Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
git-pull-request

GitHub Action

Test Coverage Reporter

v1.0.5

Test Coverage Reporter

git-pull-request

Test Coverage Reporter

Generate a coverage report based on a base/master coverage report"

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Test Coverage Reporter

uses: jgillick/test-coverage-reporter@v1.0.5

Learn more about this action in jgillick/test-coverage-reporter

Choose a version

Test Coverage Reporter

A github action that generates a comprehensive unit test coverage report, including optional diff with the branch the PR will merge into.

Screenshot

Usage

- uses: jgillick/test-coverage-reporter@v1
  with:
    coverage-file: coverage/coverage-final.json
    access-token: ${{ secrets.GITHUB_TOKEN }}

Inputs

  • coverage-file: Path to the test coverage report
  • base-coverage-file: Path to the coverage report to compare against. This is most likely from the branch you plan to merge into.
  • access-token: Required to comment on the PR
  • fail-delta: If coverage for any file is reduced by this much (in percent) the run will fail. (default: 0.2)
  • title: The coverage report title
  • custom-message: Add this custom text to the output.
  • strip-path-prefix: Remove this part of the path of the front of all file paths in the coverage report.

Compare coverage with base

You can easily see how this PR will either add or remove coverage from the branch it will be merging into by passing the base-coverage-file input.

- uses: jgillick/test-coverage-reporter@v1
  with:
    coverage-file: coverage/coverage-final.json
    base-coverage-file: main-branch/coverage/coverage-final.json
    access-token: ${{ secrets.GITHUB_TOKEN }}

See a full example in this repos workflow.

For larger test suites, it can be more performant to save the base coverage to a longer-lived artifact and use an action like actions-download-artifact to download it.

Also try

You might also like the Test Coverage Annotations action, which makes it easier to see which lines are lacking test coverage.

Test Coverage Annotation Screenshot

Acknowledgements

This action was inspired by the work of Jest coverage report and Jest Coverage Reporter Action.