#! /usr/bin/env sh
#
#  run as part of CI
#
if [ $# -lt 1 ] ; then
  echo "usage: $(basename $0) <gems_dir> [install_flags]"
  exit 1
fi

GEMS_DIR=$1
shift
INSTALL_FLAGS=$*

test -e /etc/os-release && cat /etc/os-release

set -e -x -u

cd $GEMS_DIR

  gemfile=$(ls *.gem | head -n1)
  ls -l ${gemfile}
  gem install --no-document ${gemfile} -- ${INSTALL_FLAGS}
  gem list -d sqlite3

cd ..

bundle config set without development
bundle install --local || bundle install

rm -rf lib ext # ensure we don't use the local files
rake test
