Comment coverage #2364
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment coverage | |
on: | |
workflow_run: | |
workflows: [Tests] | |
types: | |
- completed | |
permissions: | |
pull-requests: write | |
jobs: | |
comment: | |
name: Comment coverage | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion != 'cancelled' | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Find associated pull request | |
id: pr | |
uses: actions/github-script@v7 | |
if: ${{ github.event.workflow_run.pull_requests[0].number == null }} | |
with: | |
script: | | |
const response = await github.rest.pulls.list({ | |
owner: "${{ github.repository_owner }}", | |
repo: context.payload.workflow_run.repository.name, | |
state: "open", | |
head: `${context.payload.workflow_run.head_repository.owner.login}:${context.payload.workflow_run.head_branch}`, | |
}); | |
return response.data[0]?.number ?? ""; | |
retries: 3 | |
- name: Comment coverage | |
uses: MishaKav/pytest-coverage-comment@fa1c641d7e3fa1d98ed95d5f658ccd638b774628 | |
with: | |
pytest-xml-coverage-path: coverage.xml | |
junitxml-path: coverage-junit.xml | |
issue-number: ${{ github.event.workflow_run.pull_requests[0].number || steps.pr.outputs.result }} | |
report-only-changed-files: true |