Permalink
Browse files

Update README.md (#372)

* Update README.md

removes duplicate/confusing installation instructions

* Update README.md

* Update README.md

* Update README.md
  • Loading branch information...
davehenton committed Oct 30, 2018
1 parent d4851b4 commit b533c61caf0c7a8f541cdd01276434bfbe981d38
Showing with 10 additions and 110 deletions.
  1. +10 −110 README.md
120 README.md
@@ -1,119 +1,19 @@
# cc-test-reporter
![code-climate-logo_black-200](https://user-images.githubusercontent.com/18341459/47682820-32937480-db93-11e8-9d81-e5052a22453b.png)

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

For additional information, check out our docs on [Configuring Test Coverage](https://docs.codeclimate.com/docs/configuring-test-coverage) and [Test Coverage Troubleshooting Tips](https://docs.codeclimate.com/docs/test-coverage-troubleshooting-tips).
Code Climate's test reporter is a binary that works in coordination with codeclimate.com 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](https://docs.codeclimate.com/docs/configuring-test-coverage) and [Test Coverage Troubleshooting Tips](https://docs.codeclimate.com/docs/test-coverage-troubleshooting-tips).

```yaml
machine:
environment:
CC_TEST_REPORTER_ID: ...
To sign up for Code Climate, head [here](https://codeclimate.com/quality/pricing/).

dependencies:
post:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
test:
pre:
- ./cc-test-reporter before-build
post:
- ./cc-test-reporter after-build --exit-code $EXIT_CODE
```

Where:

- `$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`.

```sh
CC_TEST_REPORTER_COVERAGE_ENDPOINT=https://codeclimate.my-domain.com/api/v1/test_reports
```

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
commands.

## 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:

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

Where:

- `$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:

```sh
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 -
```

Where:

- `$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:

```sh
./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:

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

## Copyright

See the [LICENSE](LICENSE).
See the [LICENSE](https://github.com/codeclimate/test-reporter/blob/master/LICENSE).

0 comments on commit b533c61

Please sign in to comment.