#!/usr/bin/env bash set -ex function save_pact_files_to_s3() { echo "Saving pact files to S3..." folder=${1:-latest} aws s3 cp pacts s3://ci-asset-cache/pacts/${JOB_NAME}/${folder} --recursive --only-show-errors --region us-east-1 } function cleanup() { exit_code=$? set +e docker cp coverage:/app/coverage . docker-compose kill docker-compose rm -f exit $exit_code } trap cleanup INT TERM EXIT docker-compose build --pull echo "Running test suite..." docker-compose run --name coverage testrunner $@ echo "" echo "Running contract tests..." docker-compose run --name contracts -T contracts-testrunner bundle exec rspec spec/contracts docker cp contracts:/usr/src/app/pacts . docker cp contracts:/usr/src/app/log . if [[ "${GERRIT_EVENT_TYPE}" == "change-merged" ]]; then save_pact_files_to_s3 fi