Skip to content

Commit 8cee006

Browse files
authored
Merge pull request childmindresearch#77 from childmindresearch/maint/ci-coverage
Fix coverage commenting from pull requests
2 parents d0e2788 + e6b28bb commit 8cee006

2 files changed

Lines changed: 48 additions & 10 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ name: CI
22

33
permissions:
44
contents: read
5-
pull-requests: write
65

76
on:
87
push:
9-
branches: [ "main" ]
8+
branches: ["main"]
109
pull_request:
11-
branches: [ "main" ]
10+
branches: ["main"]
1211

1312
env:
1413
UV_FROZEN: true
@@ -33,7 +32,7 @@ jobs:
3332
needs: format
3433
strategy:
3534
matrix:
36-
python-version: [ "3.11", "3.12", "3.13", "3.14" ]
35+
python-version: ["3.11", "3.12", "3.13", "3.14"]
3736
steps:
3837
- uses: actions/checkout@v6
3938
with:
@@ -68,10 +67,16 @@ jobs:
6867
pytest-cloud.xml \
6968
pytest.xml
7069
71-
- name: Pytest coverage comment
72-
if: github.event_name == 'pull_request' && matrix.python-version ==
73-
env.COVERAGE_PYTHON
74-
uses: MishaKav/pytest-coverage-comment@v1
70+
- name: Record PR number
71+
if: github.event_name == 'pull_request' && matrix.python-version == env.COVERAGE_PYTHON
72+
run: echo "${{ github.event.number }}" > pr-number.txt
73+
74+
- uses: actions/upload-artifact@v7
75+
if: github.event_name == 'pull_request' && matrix.python-version == env.COVERAGE_PYTHON
7576
with:
76-
pytest-xml-coverage-path: ./coverage.xml
77-
junitxml-path: ./pytest.xml
77+
name: coverage
78+
retention-days: 1
79+
path: |
80+
coverage.xml
81+
pytest.xml
82+
pr-number.txt

.github/workflows/coverage.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Coverage report
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
types: [completed]
7+
8+
permissions:
9+
pull-requests: write
10+
actions: read
11+
12+
jobs:
13+
coverage:
14+
if: >-
15+
github.event.workflow_run.event == 'pull_request' &&
16+
github.event.workflow_run.conclusion == 'success'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/download-artifact@v8
20+
with:
21+
name: coverage
22+
run-id: ${{ github.event.workflow_run.id }}
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- id: pr
26+
run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT"
27+
28+
- name: Pytest coverage comment
29+
uses: MishaKav/pytest-coverage-comment@v1
30+
with:
31+
issue-number: ${{ steps.pr.outputs.number }}
32+
pytest-xml-coverage-path: ./coverage.xml
33+
junitxml-path: ./pytest.xml

0 commit comments

Comments
 (0)