CircleCI::CoverageReporter
CircleCI::CoverageReporter reports test coverage to your GitHub repository.
Example

Getting started
Add CircleCI::CoverageReporter to your
Gemfileandbundle install:gem 'circleci-coverage_reporter', group: :testLoad
circleci/coverage_reporter/rake_taskin yourRakefile:require 'circleci/coverage_reporter/rake_task' if ENV['CIRCLECI']Issue CircleCI and GitHub tokens and add them to build environment variables as follows:
Name Value COVERAGE_REPORTER_CIRCLECI_TOKENCircleCI API token with "view-builds" scope COVERAGE_REPORTER_VCS_TOKENGitHub personal access token with "repo" or "public_repo" scope Add the following step to your
circle.yml:test: post: - bundle exec rake circleci:report_coverage
Run manually
You must configure circleci_token and vcr_token before CircleCI::CoverageReporter.run:
CircleCI::CoverageReporter.configure do |config|
config.circleci_token = YOUR_CIRCLECI_API_TOKEN
config.vcr_token = YOUR_GITHUB_PERSONAL_ACCESS_TOKEN
end
CircleCI::CoverageReporter.run
Reporters
SimpleCov
CircleCI::CoverageReporter::SimpleCov::Reporter handles coverage files generated by
SimpleCov.
It expects that coverage files are located in $CIRCLE_ARTIFACTS/coverage directory:
# spec/spec_helper.rb
require 'simplecov'
# Save to CircleCI's artifacts directory if we're on CircleCI
SimpleCov.coverage_dir(File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')) if ENV['CIRCLECI']
SimpleCov.start
If you put files in another directory, say $CIRCLE_ARTIFACTS/foo/bar, you have to set reporter as follows:
CircleCI::CoverageReporter.configure do |config|
config.reporters << CircleCI::CoverageReporter::SimpleCov::Reporter.new('foo/bar')
end
Flow
CircleCI::CoverageReporter::Flow::Reporter handles coverage files generated by
flow-coverage-report
It expects that there is $CIRCLE_ARTIFACTS/flow-coverage/flow-coverage.json:
$(npm bin)/flow-coverage-report -t json -o $CIRCLE_ARTIFACTS/flow-coverage
If you put the file in another path, say $CIRCLE_ARTIFACTS/foo/bar/flow-coverage.json,
you have to set reporter as follows:
CircleCI::CoverageReporter.configure do |config|
config.reporters << CircleCI::CoverageReporter::Flow::Reporter.new('foo/bar')
end
License
The gem is available as open source under the terms of the MIT License.