A Github action to check if you didn't degrade your code coverage.
This action is split into two actions :
| Context | Action | Description |
|---|---|---|
| Push on main branch | update | By configuring the "update" action to be ran on pushes to your main branch, it will parse your clover file, generate a JSON containing interesting metrics, and push it to a branch named coverage. You'll benefit from the natural commits history to track the evolution of your overall coverage. |
| Pull request | check | By configuring the "check" action to be ran on pull requests, it will get the main branch's coverage, located in the coverage branch, and compare it to your pull request's coverage. A report will be posted as a comment on your pull request, and the action will fail if the coverage has been degraded. |
The update process is the one used to update coverage report for the main branch of the project. After calculation, it pushes results to a dedicated coverage branch.
Here is an exemple of how to use it (on a php project) :
name: Coverage update
on:
push:
branches:
- main
jobs:
coverage_update:
runs-on: ubuntu-lastest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite
run: make test
- name: Coverage update
uses: OpenClassrooms/coverage-checker@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
action: updateNote that the
Run test suitestep will generate acloverfile containing the coverage information. This action will use this file to generate the report.
name: Coverage check
on: [pull_request]
jobs:
coverage_check:
runs-on: ubuntu-lastest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite
run: make test
- name: Coverage check
uses: OpenClassrooms/coverage-checker@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
action: checkThe output of this action is a comment on the PR to simply see if the coverage has been degraded or not, and an action failure in case of degradation.
| Parameter | Required | Default | Comment |
|---|---|---|---|
token |
Yes | No default | The action token. Will be used to push or read from coverage branch |
action |
No | update |
The action to be executed. Either update or check |
coverage-file |
No | coverage.xml |
The clover file that will be generated by your test suite |
summary-file |
No | coverage-summary.json |
The json file that will be created by this action and uploaded to the coverage branch |
After having cloned the project, run make install, that will install dependencies, and ncc (required to compile code before pushing it).
Compile code before committing by running this command:
make


