Skip to content

Commit f48d961

Browse files
committed
slim workflow_run
1 parent 6ed9889 commit f48d961

File tree

2 files changed

+80
-61
lines changed

2 files changed

+80
-61
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,7 @@ jobs:
9999
path: ./src/.coverage*
100100
include-hidden-files: true
101101
compression-level: 0 # no compression
102-
103-
- name: Save PR number for coverage report
104-
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
105-
run: |
106-
mkdir -p ./pr
107-
echo ${{ github.event.number }} > ./pr/NR
108-
- uses: actions/upload-artifact@v4
109-
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
110-
# Currently: v4 has a bug https://github.com/actions/upload-artifact/issues/506
111-
# that fails on multiple parallel writes to the same filename.
112-
continue-on-error: true
113-
with:
114-
overwrite: true
115-
name: pr
116-
path: pr/NR
102+
117103

118104
- name: Test CPython typing test suite
119105
# Test suite fails on PyPy even without typing_extensions
@@ -151,4 +137,68 @@ jobs:
151137
repo: "typing_extensions",
152138
title: `Daily tests failed on ${new Date().toDateString()}`,
153139
body: "Runs listed here: https://github.com/python/typing_extensions/actions/workflows/ci.yml",
154-
})
140+
})
141+
prepare-report-coverage:
142+
name: Report coverage
143+
144+
runs-on: ubuntu-latest
145+
146+
needs: [tests]
147+
148+
if: ${{ always() }}
149+
150+
steps:
151+
- uses: actions/checkout@v4
152+
with:
153+
persist-credentials: false
154+
- name: Set up Python
155+
uses: actions/setup-python@v5
156+
with:
157+
python-version: "3"
158+
- name: Download coverage artifacts
159+
uses: actions/download-artifact@v4
160+
with:
161+
pattern: .coverage_*
162+
path: .
163+
# merge only when files are named differently
164+
merge-multiple: true
165+
- name: Install dependencies
166+
run: pip install coverage
167+
- name: Combine coverage results
168+
run: |
169+
# List the files to see what we have
170+
echo "Combining coverage files..."
171+
ls -aR .coverage*
172+
coverage combine .coverage*
173+
echo "Creating coverage report..."
174+
coverage report
175+
coverage xml
176+
177+
- name: Code Coverage Report
178+
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
179+
with:
180+
filename: coverage.xml
181+
badge: true
182+
fail_below_min: false
183+
format: markdown
184+
hide_branch_rate: false
185+
hide_complexity: true
186+
indicators: true
187+
output: both
188+
thresholds: '80 90'
189+
190+
- name: Archive code coverage report
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: code-coverage-results.md
194+
path: code-coverage-results.md
195+
compression-level: 0 # no compression
196+
- name: Save PR number for coverage report
197+
run: |
198+
echo ${{ github.event.number }} > ./pr_number.txt
199+
- uses: actions/upload-artifact@v4
200+
continue-on-error: true
201+
with:
202+
name: pr_number
203+
path: pr_number.txt
204+
compression-level: 0 # no compression

.github/workflows/coverage_report.yml

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,40 @@ on:
88
types:
99
- completed
1010

11+
permissions: {}
12+
1113
jobs:
12-
upload:
14+
cov-report:
15+
permissions:
16+
contents: read
1317
runs-on: ubuntu-latest
1418
if: >
1519
github.event.workflow_run.event == 'pull_request'
1620
steps:
1721
- name: Download PR number
1822
uses: actions/download-artifact@v4
1923
with:
20-
pattern: pr
24+
pattern: pr_number
2125
path: .
22-
# merge only when files are named differently
2326
github-token: ${{ secrets.GITHUB_TOKEN }}
2427
run-id: ${{ github.event.workflow_run.id }}
2528
- name: Extract PR number
2629
id: pr_number
2730
run: |
2831
echo "PR number is:"
29-
cat pr/NR
30-
echo "pr_number=$(cat pr/NR)" >> $GITHUB_ENV
31-
- uses: actions/checkout@v4
32-
with:
33-
persist-credentials: false
34-
- name: Set up Python
35-
uses: actions/setup-python@v5
36-
with:
37-
python-version: "3"
38-
- name: Download coverage artifacts
32+
cat pr_number.txt
33+
export "pr_number=$(cat pr_number.txt)"
34+
- name: Download coverage report
3935
uses: actions/download-artifact@v4
4036
with:
41-
pattern: .coverage_*
42-
path: .
43-
# merge only when files are named differently
44-
merge-multiple: true
45-
github-token: ${{ secrets.GITHUB_TOKEN }}
46-
run-id: ${{ github.event.workflow_run.id }}
47-
- name: Install dependencies
48-
run: pip install coverage
49-
- name: Combine coverage results
50-
run: |
51-
# List the files to see what we have
52-
echo "Combining coverage files..."
53-
ls -aR .coverage*
54-
coverage combine .coverage*
55-
echo "Creating coverage report..."
56-
coverage report
57-
coverage xml
58-
59-
- name: Code Coverage Report
60-
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
61-
with:
62-
filename: coverage.xml
63-
badge: true
64-
fail_below_min: false
65-
format: markdown
66-
hide_branch_rate: false
67-
hide_complexity: true
68-
indicators: true
69-
output: both
70-
thresholds: '80 90'
71-
37+
pattern: code-coverage-results.md
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
run-id: ${{ github.event.workflow_run.id }}
7240
- name: Add Coverage PR Comment
7341
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3
7442
if: github.event_name == 'pull_request'
7543
with:
7644
recreate: true
7745
path: code-coverage-results.md
78-
number: ${{ env.pr_number }}
46+
number: ${{ env.pr_number }}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)