|
| 1 | +# How Annotations Work |
| 2 | + |
| 3 | +Annotations in this context are similar to GitHub annotations or workflow commands, |
| 4 | +displaying a banner in the GitHub pull request. |
| 5 | +When the option `ANNOTATE_MISSING_LINES=True` is enabled, annotations are generated for lines missing coverage. |
| 6 | +To include branch coverage in these annotations, enable `BRANCH_COVERAGE=True`. |
| 7 | +By default, these annotations are written to the console, but you can also choose to save them elsewhere. |
| 8 | + |
| 9 | +## Storing Annotations |
| 10 | + |
| 11 | +1. **To a File**: |
| 12 | + - Set the file path in `ANNOTATIONS_OUTPUT_PATH`. |
| 13 | + |
| 14 | +2. **To a Branch**: |
| 15 | + - Set the branch name in `ANNOTATIONS_DATA_BRANCH`. |
| 16 | + - Ensure your GitHub token has `Contents:write` permissions. |
| 17 | + - Make sure the branch exists and is not protected by branch protection rules. |
| 18 | + - Annotations are stored with the filename `{PR-number}-annotations.json`, |
| 19 | + where `{PR-number}` is replaced by the actual PR number. |
| 20 | + - Existing annotations for a PR in the branch will be overwritten if the file already exist in branch. |
| 21 | + - If the GitHub token user has email privacy enabled, the email format `{id}+{login}@users.noreply.github.com` is used. |
| 22 | + Where `{id}` is the user ID and `{login}` is the username. |
| 23 | + |
| 24 | +## Using the Annotations |
| 25 | + |
| 26 | +After generating the annotations, you can enable this extension. |
| 27 | +A URL is required where the annotations are accessible from the extension, with a placeholder for the PR number. |
| 28 | +For example: |
| 29 | +`https://raw.githubusercontent.com/PradeepTammali/python-coverage-comment/data/coverage-annotations/{PR-NUMBER}-annotations.json` |
| 30 | + |
| 31 | +The `{PR-NUMBER}` placeholder will be replaced with the actual PR number when viewing the PR diff. |
0 commit comments