-
Notifications
You must be signed in to change notification settings - Fork 2
47 lines (43 loc) · 1.63 KB
/
comment_coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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@a1fe18e2b00c64a765568e2edb9f1706eb8fc88b
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: ${{ !github.event.workflow_run.head_repository.fork }} # This does not currently work for forks