Skip to content

Commit e6b28bb

Browse files
committed
Fix workflow_run coverage wiring
- Pass run-id/github-token so download-artifact reaches the CI run - Pipe PR number through pr-number.txt (workflow_run.pull_requests is empty for fork PRs) - Pass issue-number explicitly to the comment action - Gate coverage job on pull_request event + successful CI conclusion - Restore COVERAGE_PYTHON env var; cap artifact retention at 1 day
1 parent 621bfda commit e6b28bb

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
env:
1313
UV_FROZEN: true
14+
COVERAGE_PYTHON: "3.12"
1415

1516
jobs:
1617
format:
@@ -66,10 +67,16 @@ jobs:
6667
pytest-cloud.xml \
6768
pytest.xml
6869
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+
6974
- uses: actions/upload-artifact@v7
70-
if: github.event_name == 'pull_request' && matrix.python-version == '3.12'
75+
if: github.event_name == 'pull_request' && matrix.python-version == env.COVERAGE_PYTHON
7176
with:
72-
name: coverage-${{ github.event.number }}
77+
name: coverage
78+
retention-days: 1
7379
path: |
7480
coverage.xml
7581
pytest.xml
82+
pr-number.txt

.github/workflows/coverage.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@ on:
77

88
permissions:
99
pull-requests: write
10+
actions: read
1011

1112
jobs:
1213
coverage:
14+
if: >-
15+
github.event.workflow_run.event == 'pull_request' &&
16+
github.event.workflow_run.conclusion == 'success'
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: actions/download-artifact@v8
1620
with:
17-
name: coverage-${{ github.event.workflow_run.pull_requests[0].number }}
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+
1828
- name: Pytest coverage comment
1929
uses: MishaKav/pytest-coverage-comment@v1
2030
with:
31+
issue-number: ${{ steps.pr.outputs.number }}
2132
pytest-xml-coverage-path: ./coverage.xml
2233
junitxml-path: ./pytest.xml

0 commit comments

Comments
 (0)