@@ -12,6 +12,8 @@ concurrency:
1212
1313env :
1414 CARGO_TERM_COLOR : always
15+ NOX_DEFAULT_VENV_BACKEND : uv
16+ UV_PYTHON : 3.14
1517
1618jobs :
1719 fmt :
3941 outputs :
4042 MSRV : ${{ steps.resolve-msrv.outputs.MSRV }}
4143 verbose : ${{ runner.debug == '1' }}
44+ save-cache : ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
45+ # For PRs, we need to run on the real PR head, not the resultant merge of the PR into the target branch.
46+ #
47+ # This is necessary for coverage reporting to make sense; we then get exactly the coverage change
48+ # between the base branch and the real PR head.
49+ #
50+ # If it were run on the merge commit the problem is that the coverage potentially does not align
51+ # with the commit diff, because the merge may affect line numbers.
52+ coverage-sha : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
4253 steps :
4354 - uses : actions/checkout@v6.0.2
4455 - uses : actions/setup-python@v6
@@ -138,6 +149,7 @@ jobs:
138149 needs : [fmt, resolve]
139150 uses : ./.github/workflows/build.yml
140151 with :
152+ sha : ${{ needs.resolve.outputs.coverage-sha }}
141153 os : ${{ matrix.platform.os }}
142154 python-version : ${{ matrix.python-version }}
143155 python-architecture : ${{ matrix.platform.python-architecture }}
@@ -231,6 +243,7 @@ jobs:
231243 needs : [fmt, resolve]
232244 uses : ./.github/workflows/build.yml
233245 with :
246+ sha : ${{ needs.resolve.outputs.coverage-sha }}
234247 os : ${{ matrix.platform.os }}
235248 python-version : ${{ matrix.python-version }}
236249 python-architecture : ${{ matrix.platform.python-architecture }}
@@ -617,20 +630,26 @@ jobs:
617630 - run : python3 -m nox -s test
618631
619632 test-version-limits :
620- needs : [fmt]
633+ needs : [fmt, resolve ]
621634 if : ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
622635 runs-on : ubuntu-latest
623636 steps :
624637 - uses : actions/checkout@v6.0.2
625- - uses : actions/setup-python@v6
626638 with :
627- python-version : " 3.14 "
628- - uses : Swatinem/rust-cache@v2
639+ ref : ${{ needs.resolve.outputs.coverage-sha }}
640+ - uses : astral-sh/setup-uv@v7
629641 with :
630- save-if : ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI- save-pr- cache') }}
642+ save-cache : ${{ needs.resolve.outputs. save-cache }}
631643 - uses : dtolnay/rust-toolchain@stable
632- - run : python3 -m pip install --upgrade pip && pip install nox[uv]
633- - run : python3 -m nox -s test-version-limits
644+ - uses : Swatinem/rust-cache@v2
645+ with :
646+ save-if : ${{ needs.resolve.outputs.save-cache }}
647+ - uses : ./.github/actions/prepare-coverage
648+ - run : uvx nox -s test-version-limits
649+ - uses : ./.github/actions/report-coverage
650+ with :
651+ name : ${{ github.job }}
652+ token : ${{ secrets.CODECOV_TOKEN }}
634653
635654 check-feature-powerset :
636655 needs : [fmt, resolve]
@@ -662,7 +681,7 @@ jobs:
662681 - run : python3 -m nox -s check-feature-powerset -- ${{ matrix.rust != 'stable' && 'minimal-versions' || '' }}
663682
664683 test-cross-compilation :
665- needs : [fmt]
684+ needs : [fmt, resolve ]
666685 if : ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
667686 runs-on : ${{ matrix.os }}
668687 name : test-cross-compilation ${{ matrix.os }} -> ${{ matrix.target }}
@@ -686,45 +705,72 @@ jobs:
686705 target : " x86_64-pc-windows-gnu"
687706 # TODO: remove pyo3/generate-import-lib feature when maturin supports cross compiling to Windows without it
688707 flags : " -i python3.13 --features pyo3/generate-import-lib"
708+ apt-packages : mingw-w64 llvm
689709 # windows x86_64 -> aarch64
690710 - os : " windows-latest"
691711 target : " aarch64-pc-windows-msvc"
692712 flags : " -i python3.13 --features pyo3/generate-import-lib"
693713 steps :
694714 - uses : actions/checkout@v6.0.2
715+ with :
716+ ref : ${{ needs.resolve.outputs.coverage-sha }}
717+ - uses : astral-sh/setup-uv@v7
718+ with :
719+ save-cache : ${{ needs.resolve.outputs.save-cache }}
695720 - uses : actions/setup-python@v6
696721 with :
697- python-version : " 3.14 "
722+ python-version : ${{ env.UV_PYTHON }}
698723 - uses : Swatinem/rust-cache@v2
699724 with :
700725 workspaces : examples/maturin-starter
701726 save-if : ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
702727 key : ${{ matrix.target }}
703- - name : Setup cross-compiler
704- if : ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
705- run : sudo apt-get install -y mingw-w64 llvm
728+ - name : Setup cross-compiler packages
729+ if : ${{ matrix.apt-packages }}
730+ run : sudo apt-get install -y ${{ matrix.apt-packages }}
731+ - uses : ./.github/actions/prepare-coverage
732+ with :
733+ host_only : true
706734 - name : Compile version-specific library
707735 uses : PyO3/maturin-action@v1
708736 with :
709737 target : ${{ matrix.target }}
738+ args : --profile=dev -m examples/maturin-starter/Cargo.toml ${{ matrix.flags }}
710739 manylinux : ${{ matrix.manylinux }}
711- args : --release -m examples/maturin-starter/Cargo.toml ${{ matrix.flags }}
740+ docker-options : >-
741+ -e LLVM_PROFILE_FILE
742+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER
743+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER_RUSTFLAGS
744+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER_CRATE_NAMES
745+ -v /home/runner/.cargo/bin/cargo-llvm-cov:/home/runner/.cargo/bin/cargo-llvm-cov
712746 - name : Compile abi3 library
713747 uses : PyO3/maturin-action@v1
714748 with :
715749 target : ${{ matrix.target }}
750+ args : --profile=dev -m examples/maturin-starter/Cargo.toml --features abi3 ${{ matrix.flags }}
716751 manylinux : ${{ matrix.manylinux }}
717- args : --release -m examples/maturin-starter/Cargo.toml --features abi3 ${{ matrix.flags }}
752+ docker-options : >-
753+ -e LLVM_PROFILE_FILE
754+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER
755+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER_RUSTFLAGS
756+ -e __CARGO_LLVM_COV_RUSTC_WRAPPER_CRATE_NAMES
757+ -v /home/runner/.cargo/bin/cargo-llvm-cov:/home/runner/.cargo/bin/cargo-llvm-cov
758+ - uses : ./.github/actions/report-coverage
759+ with :
760+ name : ${{ github.job }}/${{ matrix.os }}/${{ matrix.target }}
761+ token : ${{ secrets.CODECOV_TOKEN }}
718762
719763 test-cross-compilation-windows :
720- needs : [fmt]
764+ needs : [fmt, resolve ]
721765 if : ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
722766 runs-on : ubuntu-latest
723767 steps :
724768 - uses : actions/checkout@v6.0.2
725- - uses : actions/setup-python@v6
726769 with :
727- python-version : " 3.14"
770+ ref : ${{ needs.resolve.outputs.coverage-sha }}
771+ - uses : astral-sh/setup-uv@v7
772+ with :
773+ save-cache : ${{ needs.resolve.outputs.save-cache }}
728774 - uses : dtolnay/rust-toolchain@stable
729775 with :
730776 targets : x86_64-pc-windows-gnu,x86_64-pc-windows-msvc
@@ -734,12 +780,17 @@ jobs:
734780 with :
735781 path : ~/.cache/cargo-xwin
736782 key : cargo-xwin-cache
783+ - name : Setup cross-compiler
784+ run : sudo apt-get install -y mingw-w64 llvm
785+ - uses : ./.github/actions/prepare-coverage
786+ with :
787+ host_only : true
737788 - name : Test cross compile to Windows
738- run : |
739- set -ex
740- sudo apt-get install -y mingw-w64 llvm
741- pip install nox
742- nox -s test-cross-compilation-windows
789+ run : uvx nox -s test-cross-compilation-windows
790+ - uses : ./.github/actions/report-coverage
791+ with :
792+ name : ${{ github.job }}
793+ token : ${{ secrets.CODECOV_TOKEN }}
743794
744795 test-introspection :
745796 needs : [fmt]
0 commit comments