2019-10-12 01:11:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -ueo pipefail
|
|
|
|
|
|
|
|
export LANG=C.UTF-8 LANGUAGE=C.UTF-8
|
|
|
|
# test-reporter expects reporter identifier under this environment variable
|
2019-11-28 04:26:27 +00:00
|
|
|
CC_TEST_REPORTER_ID="$COVERAGE_ID"
|
|
|
|
export CC_TEST_REPORTER_ID
|
2019-10-12 01:11:22 +00:00
|
|
|
TEST_REPORTER_VERSION="0.6.3"
|
2019-10-17 23:37:47 +00:00
|
|
|
S3_URL="s3://public-cd-buildkite-cache/$BUILDKITE_PIPELINE_SLUG/$BUILDKITE_LABEL"
|
2019-10-12 01:11:22 +00:00
|
|
|
|
|
|
|
download_test_reporter() {
|
2019-10-17 23:37:47 +00:00
|
|
|
curl -o test-reporter -L https://codeclimate.com/downloads/test-reporter/test-reporter-"$TEST_REPORTER_VERSION"-linux-amd64
|
2019-10-12 01:11:22 +00:00
|
|
|
chmod +x test-reporter
|
|
|
|
}
|
|
|
|
|
|
|
|
download_s3_file() {
|
2019-10-17 23:37:47 +00:00
|
|
|
aws s3 cp "$S3_URL/$1" "$1"
|
2019-10-12 01:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
upload_s3_file() {
|
|
|
|
if [ -f "$1" ]; then
|
2019-10-17 23:37:47 +00:00
|
|
|
aws s3 cp "$1" "$S3_URL/$1" || echo "Could not push $1 to S3 for caching."
|
2019-10-12 01:11:22 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "--- downloading coverage tool"
|
2019-10-17 23:37:47 +00:00
|
|
|
download_s3_file test-reporter || download_test_reporter
|
|
|
|
download_s3_file test-reporter.sha || echo "Could not download test-reporter.sha"
|
2019-10-12 01:11:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
echo "--- updating rubygems"
|
|
|
|
gem update --system -N
|
|
|
|
|
|
|
|
echo "--- system details"
|
|
|
|
uname -a
|
|
|
|
gem env
|
|
|
|
bundle --version
|
|
|
|
|
|
|
|
echo "--- setting up test coverage before build"
|
|
|
|
./test-reporter before-build
|
|
|
|
|
|
|
|
echo "--- bundle install"
|
|
|
|
bundle install --jobs=7 --retry=3 --without tools maintenance deploy
|
|
|
|
|
|
|
|
echo "+++ bundle exec rake"
|
|
|
|
bundle exec rake "${RAKE_TASK:-}"
|
|
|
|
EXIT-CODE=$?
|
|
|
|
|
|
|
|
echo "+++ formatting and uploading test coverage"
|
2019-10-17 23:37:47 +00:00
|
|
|
./test-reporter after-build -t simplecov --exit-code "$EXIT_CODE"
|
2019-10-12 01:11:22 +00:00
|
|
|
|
2019-10-17 23:37:47 +00:00
|
|
|
echo "--- uploading test-reporter.sha to s3"
|
2019-10-12 01:11:22 +00:00
|
|
|
if [ "test-reporter" -nt "test-reporter.sha" ]; then
|
|
|
|
if shasum --check test-reporter.sha --status; then
|
|
|
|
shasum -a 256 test-reporter > test-reporter.sha
|
|
|
|
for i in "test-reporter" "test-reporter.sha"; do
|
|
|
|
upload_s3_file "$i"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|