File tree Expand file tree Collapse file tree 3 files changed +66
-4
lines changed Expand file tree Collapse file tree 3 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -451,10 +451,6 @@ jobs:
451
451
runs-on : ${{ matrix.os }}
452
452
steps :
453
453
- uses : actions/checkout@v4
454
- with :
455
- # Use the PR head, not the merge commit, because the head commit (and the base)
456
- # is what codecov uses to calculate diffs.
457
- ref : ${{ github.event.pull_request.head.sha }}
458
454
- uses : actions/setup-python@v5
459
455
with :
460
456
python-version : ' 3.12'
@@ -572,10 +568,24 @@ jobs:
572
568
with :
573
569
python-version : ' 3.13-dev'
574
570
nogil : true
571
+ - name : Install cargo-llvm-cov
572
+ uses : taiki-e/install-action@cargo-llvm-cov
575
573
- run : python3 -m sysconfig
576
574
- run : python3 -m pip install --upgrade pip && pip install nox
575
+ - name : Prepare coverage environment
576
+ run : |
577
+ cargo llvm-cov clean --workspace --profraw-only
578
+ nox -s set-coverage-env
577
579
- run : nox -s ffi-check
578
580
- run : nox
581
+ - name : Generate coverage report
582
+ run : nox -s generate-coverage-report
583
+ - name : Upload coverage report
584
+ uses : codecov/codecov-action@v4
585
+ with :
586
+ file : coverage.json
587
+ name : test-free-threaded
588
+ token : ${{ secrets.CODECOV_TOKEN }}
579
589
580
590
test-version-limits :
581
591
needs : [fmt]
Original file line number Diff line number Diff line change
1
+ # This runs as a separate job because it needs to run on the `pull_request_target` event
2
+ # in order to access the CODECOV_TOKEN secret.
3
+ #
4
+ # This is safe because this doesn't run arbitrary code from PRs.
5
+
6
+ name : Set Codecov PR base
7
+ on :
8
+ # See safety note / doc at the top of this file.
9
+ pull_request_target :
10
+
11
+ jobs :
12
+ coverage-pr-base :
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - uses : actions/checkout@v4
16
+ - uses : actions/setup-python@v5
17
+ with :
18
+ python-version : ' 3.12'
19
+ - name : Set PR base on codecov
20
+ run : |
21
+ # fetch the merge commit between the PR base and head
22
+ BASE_REF=refs/heads/${{ github.event.pull_request.base.ref }}
23
+ MERGE_REF=refs/pull/${{ github.event.pull_request.number }}/merge
24
+
25
+ git fetch --progress --depth=1 origin "+$BASE_REF:$BASE_REF" "+$MERGE_REF:$MERGE_REF"
26
+ while [ -z "$(git merge-base "$BASE_REF" "$MERGE_REF")" ]; do
27
+ git fetch -q --deepen="10" origin "$BASE_REF" "$MERGE_REF";
28
+ done
29
+
30
+ MERGE_BASE=$(git merge-base "$BASE_REF" "$MERGE_REF")
31
+ echo "Merge base: $MERGE_BASE"
32
+
33
+ # inform codecov about the merge base
34
+ pip install codecov-cli
35
+ codecovcli pr-base-picking \
36
+ --base-sha $MERGE_BASE \
37
+ --pr ${{ github.event.number }} \
38
+ --slug PyO3/pyo3 \
39
+ --token ${{ secrets.CODECOV_TOKEN }} \
40
+ --service github
Original file line number Diff line number Diff line change @@ -72,7 +72,19 @@ def coverage(session: nox.Session) -> None:
72
72
session .env .update (_get_coverage_env ())
73
73
_run_cargo (session , "llvm-cov" , "clean" , "--workspace" )
74
74
test (session )
75
+ generate_coverage_report (session )
75
76
77
+
78
+ @nox .session (name = "set-coverage-env" , venv_backend = "none" )
79
+ def set_coverage_env (session : nox .Session ) -> None :
80
+ """For use in GitHub Actions to set coverage environment variables."""
81
+ with open (os .environ ["GITHUB_ENV" ], "a" ) as env_file :
82
+ for k , v in _get_coverage_env ().items ():
83
+ print (f"{ k } ={ v } " , file = env_file )
84
+
85
+
86
+ @nox .session (name = "generate-coverage-report" , venv_backend = "none" )
87
+ def generate_coverage_report (session : nox .Session ) -> None :
76
88
cov_format = "codecov"
77
89
output_file = "coverage.json"
78
90
You can’t perform that action at this time.
0 commit comments