bin/test
#!/bin/bash
set -eo pipefail
if [[ -z "$DOCKER" ]]; then
echo "--- :buildkite: Building zero_downtime_migrations"
buildkite-agent --version
echo "branch: $BUILDKITE_BRANCH"
echo "commit: $BUILDKITE_COMMIT"
echo "image: $DOCKER_IMAGE"
echo "--- :docker: Starting docker"
docker --version
docker-compose --version
echo "Building $DOCKER_IMAGE"
docker-compose run app /app/bin/test $@
exit 0
fi
echo "--- :terminal: Loading environment"
echo "bash: `bash --version | head -1`"
echo "git: `git --version`"
echo "imagemagick: `identify --version | head -1`"
echo "java: `java -version 2>&1 | head -1`"
echo "os: `cat /etc/issue | head -1`"
echo "phantomjs: `phantomjs --version`"
echo "--- :ruby: Installing ruby"
rbenv install --skip-existing
ruby --version
rbenv --version
echo "--- :rubygems: Installing ruby gems"
echo "gem $(gem --version)"
bundler --version
cpus=$(nproc 2>/dev/null || echo 1)
[[ $cpus -eq 1 ]] && jobs=1 || jobs=$((cpus - 1))
options="--path vendor/bundle --jobs $jobs --retry 3 --frozen --no-cache --no-prune"
bundle check || bundle install $options
echo "--- :postgres: Creating database"
sleep 3 # give postgres container time to boot
createdb -h postgres -U postgres -w zero_downtime_migrations || true
echo "+++ :rspec: Running rspec tests"
echo "rspec $(bundle exec rspec --version)"
bundle exec rspec $@
bundle exec codeclimate-test-reporter