Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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
            - main
permissions:
    contents: read
    pull-requests: write
jobs:
    coverage:
        runs-on: ubuntu-latest
        steps:
          - name: Get Cover 
            uses: orgoro/coverage@v3.2
            with:
                coverageFile: path/to/coverage.xml
                token: ${{ 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

Input Optional Description Example
coverageFile path to .xml coverage report ./path/to/coverage.xml
token your github token 🀫
thresholdAll βœ… the minimal average line coverage 0.8
thresholdNew βœ… the minimal average new files line coverage 0.9
thresholdModified βœ… the minimal average modified files line coverage 0.0
passIcon βœ… the indicator to use for files that passed 🟒
failIcon βœ… the indicator to use for files that failed πŸ”΄
sourceDir βœ… the directory to use as the source of the coverage report ./path/to/src
title βœ… heading text for the PR comment; set a unique value per matrix entry to post separate comments Python Coverage 3.11

About

GitHub Action for python coverage publish & analysis

Topics

Resources

Stars

141 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages