Browse files

Update (#372)

* Update

removes duplicate/confusing installation instructions

* Update

* Update

* Update
  • Loading branch information...
davehenton committed Oct 30, 2018
1 parent d4851b4 commit b533c61caf0c7a8f541cdd01276434bfbe981d38
Showing with 10 additions and 110 deletions.
  1. +10 −110
@@ -1,119 +1,19 @@
# cc-test-reporter

Report information about your CI builds to Code Climate.
# Code Climate Test Reporter

For additional information, check out our docs on [Configuring Test Coverage]( and [Test Coverage Troubleshooting Tips](
Code Climate's test reporter is a binary that works in coordination with to report test coverage data. Once you've set up test coverage reporting you can:
* view test coverage reports for each file alongside quality metrics like complexity, duplication, and churn,
* toggle between viewing code issues and test coverage line-by-line in the same source listings,
* block PRs from being merged if they don't meet your team's standards for test coverage percentage.

## Installation & Usage
Code Climate accepts test coverage data from virtually any location, including locally run tests or your continuous integration (CI) service, and supports a variety of programming languages and test coverage formats, including Ruby, JavaScript, Go, Python, PHP, Java, and more.

Most CI systems allow configuration of commands to run as part of setup, before,
and after a test build. Using Circle CI as an example:
For installation instructions, check out our docs on [Configuring Test Coverage]( and [Test Coverage Troubleshooting Tips](

To sign up for Code Climate, head [here](

- curl -L > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- ./cc-test-reporter after-build --exit-code $EXIT_CODE


- `$EXIT_CODE` should be the exit code of your test suite process. Some CI
system expose this as an environment variable; for others, you may need
to manually capture $? to provide it to after-build later. Providing this
will prevent sending test coverage results for failed tests.

## Code Climate: Enterprise

To report coverage to your locally-hosted *Code Climate: Enterprise* instance,
export the `CC_TEST_REPORTER_COVERAGE_ENDPOINT` variable, or pass the
`--coverage-endpoint` option to `after-build`.


If you're using a self-signed certificate, export the `SSL_CERT_FILE` variable
indicating the location of the certificate file when using `after-build` or `upload-coverage` commands.

## Low-level Usage

The test reporter is implemented as a composition of lower-level commands, which
may themselves be useful. See the [man-pages](man) for details of these

## Parallel Tests

Code Climate supports parallel test setups using sub-commands provided by the
test reporter. Specifically, the test reporter has sub-commands to:

1. format partial results (`format-coverage`)
1. sum partial results into a single result (`sum-coverage`) and
1. upload the single result to Code Climate (`upload-coverage`)

To make use of these commands, parallel test support requires:

1. the ability to run commands after *each* batch of tests has completed (most CI systems support this)
1. the ability to run commands after *all* tests have completed (most CI systems support this)
1. uploading and downloading partial test coverage data to/from shared storage
(using AWS S3, for example)

For example:

1. After *each* batch of tests:

./cc-test-reporter format-coverage --output "coverage/codeclimate.$N.json"
aws s3 sync coverage/ "s3://my-bucket/coverage/$BUILD_NUMBER"


- `$N` should be a unique identifier for that batch of tests
- `$BUILD_NUMBER` should be the build number provided by your CI.

1. After *all* tests:

aws s3 sync "s3://my-bucket/coverage/$BUILD_NUMBER" coverage/
cc-test-reporter sum-coverage --output - --parts $PARTS coverage/codeclimate.*.json | \
cc-test-reporter upload-coverage --input -


- `$PARTS` should be the number of payloads to sum.

## Multiple Suites

Coverage from multiple suites can be sent to Code Climate by aggregating each
suite's results into one final report.

1. After each test suite, run:

./cc-test-reporter format-coverage --output coverage/codeclimate.$SUITE.json
If format-coverage is not capturing the ideal format, use `--input-type` flag.

1. After all test suites, run:

./cc-test-reporter sum-coverage coverage/codeclimate.*.json
./cc-test-reporter upload-coverage

## Copyright

See the [LICENSE](

0 comments on commit b533c61

Please sign in to comment.