Skip to content

Python Coverage

Actions

About

Publish coverage report to a PR enforce coverage on new modified files
v3.3.1
Latest
Star (141)

Python Coverage: The Esential Coverage Reporter GitHub Action for python

☂️ parse and publish coverage xml to a PR, enforce coverage rate on new & modified files

Usage

Create a new workflow .yml file in the .github/workflows/ directory.

You can create a coverage report using python:

  • pytest $ pytest --cov-report xml:path/to/coverage.xml
  • coverage $ coverage xml path/to/coverage.xml

Minimal Configuration

name: 'coverage'on:
pull_request:
branches:
- master
- mainpermissions:
contents: readpull-requests: writejobs:
coverage:
runs-on: ubuntu-lateststeps:
- name: Get Cover uses: orgoro/coverage@v3.2with:
coverageFile: path/to/coverage.xmltoken: ${{ secrets.GITHUB_TOKEN }}

Required Permissions

The action needs pull-requests: write to post (and update) the coverage comment, and contents: read to fetch the diff between base and head. If your workflow restricts the default token (e.g. via a repo-wide permissions: read-all), set them explicitly as shown above.

PR Message & Job Summary 🆕

message

Inputs

InputOptionalDescriptionExample
coverageFilepath to .xml coverage report./path/to/coverage.xml
tokenyour github token🤫
thresholdAllthe minimal average line coverage0.8
thresholdNewthe minimal average new files line coverage0.9
thresholdModifiedthe minimal average modified files line coverage0.0
passIconthe indicator to use for files that passed🟢
failIconthe indicator to use for files that failed🔴
sourceDirthe directory to use as the source of the coverage report./path/to/src
titleheading text for the PR comment; set a unique value per matrix entry to post separate commentsPython Coverage 3.11

Python Coverage is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Publish coverage report to a PR enforce coverage on new modified files
v3.3.1
Latest

Python Coverage is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.