GitHub Action which parse a XML cobertura report and display the metrics in a GitHub Pull Request.
Many coverage tools can be configured to output cobertura reports:
This action will not currently work when triggered by pull requests from forks, like is common in open source projects. This is because the token for forked pull request workflows does not have write permissions on the target repository. Hopefully GitHub will have a solution for this in the future. In the meantime one can use utilize multiple workflows and artifacts to circumvent this. See the workflows in this project for an implementation example and this blog post https://securitylab.github.com/research/github-actions-preventing-pwn-requests.
The GITHUB_TOKEN. See details.
The to the cobertura report. Defaults to coverage.xml
. If a glob pattern is provided it will take the first match.
If files with 100% coverage should be ignored. Defaults to true
.
The minimum allowed coverage percentage as an integer.
Show line rate as specific column.
Show branch rate as specific column.
Show class names instead of file names.
Show line numbers of statements, per module, that weren't executed.
Crop missing line numbers strings that exceeds this length, provided as an integer.
Default is no crop.
(Note: "..." is appended to a cropped string)
Only show coverage for changed files.
Use a unique name for the report and comment.
Pull request number associated with the report. This property should be used when workflow trigger is different than pull_request
.
on:
pull_request:
types: [opened]
branches:
- master
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: 5monkeys/cobertura-action@master
with:
path: src/test.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
minimum_coverage: 75
- Install deps:
npm ci
- Run tests:
npm run test
- Run lint:
npm run lint
- Package application
npm run package
. Remember to run this before committing anything.