diff --git a/.expeditor/buildkite/coverage.sh b/.expeditor/buildkite/coverage.sh new file mode 100755 index 000000000..4418d308a --- /dev/null +++ b/.expeditor/buildkite/coverage.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +set -ueo pipefail + +export LANG=C.UTF-8 LANGUAGE=C.UTF-8 +# test-reporter expects reporter identifier under this environment variable +CC_TEST_REPORTER_ID="$COVERAGE_ID" +export CC_TEST_REPORTER_ID +TEST_REPORTER_VERSION="0.6.3" +S3_URL="s3://public-cd-buildkite-cache/$BUILDKITE_PIPELINE_SLUG/$BUILDKITE_LABEL" + +download_test_reporter() { + curl -o test-reporter -L https://codeclimate.com/downloads/test-reporter/test-reporter-"$TEST_REPORTER_VERSION"-linux-amd64 + chmod +x test-reporter + touch new_test-reporter +} + +download_s3_file() { + aws s3 cp "$S3_URL/$1" "$1" +} + +upload_s3_file() { + if [ -f "$1" ]; then + aws s3 cp "$1" "$S3_URL/$1" || echo "Could not push $1 to S3 for caching." + fi +} + +echo "--- downloading coverage tool" +download_s3_file test-reporter || download_test_reporter +download_s3_file test-reporter.sha || echo -e "\nCould not download test-reporter.sha" + + +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 test +EXIT_CODE=$? + +echo "+++ formatting and uploading test coverage" +./test-reporter after-build -t simplecov --exit-code "$EXIT_CODE" + +echo "--- uploading test-reporter.sha to s3" +if [ -f "new_test-reporter" ]; then + echo "new test-reporter detected. uploading." + shasum -a 256 test-reporter > test-reporter.sha + for i in "test-reporter" "test-reporter.sha"; do + upload_s3_file "$i" + done +fi + +if shasum --check test-reporter.sha --status; then + echo "test-reporter shasum mismatch. uploading." + shasum -a 256 test-reporter > test-reporter.sha + for i in "test-reporter" "test-reporter.sha"; do + upload_s3_file "$i" + done +fi diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 316c271c3..0b7ad7dea 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -170,4 +170,4 @@ subscriptions: only_if_team_member: - inspec/owners - inspec/inspec-core-team - - post_github_comment:.expeditor/templates/pull_request.mustache + - trigger_pipeline:coverage diff --git a/.expeditor/coverage.pipeline.yml b/.expeditor/coverage.pipeline.yml index ba44dddbe..45630e379 100644 --- a/.expeditor/coverage.pipeline.yml +++ b/.expeditor/coverage.pipeline.yml @@ -9,9 +9,11 @@ steps: - label: coverage commands: - - bundle install --jobs=7 --retry=3 --without tools maintenance deploy - - bundle exec rake test:default + - .expeditor/buildkite/coverage.sh expeditor: executor: docker: - image: ruby:2.6-stretch + secrets: + COVERAGE_ID: + path: secret/coveralls/inspec/inspec + field: reporter_id diff --git a/Gemfile b/Gemfile index 7cfd83b3d..d46320efc 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,6 @@ end group :test do gem "chefstyle", "~> 0.13.0" - gem "coveralls", require: false gem "minitest", "~> 5.5" gem "minitest-sprint", "~> 1.0" gem "rake", ">= 10" diff --git a/test/helper.rb b/test/helper.rb index a99339578..95fb81e88 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -2,18 +2,12 @@ # Do not add any code above this line. ## -# Do not add any other code to this code block. Simplecov and -# coveralls only until the next code block: +# Do not add any other code to this code block. Simplecov +# only until the next code block: if ENV["CI_ENABLE_COVERAGE"] require "simplecov/no_defaults" require "helpers/simplecov_minitest" - require "coveralls" - - SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter, - ]) SimpleCov.start do add_filter "/test/"