Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/coverage-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Coverage Comment
on: # yamllint disable-line rule:truthy # zizmor: ignore[dangerous-triggers]
workflow_run:
workflows: [Test]
types: [completed]
permissions:
actions: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download artifact
# yamllint disable-line rule:line-length
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # ratchet:actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: pr
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read PR number
id: pr
run: |
pr_number=$(cat NR)
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "Invalid PR number: $pr_number" >&2
exit 1
fi
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
- name: Post coverage comment
# yamllint disable-line rule:line-length
uses: MishaKav/pytest-coverage-comment@dd5b80bde6d16941f336518e92929e89069d8451 # ratchet:MishaKav/pytest-coverage-comment@v1.7.2
with:
pytest-xml-coverage-path: coverage.xml
unique-id-for-comment: coverage
issue-number: ${{ steps.pr.outputs.number }}
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: # yamllint disable-line rule:truthy
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -27,9 +26,14 @@ jobs:
uv run --dev pytest \
tests/ --cov=git_commit_guard --cov-report=term-missing \
--cov-report=xml
- name: Post coverage comment
- name: Save coverage artifact
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
cp coverage.xml ./pr/
- name: Upload PR artifact
# yamllint disable-line rule:line-length
uses: MishaKav/pytest-coverage-comment@dd5b80bde6d16941f336518e92929e89069d8451 # v1.7.2
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4
with:
pytest-xml-coverage-path: coverage.xml
unique-id-for-comment: coverage
name: pr
path: pr/
Loading