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 GitHubTrust Signals
- Scorecard Score
- Scorecard 4–6scored Jul 6, 2026
- Maintenance Recency
- Activelast commit Jul 10, 2026
- License
- MIT
Pinned Snippet
uses: py-cov-action/python-coverage-comment-action@5d8df5979747514c914e1c5a12335a7cf9a2745f # v4.1tags can be moved; commit SHAs can't. why a SHA?
Inputs
| name | description | required | default |
|---|---|---|---|
| ACTIVITY | Use 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_URL | The 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. | no | https://api.github.com |
| GITHUB_TOKEN | A 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_ID | Only 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_BRANCH | Name 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. | no | python-coverage-comment-action-data |
| COVERAGE_PATH | Path to the directory under the git root where the coverage data is stored. Default is '.'. | no | . |
| COMMENT_ARTIFACT_NAME | Name 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. | no | python-coverage-comment-action |
| COMMENT_FILENAME | Name of the file in which the body of the comment to post on the PR is stored. In monorepo setting, see SUBPROJECT_ID. | no | python-coverage-comment-action.txt |
| SUBPROJECT_ID | This 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_GREEN | If the coverage percentage is above or equal to this value, the badge will be green. | no | 100 |
| MINIMUM_ORANGE | If the coverage percentage is not green and above or equal to this value, the badge will be orange. Otherwise it will be red. | no | 70 |
| MAX_FILES_IN_COMMENT | Maximum 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.) | no | 25 |
| MERGE_COVERAGE_FILES | If true, will run `coverage combine` before reading the `.coverage` file. | — | false |
| ANNOTATE_MISSING_LINES | If true, will create an annotation on every line with missing coverage on a pull request. | — | false |
| ANNOTATION_TYPE | Only 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_URL | If true, will use the GitHub Pages URL for the coverage report instead of the raw URL or an htmlpreview.github.io link. | — | false |
| VERBOSE | Deprecated, see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging | — | false |
Outputs
| name | description |
|---|---|
| activity_run | The type of activity that was run. One of `process_pr`, `post_comment`, `save_coverage_data_files`. |
| comment_file_written | A 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_lines | The number of covered lines in the pull request. (Only available in PR mode) |
| new_num_statements | The number of statements in the pull request. (Only available in PR mode) |
| new_percent_covered | The coverage percentage of the pull request. (Only available in PR mode) |
| new_missing_lines | The number of lines with missing coverage in the pull request. (Only available in PR mode) |
| new_excluded_lines | The number of excluded lines in the pull request. (Only available in PR mode) |
| new_num_branches | The number of branches in the pull request. (Only available in PR mode) |
| new_num_partial_branches | The number of partial branches in the pull request. (Only available in PR mode) |
| new_covered_branches | The number of covered branches in the pull request. (Only available in PR mode) |
| new_missing_branches | The number of branches with missing coverage in the pull request. (Only available in PR mode) |
| reference_covered_lines | The number of covered lines in the base branch. (Only available in PR mode) |
| reference_num_statements | The number of statements in the base branch. (Only available in PR mode) |
| reference_percent_covered | The coverage percentage of the base branch. (Only available in PR mode) |
| reference_missing_lines | The number of lines with missing coverage in the base branch. (Only available in PR mode) |
| reference_excluded_lines | The number of excluded lines in the base branch. (Only available in PR mode) |
| reference_num_branches | The number of branches in the base branch. (Only available in PR mode) |
| reference_num_partial_branches | The number of partial branches in the base branch. (Only available in PR mode) |
| reference_covered_branches | The number of covered branches in the base branch. (Only available in PR mode) |
| reference_missing_branches | The number of branches with missing coverage in the base branch. (Only available in PR mode) |
| diff_total_num_lines | The total number of lines in the diff. (Only available in PR mode) |
| diff_total_num_violations | The total number of lines with missing coverage in the diff. (Only available in PR mode) |
| diff_total_percent_covered | The coverage percentage of the diff. (Only available in PR mode) |
| diff_num_changed_lines | The number of changed lines in the diff. (Only available in PR mode) |