Skip to content

Instantly share code, notes, and snippets.

@ale7714
Last active February 4, 2020 16:55
Show Gist options
  • Save ale7714/8da439bfe9fe4e0b61dfdb056172b1ee to your computer and use it in GitHub Desktop.
Save ale7714/8da439bfe9fe4e0b61dfdb056172b1ee to your computer and use it in GitHub Desktop.
CC test reporter on Travis parallel builds
language: ruby
env:
global:
- CC_TEST_REPORTER_ID=<repo_test_reporter_id>
- RSPEC_PARALLELISM=4 # total number of jobs
matrix:
- "RSPEC_TEST_GROUP=1"
- "RSPEC_TEST_GROUP=2"
- "RSPEC_TEST_GROUP=3"
- "RSPEC_TEST_GROUP=4"
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
script:
- bundle exec parallel_test spec/ -n $RSPEC_PARALLELISM --only-group $RSPEC_TEST_GROUP --group-by filesize --type rspec
- ./format-coverage
after_script:
- ./sum-upload-coverage
#!/bin/sh
pip install --user awscli
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
./cc-test-reporter format-coverage -t simplecov --output coverage/codeclimate.$RSPEC_TEST_GROUP.json coverage/.resultset.json
aws s3 cp coverage/codeclimate.$RSPEC_TEST_GROUP.json s3://bucket/codeclimate/$TRAVIS_REPO_SLUG/$TRAVIS_BUILD_NUMBER/codeclimate.$RSPEC_TEST_GROUP.json
fi
#!/bin/sh
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ $TRAVIS_TEST_RESULT == 0 ]; then
aws s3 cp --recursive s3://bucket/codeclimate/$TRAVIS_REPO_SLUG/$TRAVIS_BUILD_NUMBER/ coverage
./cc-test-reporter sum-coverage --output - --parts $RSPEC_PARALLELISM coverage/codeclimate.* | ./cc-test-reporter upload-coverage --input -
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment