Reviewing test coverage information for a whole repository can be overwhelming and hard to take action on. It's much more useful to catch gaps in coverage as they're introduced to a repo, right in the context of pull requests!
All processing is done within Github Actions, no data is sent to an external server.
| Key | Required | Default | Description |
|---|---|---|---|
GITHUB_TOKEN |
yes | - | Github Token generated by Github Action workflow. You can pass this in as ${{secrets.GITHUB_TOKEN}} |
GITHUB_BASE_URL |
no | https://api.github.com |
Base URL for GitHub API. Required for GitHub Enterprise Server or Cloud. |
COVERAGE_FILE_PATH |
yes | - | Location of coverage file that was generated |
COVERAGE_FORMAT |
no | lcov |
Format of coverage file. May be lcov, clover, or go |
DEBUG |
no | - | Log debugging information. Comma-separated list of possible values coverage, pr_lines_added |
Add the action to your workflow file like so, replacing the file path and coverage format with values appropriate for your repo:
- name: Code Coverage Annotation
uses: ggilder/codecoverage@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
COVERAGE_FILE_PATH: "./coverage/lcov.info"
COVERAGE_FORMAT: "lcov"You need to the GITHUB_BASE_URL input to point to your API endpoint to use this action with GitHub Enterprise Server or Cloud. For example:
with:
GITHUB_BASE_URL: https://github.acme-inc.com/api/v3 # for GitHub Enterprise Serveror
with:
GITHUB_BASE_URL: https://api.acme-inc.ghe.com # for GitHub Enterprise Cloud- name: Run tests with coverage
run: go test -v ./... -coverprofile coverage.out
- name: Code Coverage Annotation
uses: ggilder/codecoverage@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
COVERAGE_FILE_PATH: coverage.out
COVERAGE_FORMAT: goSet up npm run test:cov in your package.json scripts to run jest --coverage, which will output Lcov formatted information to coverage/lcov.info.
- Java/Groovy can use Clover format
- PHPUnit will output Clover with the
--coverage-cloverflag - C++: GCC Gcov can output Lcov format; this blog post may help you get started.
- Ruby: Simplecov can output Lcov format when you add the
simplecov-lcovgem to your Gemfile. Make sure to setSimpleCov::Formatter::LcovFormatter.config.report_with_single_filetotrueand provide the path to the output file usingCOVERAGE_FILE_PATHas described above.
First, you'll need to have a reasonably modern version of
nodehandy, ideally 16 or newer. Older versions will change the format ofpackage-lock.json.
Install the dependencies:
$ npm installRun formatting and linting, build the typescript and package it for distribution, and run tests:
$ npm run allMake sure you commit the dist/ folder or CI will fail.
You can validate the action while developing by referencing ./ in a workflow in your repo (see test.yml)
uses: ./
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
COVERAGE_FILE_PATH: "./coverage/lcov.info"This project was originally based on https://github.com/shravan097/codecoverage (which is unmaintained).
