Last active
April 17, 2025 21:05
-
-
Save armandofox/6273653fa68744d720842e6a6e5be04f to your computer and use it in GitHub Desktop.
Getting coverage working with CodeClimate in CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make CCTR an alias for './cc-test-reporter' | |
# NOTE: the other gist [https://gist.github.com/armandofox/29d09a904c08c26f5e50cea60219f2fc] | |
# showing env.rb relies on checking $CCTR to see if it is set, | |
# as a way to know whether we are running in CI or locally. | |
runs-on: ubuntu-latest | |
env: | |
CCTR: ./cc-test-reporter | |
BUNDLE_WITHOUT: production | |
TZ: America/Los_Angeles | |
# somewhere you need a step that actually fetches the cctr binary, | |
# and tells it you're going to do a build: | |
- name: Setup CodeClimate test-reporter | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR | |
chmod +x $CCTR | |
$CCTR before-build | |
# presumably you already have a step that installs gems, etc. when you're ready to run tests: | |
- name: run RSpec tests and capture coverage | |
run: | | |
bundle exec rspec | |
$CCTR format-coverage --output coverage/codeclimate.$SUITE.json --input-type simplecov | |
# if you use a headless browser for any Cucumber scenarios, don't waste time installing it until | |
# after rspec has passed. I use ChromeForTesting, which also requires the corresponding version | |
# of Chromedriver. Make sure you've specified in features/support/env.rb whichever headless | |
# browser you are installing here. | |
- name: Install Chrome For Testing and Chromedriver | |
uses: browser-actions/setup-chrome@v1 | |
id: install-chromedriver | |
with: | |
chrome-version: stable | |
install-chromedriver: true | |
install-dependencies: true | |
# see the separate gist | |
- name: run Cucumber tests using config/cucumber.yml options, and capture coverage | |
env: | |
CHROMEDRIVER_PATH: ${{ steps.install-chromedriver.outputs.chromedriver-path }} | |
CHROME_FOR_TESTING_PATH: ${{ steps.install-chromedriver.outputs.chrome-path }} | |
run: | | |
bundle exec cucumber --profile ci-report | |
$CCTR format-coverage --output coverage/codeclimate.$SUITE.json --input-type simplecov |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment