Skip to content

Commit 44c16ec

Browse files
authored
ci: run coverage jobs in pull_request_target context (#4483)
1 parent 03e85c2 commit 44c16ec

File tree

2 files changed

+54
-41
lines changed

2 files changed

+54
-41
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -385,46 +385,6 @@ jobs:
385385
components: rust-src
386386
- run: cargo rustdoc --lib --no-default-features --features full -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]"
387387

388-
coverage:
389-
needs: [fmt]
390-
name: coverage ${{ matrix.os }}
391-
strategy:
392-
matrix:
393-
os: ["windows-latest", "macos-14", "ubuntu-latest"] # first available arm macos runner
394-
runs-on: ${{ matrix.os }}
395-
steps:
396-
- if: ${{ github.event_name == 'pull_request' && matrix.os != 'ubuntu-latest' }}
397-
id: should-skip
398-
shell: bash
399-
run: echo 'skip=true' >> $GITHUB_OUTPUT
400-
- uses: actions/checkout@v4
401-
if: steps.should-skip.outputs.skip != 'true'
402-
- uses: actions/setup-python@v5
403-
if: steps.should-skip.outputs.skip != 'true'
404-
with:
405-
python-version: '3.12'
406-
- uses: Swatinem/rust-cache@v2
407-
if: steps.should-skip.outputs.skip != 'true'
408-
with:
409-
save-if: ${{ github.event_name != 'merge_group' }}
410-
- uses: dtolnay/rust-toolchain@stable
411-
if: steps.should-skip.outputs.skip != 'true'
412-
with:
413-
components: llvm-tools-preview,rust-src
414-
- name: Install cargo-llvm-cov
415-
if: steps.should-skip.outputs.skip != 'true'
416-
uses: taiki-e/install-action@cargo-llvm-cov
417-
- run: python -m pip install --upgrade pip && pip install nox
418-
if: steps.should-skip.outputs.skip != 'true'
419-
- run: nox -s coverage
420-
if: steps.should-skip.outputs.skip != 'true'
421-
- uses: codecov/codecov-action@v4
422-
if: steps.should-skip.outputs.skip != 'true'
423-
with:
424-
file: coverage.json
425-
name: ${{ matrix.os }}
426-
token: ${{ secrets.CODECOV_TOKEN }}
427-
428388
emscripten:
429389
name: emscripten
430390
if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
@@ -673,7 +633,6 @@ jobs:
673633
- valgrind
674634
- careful
675635
- docsrs
676-
- coverage
677636
- emscripten
678637
- test-debug
679638
- test-free-threaded

.github/workflows/coverage.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request_target:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-coverage
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
coverage:
18+
name: coverage ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: ["windows-latest", "macos-14", "ubuntu-latest"] # first available arm macos runner
22+
runs-on: ${{ matrix.os }}
23+
steps:
24+
- if: ${{ github.event_name == 'pull_request' && matrix.os != 'ubuntu-latest' }}
25+
id: should-skip
26+
shell: bash
27+
run: echo 'skip=true' >> $GITHUB_OUTPUT
28+
- uses: actions/checkout@v4
29+
if: steps.should-skip.outputs.skip != 'true'
30+
- uses: actions/setup-python@v5
31+
if: steps.should-skip.outputs.skip != 'true'
32+
with:
33+
python-version: '3.12'
34+
- uses: Swatinem/rust-cache@v2
35+
if: steps.should-skip.outputs.skip != 'true'
36+
with:
37+
save-if: ${{ github.event_name != 'merge_group' }}
38+
- uses: dtolnay/rust-toolchain@stable
39+
if: steps.should-skip.outputs.skip != 'true'
40+
with:
41+
components: llvm-tools-preview,rust-src
42+
- name: Install cargo-llvm-cov
43+
if: steps.should-skip.outputs.skip != 'true'
44+
uses: taiki-e/install-action@cargo-llvm-cov
45+
- run: python -m pip install --upgrade pip && pip install nox
46+
if: steps.should-skip.outputs.skip != 'true'
47+
- run: nox -s coverage
48+
if: steps.should-skip.outputs.skip != 'true'
49+
- uses: codecov/codecov-action@v4
50+
if: steps.should-skip.outputs.skip != 'true'
51+
with:
52+
file: coverage.json
53+
name: ${{ matrix.os }}
54+
token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)