py-cov-action/Python Coverage Comment

Publish diff coverage report as PR comment, and create a coverage badge to display on the readme.

View on GitHub

Trust Signals

Scorecard Score
Scorecard 4–6scored Jul 6, 2026
Maintenance Recency
Activelast commit Jul 10, 2026
License
MIT

Pinned Snippet

workflow.ymlSHA-pinned
uses: py-cov-action/python-coverage-comment-action@5d8df5979747514c914e1c5a12335a7cf9a2745f # v4.1

tags can be moved; commit SHAs can't. why a SHA?

namedescriptionrequireddefault
ACTIVITYUse this setting to override the auto-selection of the proper activity ("process_pr", "post_comment", "save_coverage_data_files"). By default, a heuristic based on the event that triggers the worflow will auto-select the proper activity no
GITHUB_BASE_URLThe base URL for the GitHub API, typically used to specify custom endpoints for GitHub Enterprise Server (e.g., `https://github.mycompany.com/api/v3`). Defaults to `https://api.github.com` for GitHub.com. nohttps://api.github.com
GITHUB_TOKENA GitHub token to write comments and write the badge & coverage data to the repository. Set to `$ {{ github.token }}` (without the space between `$` and `{`). yes
GITHUB_PR_RUN_IDOnly useful on the "workflow_run" part of the workflow. Set to `$ {{ github.event.workflow_run.id }}` (without the space between `$` and `{`). no
COMMENT_TEMPLATE[Advanced] Specify a different template for the comments that will be written on the PR. See the Action README documentation for how to use this properly. no
COVERAGE_DATA_BRANCHName of the branch in which coverage data will be stored on the repository. Default is 'python-coverage-comment-action-data'. Please make sure that this branch is not protected. In monorepo setting, see SUBPROJECT_ID. nopython-coverage-comment-action-data
COVERAGE_PATHPath to the directory under the git root where the coverage data is stored. Default is '.'. no.
COMMENT_ARTIFACT_NAMEName of the artifact in which the body of the comment to post on the PR is stored. You typically don't have to change this unless you're already using this name for something else. nopython-coverage-comment-action
COMMENT_FILENAMEName of the file in which the body of the comment to post on the PR is stored. In monorepo setting, see SUBPROJECT_ID. nopython-coverage-comment-action.txt
SUBPROJECT_IDThis setting is only necessary if you plan to run the action multiple times in the same repository. It will be appended to the value of all the settings that need to be unique, so as for the action to avoid mixing up results of multiple runs. Ideally, use dashes (`-`) rather than underscrores (`_`) to split words, for consistency. Affects `COMMENT_FILENAME`, `COVERAGE_DATA_BRANCH`. no
MINIMUM_GREENIf the coverage percentage is above or equal to this value, the badge will be green. no100
MINIMUM_ORANGEIf the coverage percentage is not green and above or equal to this value, the badge will be orange. Otherwise it will be red. no70
MAX_FILES_IN_COMMENTMaximum number of files to display in the comment. If there are more files than this number, they will only appear in the workflow summary. The selected files are the ones with the most new uncovered lines. The closer this number gets to 35, the higher the risk that it reaches GitHub's maximum comment size limit of 65536 characters. If you want more files, you may need to use a custom comment template. (Feel free to open an issue.) no25
MERGE_COVERAGE_FILESIf true, will run `coverage combine` before reading the `.coverage` file. false
ANNOTATE_MISSING_LINESIf true, will create an annotation on every line with missing coverage on a pull request. false
ANNOTATION_TYPEOnly relevant if ANNOTATE_MISSING_LINES is set to true. This parameter allows you to choose between notice, warning and error as annotation type. For more information look here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-notice-message warning
USE_GH_PAGES_HTML_URLIf true, will use the GitHub Pages URL for the coverage report instead of the raw URL or an htmlpreview.github.io link. false
VERBOSEDeprecated, see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging false
namedescription
activity_runThe type of activity that was run. One of `process_pr`, `post_comment`, `save_coverage_data_files`.
comment_file_writtenA boolean indicating whether a comment file was written to COMMENT_FILENAME or not. If so, you'll need to run the action in workflow_run mode to post it. If "false", no comment file was written (likely because the comment was already posted to the PR). Only available when running in PR mode.
new_covered_linesThe number of covered lines in the pull request. (Only available in PR mode)
new_num_statementsThe number of statements in the pull request. (Only available in PR mode)
new_percent_coveredThe coverage percentage of the pull request. (Only available in PR mode)
new_missing_linesThe number of lines with missing coverage in the pull request. (Only available in PR mode)
new_excluded_linesThe number of excluded lines in the pull request. (Only available in PR mode)
new_num_branchesThe number of branches in the pull request. (Only available in PR mode)
new_num_partial_branchesThe number of partial branches in the pull request. (Only available in PR mode)
new_covered_branchesThe number of covered branches in the pull request. (Only available in PR mode)
new_missing_branchesThe number of branches with missing coverage in the pull request. (Only available in PR mode)
reference_covered_linesThe number of covered lines in the base branch. (Only available in PR mode)
reference_num_statementsThe number of statements in the base branch. (Only available in PR mode)
reference_percent_coveredThe coverage percentage of the base branch. (Only available in PR mode)
reference_missing_linesThe number of lines with missing coverage in the base branch. (Only available in PR mode)
reference_excluded_linesThe number of excluded lines in the base branch. (Only available in PR mode)
reference_num_branchesThe number of branches in the base branch. (Only available in PR mode)
reference_num_partial_branchesThe number of partial branches in the base branch. (Only available in PR mode)
reference_covered_branchesThe number of covered branches in the base branch. (Only available in PR mode)
reference_missing_branchesThe number of branches with missing coverage in the base branch. (Only available in PR mode)
diff_total_num_linesThe total number of lines in the diff. (Only available in PR mode)
diff_total_num_violationsThe total number of lines with missing coverage in the diff. (Only available in PR mode)
diff_total_percent_coveredThe coverage percentage of the diff. (Only available in PR mode)
diff_num_changed_linesThe number of changed lines in the diff. (Only available in PR mode)