You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Coverage monitor
1.6.0
A GitHub Action that monitor coverage.
Create a workflow .yml
file in your repositories .github/workflows
directory.
Options | Description |
---|---|
github_token |
Required. The GITHUB_TOKEN secret. |
coverage_path |
Required. Path to coverage reports. |
coverage_format |
Format of coverage, supported: auto , clover and json-summary . Defaults to auto . |
working_dir |
The working directory of the action. Defaults to workflow workspace. |
clover_file |
Deprecated. Path to Clover XML file. Prefer coverage_path instead of clover_file . |
threshold_alert |
Mark the build as unstable when coverage is less than this threshold. Defaults to 50 . |
threshold_warning |
Warning when coverage is less than this threshold. Defaults to 90 . |
threshold_metric |
A metric to check threshold on, supported: statements , lines , methods or branches . Defaults to lines . |
check |
Whether check the coverage thresholds. Default to true . Ignored when event does not support checks, is not pull_request . |
status_context |
A string label to differentiate this status from the status of other systems. Defaults to Coverage Report . |
comment |
Whether comment the coverage report. Default to true . Ignored when event does not support comments, is not pull_request . |
comment_context |
A string label to differentiate the comment posted by this action. Defaults to Coverage Report . |
comment_mode |
A mode for comments, supported: replace , update or insert . Defaults to replace . |
comment_footer |
Whether comment may contain footer. Defaults to true . |
name: Tests
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Test
run: npm test
- name: Monitor coverage
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: "logs/clover.xml"
threshold_alert: 10
threshold_warning: 50
threshold_metric: "lines"
The secret GITHUB_TOKEN
is granted with some permissions, and in some cases the action may fail to post the comment or the check status,
for example on Dependabot
pull-requests. You can follow instructions from Using the GITHUB_TOKEN in a workflow guid
how to set up permissions.
You also can work around the issue with using the action with conditions, for example:
name: Tests
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Monitor coverage
if: ! contains(github.event.pull_request.user.login, 'dependabot[bot]')
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: "logs/clover.xml"
We would love for you to contribute, pull requests are welcome! Please see the CONTRIBUTING.md for more information.