Cpython internal apis #16624
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| merge_group: | |
| types: [checks_requested] | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Check python formatting and lints (ruff) | |
| run: nox -s ruff | |
| - name: Check rust formatting (rustfmt) | |
| run: nox -s rustfmt | |
| - name: Check markdown formatting (rumdl) | |
| run: nox -s rumdl | |
| resolve: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| MSRV: ${{ steps.resolve-msrv.outputs.MSRV }} | |
| verbose: ${{ runner.debug == '1' }} | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: resolve MSRV | |
| id: resolve-msrv | |
| run: echo MSRV=`python -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["workspace"]["package"]["rust-version"])'` >> $GITHUB_OUTPUT | |
| semver-checks: | |
| if: github.event_name == 'pull_request' | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Fetch merge base | |
| id: fetch_merge_base | |
| uses: ./.github/actions/fetch-merge-base | |
| with: | |
| base_ref: "refs/heads/${{ github.event.pull_request.base.ref }}" | |
| head_ref: "refs/pull/${{ github.event.pull_request.number }}/merge" | |
| - uses: obi1kenobi/cargo-semver-checks-action@v2 | |
| with: | |
| baseline-rev: ${{ steps.fetch_merge_base.outputs.merge_base }} | |
| check-msrv: | |
| needs: [fmt, resolve] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ needs.resolve.outputs.MSRV }} | |
| components: rust-src | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| # This is a smoke test to confirm that CI will run on MSRV (including dev dependencies) | |
| - name: Check with MSRV package versions | |
| run: | | |
| nox -s set-msrv-package-versions | |
| nox -s check-all | |
| env: | |
| CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu | |
| clippy: | |
| needs: [fmt] | |
| runs-on: ubuntu-24.04-arm | |
| strategy: | |
| # If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present | |
| fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
| matrix: | |
| rust: [stable] | |
| target: | |
| [ | |
| "aarch64-apple-darwin", | |
| "x86_64-unknown-linux-gnu", | |
| "aarch64-unknown-linux-gnu", | |
| "powerpc64le-unknown-linux-gnu", | |
| "s390x-unknown-linux-gnu", | |
| "wasm32-wasip1", | |
| "x86_64-pc-windows-msvc", | |
| "i686-pc-windows-msvc", | |
| "aarch64-pc-windows-msvc", | |
| ] | |
| include: | |
| # Run beta clippy as a way to detect any incoming lints which may affect downstream users | |
| - rust: beta | |
| target: "x86_64-unknown-linux-gnu" | |
| name: clippy/${{ matrix.target }}/${{ matrix.rust }} | |
| continue-on-error: ${{ matrix.rust != 'stable' }} | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| targets: ${{ matrix.target }} | |
| components: clippy,rust-src | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| save-cache: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - run: uvx nox -s clippy-all | |
| env: | |
| CARGO_BUILD_TARGET: ${{ matrix.target }} | |
| build-pr: | |
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-build-full') && github.event_name == 'pull_request' }} | |
| name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }} | |
| needs: [fmt, resolve] | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| os: ${{ matrix.platform.os }} | |
| python-version: ${{ matrix.python-version }} | |
| python-architecture: ${{ matrix.platform.python-architecture }} | |
| rust: ${{ matrix.rust }} | |
| rust-target: ${{ matrix.platform.rust-target }} | |
| MSRV: ${{ needs.resolve.outputs.MSRV }} | |
| verbose: ${{ needs.resolve.outputs.verbose == 'true' }} | |
| secrets: inherit | |
| strategy: | |
| # If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present | |
| fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
| matrix: | |
| rust: [stable] | |
| python-version: ["3.14"] | |
| platform: | |
| [ | |
| { | |
| os: "macos-latest", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-apple-darwin", | |
| }, | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| }, | |
| { | |
| os: "ubuntu-24.04-arm", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-unknown-linux-gnu", | |
| }, | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-pc-windows-msvc", | |
| }, | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x86", | |
| rust-target: "i686-pc-windows-msvc", | |
| }, | |
| { | |
| os: "windows-11-arm", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-pc-windows-msvc", | |
| }, | |
| ] | |
| include: | |
| # Test nightly Rust on PRs so that PR authors have a chance to fix nightly | |
| # failures, as nightly does not block merge. | |
| - rust: nightly | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| } | |
| # Also test free-threaded Python just for latest Python version, on ubuntu | |
| # (run for all OSes on build-full) | |
| - rust: stable | |
| python-version: "3.14t" | |
| platform: | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| } | |
| build-full: | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }} | |
| needs: [fmt, resolve] | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| os: ${{ matrix.platform.os }} | |
| python-version: ${{ matrix.python-version }} | |
| python-architecture: ${{ matrix.platform.python-architecture }} | |
| rust: ${{ matrix.rust }} | |
| rust-target: ${{ matrix.platform.rust-target }} | |
| MSRV: ${{ needs.resolve.outputs.MSRV }} | |
| verbose: ${{ needs.resolve.outputs.verbose == 'true' }} | |
| secrets: inherit | |
| strategy: | |
| # If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present | |
| fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
| matrix: | |
| rust: [stable] | |
| python-version: | |
| [ | |
| "3.8", | |
| "3.9", | |
| "3.10", | |
| "3.11", | |
| "3.12", | |
| "3.13", | |
| "3.14", | |
| "3.14t", | |
| "3.15-dev", | |
| "3.15t-dev", | |
| "pypy3.11", | |
| "graalpy25.0", | |
| ] | |
| platform: | |
| [ | |
| { | |
| os: "macos-latest", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-apple-darwin", | |
| }, | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| }, | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-pc-windows-msvc", | |
| }, | |
| ] | |
| include: | |
| # Test minimal supported Rust version | |
| - rust: ${{ needs.resolve.outputs.MSRV }} | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| } | |
| # Test the `nightly` feature | |
| - rust: nightly | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| } | |
| # Run rust beta to help catch toolchain regressions | |
| - rust: beta | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| } | |
| # Test 32-bit Windows and x64 macOS only with the latest Python version | |
| - rust: stable | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x86", | |
| rust-target: "i686-pc-windows-msvc", | |
| } | |
| - rust: stable | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "macos-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-apple-darwin", | |
| } | |
| # arm64 macOS Python not available on GitHub Actions until 3.10, test older versions on x64 | |
| - rust: stable | |
| python-version: "3.8" | |
| platform: | |
| { | |
| os: "macos-15-intel", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-apple-darwin", | |
| } | |
| - rust: stable | |
| python-version: "3.9" | |
| platform: | |
| { | |
| os: "macos-15-intel", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-apple-darwin", | |
| } | |
| # test latest Python on arm64 linux & windows runners | |
| - rust: stable | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "ubuntu-24.04-arm", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-unknown-linux-gnu", | |
| } | |
| - rust: stable | |
| python-version: "3.14" | |
| platform: | |
| { | |
| os: "windows-11-arm", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-pc-windows-msvc", | |
| } | |
| exclude: | |
| # arm64 macOS Python not available on GitHub Actions until 3.10 | |
| - rust: stable | |
| python-version: "3.8" | |
| platform: | |
| { | |
| os: "macos-latest", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-apple-darwin", | |
| } | |
| - rust: stable | |
| python-version: "3.9" | |
| platform: | |
| { | |
| os: "macos-latest", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-apple-darwin", | |
| } | |
| valgrind: | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: taiki-e/install-action@valgrind | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - run: nox -s test-rust -- release skip-full | |
| env: | |
| CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1 | |
| RUST_BACKTRACE: 1 | |
| TRYBUILD: overwrite | |
| careful: | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rust-src | |
| - uses: taiki-e/install-action@cargo-careful | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - run: nox -s test-rust -- careful skip-full | |
| env: | |
| RUST_BACKTRACE: 1 | |
| TRYBUILD: overwrite | |
| docsrs: | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rust-src | |
| - run: cargo rustdoc --lib --no-default-features --features full,jiff-02 -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]" | |
| emscripten: | |
| name: emscripten | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.14 | |
| id: setup-python | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-emscripten | |
| components: rust-src | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - uses: actions/cache/restore@v5 | |
| id: cache | |
| with: | |
| path: | | |
| .nox/emscripten | |
| key: emscripten-${{ hashFiles('emscripten/*') }}-${{ hashFiles('noxfile.py') }}-${{ steps.setup-python.outputs.python-path }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - name: Build | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: nox -s build-emscripten | |
| - name: Test | |
| run: nox -s test-emscripten | |
| - uses: actions/cache/save@v5 | |
| if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| with: | |
| path: | | |
| .nox/emscripten | |
| key: emscripten-${{ hashFiles('emscripten/*') }}-${{ hashFiles('noxfile.py') }}-${{ steps.setup-python.outputs.python-path }} | |
| wasm32-wasip1: | |
| name: wasm32-wasip1 | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| env: | |
| WASI_SDK_PATH: "/opt/wasi-sdk" | |
| CPYTHON_PATH: "${{ github.workspace }}/wasi/cpython" | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.14 | |
| id: setup-python | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-wasip1 | |
| components: rust-src | |
| - name: "Install wasmtime" | |
| uses: bytecodealliance/actions/wasmtime/setup@v1 | |
| - name: "Install WASI SDK" | |
| run: | | |
| mkdir ${{ env.WASI_SDK_PATH }} && \ | |
| curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz | \ | |
| tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip | |
| $WASI_SDK_PATH/bin/clang --version | |
| - uses: actions/cache/restore@v5 | |
| id: cache-wasip1-python | |
| with: | |
| path: ${{ env.CPYTHON_PATH }}/cross-build/ | |
| key: wasm32-wasip1-python | |
| - uses: actions/[email protected] | |
| with: | |
| repository: python/cpython | |
| ref: 3.14 | |
| path: ${{ env.CPYTHON_PATH }} | |
| fetch-depth: 1 | |
| - name: Build | |
| run: | | |
| cd ${{ env.CPYTHON_PATH }} | |
| cat >> Tools/wasm/wasi/config.site-wasm32-wasi <<'EOF' | |
| # Force-disable POSIX dynamic loading for WASI | |
| ac_cv_func_dlopen=no | |
| ac_cv_lib_dl_dlopen=no | |
| EOF | |
| python Tools/wasm/wasi build --quiet -- --config-cache | |
| cp cross-build/wasm32-wasip1/libpython3.14.a \ | |
| cross-build/wasm32-wasip1/Modules/_hacl/libHacl_HMAC.a \ | |
| cross-build/wasm32-wasip1/Modules/_decimal/libmpdec/libmpdec.a \ | |
| cross-build/wasm32-wasip1/Modules/expat/libexpat.a \ | |
| cross-build/wasm32-wasip1/build/lib.wasi-wasm32-3.14/ | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - name: Test | |
| env: | |
| PYO3_CROSS_LIB_DIR: ${{ env.CPYTHON_PATH }}/cross-build/wasm32-wasip1/build/lib.wasi-wasm32-3.14/ | |
| CARGO_BUILD_TARGET: wasm32-wasip1 | |
| CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run --dir ${{ env.CPYTHON_PATH }}::/ --env PYTHONPATH=/lib | |
| RUSTFLAGS: > | |
| -C link-arg=-L${{ env.WASI_SDK_PATH }}/share/wasi-sysroot/lib/wasm32-wasi | |
| -C link-arg=-lwasi-emulated-signal | |
| -C link-arg=-lwasi-emulated-process-clocks | |
| -C link-arg=-lwasi-emulated-getpid | |
| -C link-arg=-lmpdec | |
| -C link-arg=-lHacl_HMAC | |
| -C link-arg=-lexpat | |
| run: RUSTDOCFLAGS=$RUSTFLAGS cargo test | |
| - uses: actions/cache/save@v5 | |
| if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| with: | |
| path: ${{ env.CPYTHON_PATH }}/cross-build/ | |
| key: ${{ steps.cache-wasip1-python.outputs.cache-primary-key }} | |
| test-debug: | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rust-src | |
| - name: Install python3 standalone debug build with nox | |
| run: | | |
| PBS_RELEASE="20241219" | |
| PBS_PYTHON_VERSION="3.13.1" | |
| PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst" | |
| wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}" | |
| tar -I zstd -xf "${PBS_ARCHIVE}" | |
| ls -l $(pwd)/python/install/bin | |
| ls -l $(pwd)/python/install/lib | |
| echo PATH=$(pwd)/python/install/bin:$PATH >> $GITHUB_ENV | |
| echo LD_LIBRARY_PATH=$(pwd)/python/install/lib:$LD_LIBRARY_PATH >> $GITHUB_ENV | |
| echo PYTHONHOME=$(pwd)/python/install >> $GITHUB_ENV | |
| echo PYO3_PYTHON=$(pwd)/python/install/bin/python3 >> $GITHUB_ENV | |
| - run: python3 -m sysconfig | |
| - run: python3 -m pip install --upgrade pip && pip install nox[uv] | |
| - run: | | |
| PYO3_CONFIG_FILE=$(mktemp) | |
| cat > $PYO3_CONFIG_FILE << EOF | |
| implementation=CPython | |
| version=3.13 | |
| shared=true | |
| abi3=false | |
| lib_name=python3.13d | |
| lib_dir=${{ github.workspace }}/python/install/lib | |
| executable=${{ github.workspace }}/python/install/bin/python3 | |
| pointer_width=64 | |
| build_flags=Py_DEBUG,Py_REF_DEBUG | |
| suppress_build_script_link_lines=false | |
| EOF | |
| echo PYO3_CONFIG_FILE=$PYO3_CONFIG_FILE >> $GITHUB_ENV | |
| - run: python3 -m nox -s test | |
| test-version-limits: | |
| needs: [fmt] | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@stable | |
| - run: python3 -m pip install --upgrade pip && pip install nox[uv] | |
| - run: python3 -m nox -s test-version-limits | |
| check-feature-powerset: | |
| needs: [fmt, resolve] | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| name: check-feature-powerset ${{ matrix.rust }} | |
| strategy: | |
| # run on stable and MSRV to check that all combinations of features are expected to build fine on our supported | |
| # range of compilers | |
| matrix: | |
| rust: ["stable"] | |
| include: | |
| - rust: ${{ needs.resolve.outputs.MSRV }} | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack,cargo-minimal-versions | |
| - run: python3 -m pip install --upgrade pip && pip install nox[uv] | |
| - run: python3 -m nox -s check-feature-powerset -- ${{ matrix.rust != 'stable' && 'minimal-versions' || '' }} | |
| test-cross-compilation: | |
| needs: [fmt] | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| runs-on: ${{ matrix.os }} | |
| name: test-cross-compilation ${{ matrix.os }} -> ${{ matrix.target }} | |
| strategy: | |
| # If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present | |
| fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
| matrix: | |
| include: | |
| # ubuntu "cross compile" to itself | |
| - os: "ubuntu-latest" | |
| target: "x86_64-unknown-linux-gnu" | |
| flags: "-i python3.13" | |
| manylinux: auto | |
| # ubuntu x86_64 -> aarch64 | |
| - os: "ubuntu-latest" | |
| target: "aarch64-unknown-linux-gnu" | |
| flags: "-i python3.13" | |
| manylinux: auto | |
| # ubuntu x86_64 -> windows x86_64 | |
| - os: "ubuntu-latest" | |
| target: "x86_64-pc-windows-gnu" | |
| # TODO: remove pyo3/generate-import-lib feature when maturin supports cross compiling to Windows without it | |
| flags: "-i python3.13 --features pyo3/generate-import-lib" | |
| # windows x86_64 -> aarch64 | |
| - os: "windows-latest" | |
| target: "aarch64-pc-windows-msvc" | |
| flags: "-i python3.13 --features pyo3/generate-import-lib" | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: examples/maturin-starter | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| key: ${{ matrix.target }} | |
| - name: Setup cross-compiler | |
| if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }} | |
| run: sudo apt-get install -y mingw-w64 llvm | |
| - name: Compile version-specific library | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| manylinux: ${{ matrix.manylinux }} | |
| args: --release -m examples/maturin-starter/Cargo.toml ${{ matrix.flags }} | |
| - name: Compile abi3 library | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| manylinux: ${{ matrix.manylinux }} | |
| args: --release -m examples/maturin-starter/Cargo.toml --features abi3 ${{ matrix.flags }} | |
| test-cross-compilation-windows: | |
| needs: [fmt] | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: x86_64-pc-windows-gnu,x86_64-pc-windows-msvc | |
| components: rust-src | |
| # load cache (prepared in ci-cache-warmup.yml) | |
| - uses: actions/cache/restore@v5 | |
| with: | |
| path: ~/.cache/cargo-xwin | |
| key: cargo-xwin-cache | |
| - name: Test cross compile to Windows | |
| run: | | |
| set -ex | |
| sudo apt-get install -y mingw-w64 llvm | |
| pip install nox | |
| nox -s test-cross-compilation-windows | |
| test-introspection: | |
| needs: [fmt] | |
| if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-test-introspection') || contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} | |
| strategy: | |
| matrix: | |
| platform: | |
| [ | |
| { | |
| os: "macos-latest", | |
| python-architecture: "arm64", | |
| rust-target: "aarch64-apple-darwin", | |
| }, | |
| { | |
| os: "ubuntu-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-unknown-linux-gnu", | |
| }, | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x64", | |
| rust-target: "x86_64-pc-windows-msvc", | |
| }, | |
| { | |
| os: "windows-latest", | |
| python-architecture: "x86", | |
| rust-target: "i686-pc-windows-msvc", | |
| }, | |
| ] | |
| runs-on: ${{ matrix.platform.os }} | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.platform.rust-target }} | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| architecture: ${{ matrix.platform.python-architecture }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }} | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - run: nox -s test-introspection | |
| env: | |
| CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }} | |
| test-introspection-pr: | |
| needs: [fmt] | |
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-build-full') && github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - run: nox -s test-introspection | |
| pytests-type-checking: | |
| needs: [fmt] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| # If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present | |
| fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} | |
| matrix: | |
| checker: [mypy, pyrefly] | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rust-src | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - run: python -m pip install --upgrade pip && pip install nox[uv] | |
| - run: nox -s ${{matrix.checker}} | |
| working-directory: pytests | |
| conclusion: | |
| needs: | |
| - fmt | |
| - check-msrv | |
| - clippy | |
| - build-pr | |
| - build-full | |
| - valgrind | |
| - careful | |
| - docsrs | |
| - emscripten | |
| - test-debug | |
| - test-version-limits | |
| - check-feature-powerset | |
| - test-cross-compilation | |
| - test-cross-compilation-windows | |
| - test-introspection | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Result | |
| run: | | |
| jq -C <<< "${needs}" | |
| # Check if all needs were successful or skipped. | |
| "$(jq -r 'all(.result as $result | (["success", "skipped"] | contains([$result])))' <<< "${needs}")" | |
| env: | |
| needs: ${{ toJson(needs) }} |