PHP-Coverage-Badge is a GitAction for creating SVG coverage badges. It parses XML report files such as Clover or Cobertura and creates badges based on the coverage of lines and branches of the code.
- name: clover report
uses: athos99/php-coverage-badge@v1
with:
report: 'coverage/clover.xml'
report_type: 'clover'
coverage_line_badge_path: 'output/coverage_line.svg'
coverage_branch_badge_path: 'output/coverage_branch.svg'
Generated badges are not archived by default in your Git repository. You must archive them.
- name: archive
run: git config --local user.name "github-actions[bot]"
- run: git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git add out/coverage_line.svg
- run: git add out/coverage_branch.svg
- run: 'git commit -m "chore: add coverage badges" || true'
- name: Push changes # push the output folder to your repo
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
branch: ${{ github.ref }}
You can take inspiration from the php-coverage-badge-test file to integrate php-covevrage-badge into your GitAction
v1

Paths are always relative to the root of your repository.
-
report:
- description: 'The path to the report file.'
- required: false
- default: 'clover.xml'
-
report_type:
- description: 'The type of the generated report. Currently supported: clover, cobertura.'
- required: false
- default: 'clover'
-
coverage_line_badge_name:
- description: 'The name of the line coverage badge'
- required: false
- default: 'Line coverage'
-
coverage_branch_badge_name:
- description: 'The name of the branch coverage badge'
- required: false
- default: 'Branch coverage'
-
coverage_line_badge_path:
- description: 'The path of the line coverage badge'
- required: false
- default: 'coverage_line.svg'
-
coverage_branch_badge_path:
- description: 'The path of the branch coverage badge'
- required: false
- default: 'coverage_breanche.svg'
-
coverage_line_percent_ok:
- description: 'Acceptable limit of coverage line percent'
- required: false
- default: '80'
-
coverage_branch_percent_ok:
- description: 'Acceptable limit of coverage barnch percent'
- required: false
- default: '60'
Based on https://github.com/cicirello/jacoco-badge-generator