From ec0c70f9d06b0f0af1919156b8074f3dff5fa50c Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 13:20:44 +0100 Subject: [PATCH 01/11] add full-only prop to matrix reduce CI utilization in PRs --- .github/workflows/build-test.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 78e7e8c..00b67fc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,21 +27,28 @@ jobs: name: Rust tests - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only strategy: matrix: platform: - name: Linux x86_64 runner: ubuntu-24.04 + full-only: false - name: Linux ARM64 runner: ubuntu-24.04-arm + full-only: true - name: Windows x64 runner: windows-latest + full-only: true - name: Windows ARM64 runner: windows-11-arm + full-only: true - name: macOS x86_64 runner: macos-15-intel + full-only: true - name: macOS ARM64 runner: macos-15 + full-only: true steps: - uses: actions/checkout@v6 - name: Cache Rust build @@ -92,6 +99,7 @@ jobs: name: Build Wheels - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only strategy: matrix: platform: @@ -101,6 +109,7 @@ jobs: before-script: python3 -m ensurepip && cat /etc/os-release && yum install clang -y manylinux: "2_28" is-musl: false + full-only: false - name: linux-aarch64 runner: ubuntu-24.04 @@ -111,6 +120,7 @@ jobs: apt-get install --assume-yes --no-install-recommends crossbuild-essential-arm64 manylinux: "2_28" is-musl: false + full-only: true - name: linux-musl-x86_64 runner: ubuntu-24.04 @@ -119,26 +129,31 @@ jobs: before-script: cat /etc/os-release && apt install clang -y manylinux: musllinux_1_2 is-musl: true + full-only: true - name: windows-x64 runner: windows-latest target: x86_64-pc-windows-msvc is-musl: false + full-only: true - name: windows-arm64 runner: windows-11-arm target: aarch64-pc-windows-msvc is-musl: false + full-only: true - name: macos-x86_64 runner: macos-15-intel target: x86_64-apple-darwin is-musl: false + full-only: true - name: macos-arm64 runner: macos-15 target: aarch64-apple-darwin is-musl: false + full-only: true steps: - uses: actions/checkout@v6 - name: Cache Rust build @@ -186,6 +201,7 @@ jobs: needs: build name: Test - ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner }} + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.config.full-only strategy: fail-fast: false matrix: @@ -196,36 +212,42 @@ jobs: platform-name: linux-x86_64 python-version: "3.12" is-min-deps: false + full-only: false - name: Linux ARM64 runner: ubuntu-24.04-arm platform-name: linux-aarch64 python-version: "3.12" is-min-deps: false + full-only: true - name: Windows runner: windows-latest platform-name: windows-x64 python-version: "3.12" is-min-deps: false + full-only: true - name: Windows ARM64 runner: windows-11-arm platform-name: windows-arm64 python-version: "3.12" is-min-deps: false + full-only: true - name: macOS x86_64 runner: macos-15-intel platform-name: macos-x86_64 python-version: "3.12" is-min-deps: false + full-only: true - name: macOS ARM64 runner: macos-15 platform-name: macos-arm64 python-version: "3.12" is-min-deps: false + full-only: true # Additional Python versions for Linux x86_64 - name: Python 3.10 @@ -233,24 +255,28 @@ jobs: platform-name: linux-x86_64 python-version: "3.10" is-min-deps: false + full-only: true - name: Python 3.11 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.11" is-min-deps: false + full-only: true - name: Python 3.13 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.13" is-min-deps: false + full-only: true - name: Python 3.14 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.14" is-min-deps: false + full-only: true # - name: Python 3.15 # runner: ubuntu-24.04 @@ -264,6 +290,7 @@ jobs: platform-name: linux-x86_64 python-version: "3.10" is-min-deps: true + full-only: true steps: # Use the test composite action - uses: actions/checkout@v6 @@ -308,6 +335,7 @@ jobs: needs: build name: Test - Linux Musl runs-on: ubuntu-24.04 + if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci') container: ghcr.io/astral-sh/uv:0.9.11-alpine steps: - uses: actions/checkout@v6 From d6c20c734e782834c89e76068997e8b7a15445ef Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 13:24:04 +0100 Subject: [PATCH 02/11] fix matrix platform check --- .github/workflows/build-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 00b67fc..f5f8c08 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,7 +27,7 @@ jobs: name: Rust tests - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.platform.full-only }} strategy: matrix: platform: @@ -99,7 +99,7 @@ jobs: name: Build Wheels - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.platform.full-only }} strategy: matrix: platform: @@ -201,7 +201,7 @@ jobs: needs: build name: Test - ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.config.full-only + if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.config.full-only }} strategy: fail-fast: false matrix: From 33f480737e3ff874a16efe9cbe76fd420309505a Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 13:33:45 +0100 Subject: [PATCH 03/11] maybe this way --- .github/workflows/build-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f5f8c08..c6ee67e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,7 +27,7 @@ jobs: name: Rust tests - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.platform.full-only }} + if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only }} strategy: matrix: platform: @@ -99,7 +99,7 @@ jobs: name: Build Wheels - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.platform.full-only }} + if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only }} strategy: matrix: platform: @@ -201,7 +201,7 @@ jobs: needs: build name: Test - ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner }} - if: (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !${{ matrix.config.full-only }} + if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.config.full-only }} strategy: fail-fast: false matrix: From d4002f3670540d3ac878da6a49c06a22906f3978 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 13:38:32 +0100 Subject: [PATCH 04/11] separate workflow for PR --- .github/workflows/build-test.yml | 29 -------- .github/workflows/ci-pr.yml | 117 +++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/ci-pr.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c6ee67e..8f7fe0b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -6,7 +6,6 @@ on: - main tags: - "*" - pull_request: workflow_dispatch: permissions: @@ -27,28 +26,21 @@ jobs: name: Rust tests - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only }} strategy: matrix: platform: - name: Linux x86_64 runner: ubuntu-24.04 - full-only: false - name: Linux ARM64 runner: ubuntu-24.04-arm - full-only: true - name: Windows x64 runner: windows-latest - full-only: true - name: Windows ARM64 runner: windows-11-arm - full-only: true - name: macOS x86_64 runner: macos-15-intel - full-only: true - name: macOS ARM64 runner: macos-15 - full-only: true steps: - uses: actions/checkout@v6 - name: Cache Rust build @@ -99,7 +91,6 @@ jobs: name: Build Wheels - ${{ matrix.platform.name }} runs-on: ${{ matrix.platform.runner }} container: ${{ matrix.platform.container }} - if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.platform.full-only }} strategy: matrix: platform: @@ -109,7 +100,6 @@ jobs: before-script: python3 -m ensurepip && cat /etc/os-release && yum install clang -y manylinux: "2_28" is-musl: false - full-only: false - name: linux-aarch64 runner: ubuntu-24.04 @@ -120,7 +110,6 @@ jobs: apt-get install --assume-yes --no-install-recommends crossbuild-essential-arm64 manylinux: "2_28" is-musl: false - full-only: true - name: linux-musl-x86_64 runner: ubuntu-24.04 @@ -129,31 +118,26 @@ jobs: before-script: cat /etc/os-release && apt install clang -y manylinux: musllinux_1_2 is-musl: true - full-only: true - name: windows-x64 runner: windows-latest target: x86_64-pc-windows-msvc is-musl: false - full-only: true - name: windows-arm64 runner: windows-11-arm target: aarch64-pc-windows-msvc is-musl: false - full-only: true - name: macos-x86_64 runner: macos-15-intel target: x86_64-apple-darwin is-musl: false - full-only: true - name: macos-arm64 runner: macos-15 target: aarch64-apple-darwin is-musl: false - full-only: true steps: - uses: actions/checkout@v6 - name: Cache Rust build @@ -201,7 +185,6 @@ jobs: needs: build name: Test - ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner }} - if: ${{ (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci')) || !matrix.config.full-only }} strategy: fail-fast: false matrix: @@ -212,42 +195,36 @@ jobs: platform-name: linux-x86_64 python-version: "3.12" is-min-deps: false - full-only: false - name: Linux ARM64 runner: ubuntu-24.04-arm platform-name: linux-aarch64 python-version: "3.12" is-min-deps: false - full-only: true - name: Windows runner: windows-latest platform-name: windows-x64 python-version: "3.12" is-min-deps: false - full-only: true - name: Windows ARM64 runner: windows-11-arm platform-name: windows-arm64 python-version: "3.12" is-min-deps: false - full-only: true - name: macOS x86_64 runner: macos-15-intel platform-name: macos-x86_64 python-version: "3.12" is-min-deps: false - full-only: true - name: macOS ARM64 runner: macos-15 platform-name: macos-arm64 python-version: "3.12" is-min-deps: false - full-only: true # Additional Python versions for Linux x86_64 - name: Python 3.10 @@ -255,28 +232,24 @@ jobs: platform-name: linux-x86_64 python-version: "3.10" is-min-deps: false - full-only: true - name: Python 3.11 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.11" is-min-deps: false - full-only: true - name: Python 3.13 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.13" is-min-deps: false - full-only: true - name: Python 3.14 runner: ubuntu-24.04 platform-name: linux-x86_64 python-version: "3.14" is-min-deps: false - full-only: true # - name: Python 3.15 # runner: ubuntu-24.04 @@ -290,7 +263,6 @@ jobs: platform-name: linux-x86_64 python-version: "3.10" is-min-deps: true - full-only: true steps: # Use the test composite action - uses: actions/checkout@v6 @@ -335,7 +307,6 @@ jobs: needs: build name: Test - Linux Musl runs-on: ubuntu-24.04 - if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci') container: ghcr.io/astral-sh/uv:0.9.11-alpine steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 0000000..7b0b618 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,117 @@ +name: PR Check + +on: + pull_request: + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: astral-sh/ruff-action@v3 + - run: | + ruff check + ruff format --check + + rust_tests: + name: Rust tests (Linux x86_64) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + + - name: Cache Rust build + uses: actions/cache@v4 + with: + path: | + target + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-test-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ runner.arch }}- + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.9.11" + enable-cache: true + cache-dependency-glob: "**/uv.lock" + + - name: Install required python dependencies + run: uv sync --no-install-project + shell: bash + + - name: Run cargo tests + run: | + PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") + echo "Python libdir: $PY_LIBDIR" + export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + uv run --no-sync cargo test --no-default-features + shell: bash + + build: + needs: rust_tests + name: Build Wheel (Linux x86_64) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + + - name: Cache Rust build + uses: actions/cache@v4 + with: + path: | + target + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-build-linux-x86_64-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-build-linux-x86_64- + + - name: Build wheel + uses: PyO3/maturin-action@v1 + with: + maturin-version: 1.9.6 + target: x86_64-unknown-linux-gnu + args: --release --out dist --find-interpreter + manylinux: "2_28" + before-script-linux: python3 -m ensurepip && cat /etc/os-release && yum install clang -y + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: wheels-pr-linux-x86_64 + path: dist + + test: + needs: build + name: Test (Linux x86_64, Python 3.12) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.9.11" + enable-cache: "true" + cache-dependency-glob: "**/uv.lock" + python-version: "3.12" + + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: wheels-pr-linux-x86_64 + path: dist + + - name: Run tests + shell: bash + run: | + WHEEL_PATH=$(ls dist/*.whl) + uv venv + uv sync --no-install-project --no-default-groups --group=test + uv pip install --force-reinstall "$WHEEL_PATH" + uv run --no-sync pytest tests/ From 05b5b4a0b7cace970757730b907be8ec0ee35019 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:01:20 +0100 Subject: [PATCH 05/11] reusable workflow for lint --- .github/workflows/build-test.yml | 9 +-------- .github/workflows/ci-pr.yml | 9 +-------- .github/workflows/reusable/lint.yml | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/reusable/lint.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 8f7fe0b..08a26be 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -13,14 +13,7 @@ permissions: jobs: lint: - name: Lint - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v6 - - uses: astral-sh/ruff-action@v3 - - run: | - ruff check - ruff format --check + uses: ./.github/workflows/reusable/lint.yml rust_tests: name: Rust tests - ${{ matrix.platform.name }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 7b0b618..2e09021 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -8,14 +8,7 @@ permissions: jobs: lint: - name: Lint - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v6 - - uses: astral-sh/ruff-action@v3 - - run: | - ruff check - ruff format --check + uses: ./.github/workflows/reusable/lint.yml rust_tests: name: Rust tests (Linux x86_64) diff --git a/.github/workflows/reusable/lint.yml b/.github/workflows/reusable/lint.yml new file mode 100644 index 0000000..1e30379 --- /dev/null +++ b/.github/workflows/reusable/lint.yml @@ -0,0 +1,15 @@ +name: Lint + +on: + workflow_call: + +jobs: + lint: + name: Lint + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: astral-sh/ruff-action@v3 + - run: | + ruff check + ruff format --check From c996243c6cf94d4c136679205cca6c21d3e14fdf Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:02:38 +0100 Subject: [PATCH 06/11] fix path --- .github/workflows/build-test.yml | 2 +- .github/workflows/ci-pr.yml | 2 +- .github/workflows/{reusable => }/lint.yml | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{reusable => }/lint.yml (100%) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 08a26be..1cafd5f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -13,7 +13,7 @@ permissions: jobs: lint: - uses: ./.github/workflows/reusable/lint.yml + uses: ./.github/workflows/lint.yml rust_tests: name: Rust tests - ${{ matrix.platform.name }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 2e09021..87fa4e4 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -8,7 +8,7 @@ permissions: jobs: lint: - uses: ./.github/workflows/reusable/lint.yml + uses: ./.github/workflows/lint.yml rust_tests: name: Rust tests (Linux x86_64) diff --git a/.github/workflows/reusable/lint.yml b/.github/workflows/lint.yml similarity index 100% rename from .github/workflows/reusable/lint.yml rename to .github/workflows/lint.yml From ea3f85ad058882e5b758b6ca386b2d8d7094a54f Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:06:38 +0100 Subject: [PATCH 07/11] use composite action for rust caching --- .github/actions/cache-rust-build/action.yml | 15 +++++++++++++++ .github/workflows/build-test.yml | 11 +---------- .github/workflows/ci-pr.yml | 12 +----------- 3 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 .github/actions/cache-rust-build/action.yml diff --git a/.github/actions/cache-rust-build/action.yml b/.github/actions/cache-rust-build/action.yml new file mode 100644 index 0000000..309dc62 --- /dev/null +++ b/.github/actions/cache-rust-build/action.yml @@ -0,0 +1,15 @@ +name: Cache Rust build +description: Caches Rust build artifacts and dependencies +runs: + using: "composite" + steps: + - name: Cache Rust build + uses: actions/cache@v4 + with: + path: | + target + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-test-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ runner.arch }}- diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 1cafd5f..d88bbc2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -36,16 +36,7 @@ jobs: runner: macos-15 steps: - uses: actions/checkout@v6 - - name: Cache Rust build - uses: actions/cache@v4 - with: - path: | - target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-test-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ runner.arch }}- + - uses: ./.github/actions/cache-rust-build - name: Install uv uses: astral-sh/setup-uv@v7 diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 87fa4e4..76fb558 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -15,17 +15,7 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - - name: Cache Rust build - uses: actions/cache@v4 - with: - path: | - target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-test-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ runner.arch }}- + - uses: ./.github/actions/cache-rust-build - name: Install uv uses: astral-sh/setup-uv@v7 From 45ea86cc51b353179adc1952f9fd08bbc02f0373 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:16:11 +0100 Subject: [PATCH 08/11] use composite actions for all steps --- .github/actions/build-wheel/action.yml | 24 +++++++ .github/actions/download-wheels/action.yml | 15 +++++ .../actions/install-python-deps/action.yml | 8 +++ .github/actions/install-uv/action.yml | 17 +++++ .github/actions/run-cargo-tests/action.yml | 18 ++++++ .github/actions/run-python-tests/action.yml | 23 +++++++ .github/actions/test-wheel/action.yml | 32 ++++++++++ .github/actions/upload-wheels/action.yml | 15 +++++ .github/workflows/ci-pr.yml | 63 +++---------------- 9 files changed, 161 insertions(+), 54 deletions(-) create mode 100644 .github/actions/build-wheel/action.yml create mode 100644 .github/actions/download-wheels/action.yml create mode 100644 .github/actions/install-python-deps/action.yml create mode 100644 .github/actions/install-uv/action.yml create mode 100644 .github/actions/run-cargo-tests/action.yml create mode 100644 .github/actions/run-python-tests/action.yml create mode 100644 .github/actions/test-wheel/action.yml create mode 100644 .github/actions/upload-wheels/action.yml diff --git a/.github/actions/build-wheel/action.yml b/.github/actions/build-wheel/action.yml new file mode 100644 index 0000000..de923df --- /dev/null +++ b/.github/actions/build-wheel/action.yml @@ -0,0 +1,24 @@ +name: Build wheel +description: Build wheel with maturin +inputs: + maturin-version: + required: true + target: + required: true + args: + required: true + manylinux: + required: false + before-script-linux: + required: false +runs: + using: "composite" + steps: + - name: Build wheel + uses: PyO3/maturin-action@v1 + with: + maturin-version: ${{ inputs.maturin-version }} + target: ${{ inputs.target }} + args: ${{ inputs.args }} + manylinux: ${{ inputs.manylinux }} + before-script-linux: ${{ inputs.before-script-linux }} diff --git a/.github/actions/download-wheels/action.yml b/.github/actions/download-wheels/action.yml new file mode 100644 index 0000000..0a0c941 --- /dev/null +++ b/.github/actions/download-wheels/action.yml @@ -0,0 +1,15 @@ +name: Download wheels +description: Download wheels artifact +inputs: + name: + required: true + path: + required: true +runs: + using: "composite" + steps: + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} diff --git a/.github/actions/install-python-deps/action.yml b/.github/actions/install-python-deps/action.yml new file mode 100644 index 0000000..2c8976e --- /dev/null +++ b/.github/actions/install-python-deps/action.yml @@ -0,0 +1,8 @@ +name: Install Python dependencies +description: Install required Python dependencies using uv +runs: + using: "composite" + steps: + - name: Install required python dependencies + run: uv sync --no-install-project + shell: bash diff --git a/.github/actions/install-uv/action.yml b/.github/actions/install-uv/action.yml new file mode 100644 index 0000000..0188f17 --- /dev/null +++ b/.github/actions/install-uv/action.yml @@ -0,0 +1,17 @@ +name: Install uv +description: Setup uv with caching +inputs: + python-version: + description: Python version to use + required: false + default: "" +runs: + using: "composite" + steps: + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.9.11" + enable-cache: true + cache-dependency-glob: "**/uv.lock" + python-version: ${{ inputs.python-version }} diff --git a/.github/actions/run-cargo-tests/action.yml b/.github/actions/run-cargo-tests/action.yml new file mode 100644 index 0000000..6242e68 --- /dev/null +++ b/.github/actions/run-cargo-tests/action.yml @@ -0,0 +1,18 @@ +name: Run cargo tests +description: Run cargo tests with uv and proper environment +inputs: + extra-linux-env: + description: Extra env for Linux (optional) + required: false + default: "" +runs: + using: "composite" + steps: + - name: Run cargo tests + shell: bash + run: | + PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") + echo "Python libdir: $PY_LIBDIR" + export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + ${{ inputs.extra-linux-env }} + uv run --no-sync cargo test --no-default-features diff --git a/.github/actions/run-python-tests/action.yml b/.github/actions/run-python-tests/action.yml new file mode 100644 index 0000000..30302a5 --- /dev/null +++ b/.github/actions/run-python-tests/action.yml @@ -0,0 +1,23 @@ +name: Run Python tests +description: Run Python tests with uv +inputs: + min-deps: + required: false + default: "false" +runs: + using: "composite" + steps: + - name: Run tests + shell: bash + run: | + WHEEL_PATH=$(ls dist/*.whl) + uv venv + if [[ "${{ inputs.min-deps }}" == "true" ]]; then + uv sync --resolution lowest-direct --no-install-project --no-default-groups --group=test + uv pip install --no-deps --force-reinstall "$WHEEL_PATH" + uv run --no-sync --no-default-groups --group=test pytest tests/ + else + uv sync --no-install-project --no-default-groups --group=test + uv pip install --force-reinstall "$WHEEL_PATH" + uv run --no-sync pytest tests/ + fi diff --git a/.github/actions/test-wheel/action.yml b/.github/actions/test-wheel/action.yml new file mode 100644 index 0000000..f8aaeb9 --- /dev/null +++ b/.github/actions/test-wheel/action.yml @@ -0,0 +1,32 @@ +name: Test wheel +description: Download and test a built wheel +inputs: + artifact-name: + description: Name of the artifact to download + required: true + python-version: + description: Python version to use + required: false + default: "3.12" +runs: + using: "composite" + steps: + - name: Install uv + uses: ./.github/actions/install-uv + with: + python-version: ${{ inputs.python-version }} + + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: dist + + - name: Run tests + shell: bash + run: | + WHEEL_PATH=$(ls dist/*.whl) + uv venv + uv sync --no-install-project --no-default-groups --group=test + uv pip install --force-reinstall "$WHEEL_PATH" + uv run --no-sync pytest tests/ diff --git a/.github/actions/upload-wheels/action.yml b/.github/actions/upload-wheels/action.yml new file mode 100644 index 0000000..d1a312c --- /dev/null +++ b/.github/actions/upload-wheels/action.yml @@ -0,0 +1,15 @@ +name: Upload wheels +description: Upload wheels artifact +inputs: + name: + required: true + path: + required: true +runs: + using: "composite" + steps: + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 76fb558..3aa331e 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -16,25 +16,9 @@ jobs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/cache-rust-build - - - name: Install uv - uses: astral-sh/setup-uv@v7 - with: - version: "0.9.11" - enable-cache: true - cache-dependency-glob: "**/uv.lock" - - - name: Install required python dependencies - run: uv sync --no-install-project - shell: bash - - - name: Run cargo tests - run: | - PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") - echo "Python libdir: $PY_LIBDIR" - export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - uv run --no-sync cargo test --no-default-features - shell: bash + - uses: ./.github/actions/install-uv + - uses: ./.github/actions/install-python-deps + - uses: ./.github/actions/run-cargo-tests build: needs: rust_tests @@ -42,29 +26,15 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - - name: Cache Rust build - uses: actions/cache@v4 - with: - path: | - target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-build-linux-x86_64-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-build-linux-x86_64- - - - name: Build wheel - uses: PyO3/maturin-action@v1 + - uses: ./.github/actions/cache-rust-build + - uses: ./.github/actions/build-wheel with: maturin-version: 1.9.6 target: x86_64-unknown-linux-gnu args: --release --out dist --find-interpreter manylinux: "2_28" before-script-linux: python3 -m ensurepip && cat /etc/os-release && yum install clang -y - - - name: Upload wheel - uses: actions/upload-artifact@v4 + - uses: ./.github/actions/upload-wheels with: name: wheels-pr-linux-x86_64 path: dist @@ -75,26 +45,11 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - - name: Install uv - uses: astral-sh/setup-uv@v7 + - uses: ./.github/actions/install-uv with: - version: "0.9.11" - enable-cache: "true" - cache-dependency-glob: "**/uv.lock" python-version: "3.12" - - - name: Download wheel - uses: actions/download-artifact@v4 + - uses: ./.github/actions/download-wheels with: name: wheels-pr-linux-x86_64 path: dist - - - name: Run tests - shell: bash - run: | - WHEEL_PATH=$(ls dist/*.whl) - uv venv - uv sync --no-install-project --no-default-groups --group=test - uv pip install --force-reinstall "$WHEEL_PATH" - uv run --no-sync pytest tests/ + - uses: ./.github/actions/run-python-tests From 15e65de5cf4f2caae252a3dd3f953c1fbfabf2f7 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:23:45 +0100 Subject: [PATCH 09/11] consolidate workflow more --- .github/workflows/build-test.yml | 43 +++++++------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d88bbc2..f681142 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -37,18 +37,8 @@ jobs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/cache-rust-build - - - name: Install uv - uses: astral-sh/setup-uv@v7 - with: - version: "0.9.11" - enable-cache: true - cache-dependency-glob: "**/uv.lock" - # python-version: "3.12" - - - name: Install required python dependencies - run: uv sync --no-install-project - shell: bash + - uses: ./.github/actions/install-uv + - uses: ./.github/actions/install-python-deps - name: Run cargo tests run: | @@ -143,8 +133,7 @@ jobs: manylinux: ${{ matrix.platform.manylinux }} container: ${{ matrix.platform.is-musl == true && 'off' || '' }} before-script-linux: ${{ matrix.platform.before-script }} - - name: Upload wheels - uses: actions/upload-artifact@v4 + - uses: ./.github/actions/upload-wheels with: name: wheels-${{ matrix.platform.name }} path: dist @@ -154,13 +143,13 @@ jobs: steps: - uses: actions/checkout@v6 - name: Build sdist - uses: PyO3/maturin-action@v1 + uses: ./.github/actions/build-wheel with: maturin-version: 1.9.6 command: sdist args: --out dist - name: Upload sdist - uses: actions/upload-artifact@v4 + uses: ./.github/actions/upload-wheels with: name: wheels-sdist path: dist @@ -248,19 +237,11 @@ jobs: python-version: "3.10" is-min-deps: true steps: - # Use the test composite action - uses: actions/checkout@v6 - - - name: Install uv - uses: astral-sh/setup-uv@v7 + - uses: ./.github/actions/install-uv with: - version: "0.9.11" - enable-cache: "true" - cache-dependency-glob: "**/uv.lock" python-version: ${{ matrix.config.python-version }} - - - name: Download wheels - uses: actions/download-artifact@v4 + - uses: ./.github/actions/download-wheels with: name: wheels-${{ matrix.config.platform-name }} path: dist @@ -300,16 +281,10 @@ jobs: run: | apk add tar python3 py3-pip py3-psutil gcc python3-dev musl-dev linux-headers - - name: Install uv - uses: astral-sh/setup-uv@v7 + - uses: ./.github/actions/install-uv with: - version: "0.9.11" - enable-cache: "true" - cache-dependency-glob: "**/uv.lock" python-version: "3.12" - - - name: Download wheels - uses: actions/download-artifact@v4 + - uses: ./.github/actions/download-wheels with: name: wheels-linux-musl-x86_64 path: dist From 41395819f9c85c7bd480accc760df704105aeb20 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:43:48 +0100 Subject: [PATCH 10/11] use composite actions everywhere --- .github/actions/build-wheel/action.yml | 4 +- .github/actions/run-cargo-tests/action.yml | 20 +++--- .github/workflows/build-test.yml | 71 +++------------------- .github/workflows/ci-pr.yml | 1 - 4 files changed, 21 insertions(+), 75 deletions(-) diff --git a/.github/actions/build-wheel/action.yml b/.github/actions/build-wheel/action.yml index de923df..fb82f3b 100644 --- a/.github/actions/build-wheel/action.yml +++ b/.github/actions/build-wheel/action.yml @@ -1,8 +1,6 @@ name: Build wheel description: Build wheel with maturin inputs: - maturin-version: - required: true target: required: true args: @@ -17,7 +15,7 @@ runs: - name: Build wheel uses: PyO3/maturin-action@v1 with: - maturin-version: ${{ inputs.maturin-version }} + maturin-version: 1.9.6 target: ${{ inputs.target }} args: ${{ inputs.args }} manylinux: ${{ inputs.manylinux }} diff --git a/.github/actions/run-cargo-tests/action.yml b/.github/actions/run-cargo-tests/action.yml index 6242e68..a06b722 100644 --- a/.github/actions/run-cargo-tests/action.yml +++ b/.github/actions/run-cargo-tests/action.yml @@ -1,18 +1,24 @@ name: Run cargo tests description: Run cargo tests with uv and proper environment -inputs: - extra-linux-env: - description: Extra env for Linux (optional) - required: false - default: "" runs: using: "composite" steps: - name: Run cargo tests shell: bash run: | + # pyo3 and uv do not work well together... PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") echo "Python libdir: $PY_LIBDIR" - export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - ${{ inputs.extra-linux-env }} + # setting LD_LIBRARY_PATH for Linux: https://github.com/astral-sh/uv/issues/11006#issuecomment-2672486381 + export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" # LINUX + if [[ "$RUNNER_OS" == "Windows" ]]; then + uv run --no-sync python -c "import sys; print(sys.path)" + uv run --no-sync where python + export PYTHONPATH="$(echo .venv/Lib/site-packages)" + else + # setting PYTHONHOME and PYTHONPATH seem to be the best solution for macOS at the moment + # https://github.com/PyO3/pyo3/issues/1741#issuecomment-955805634 + export PYTHONHOME="$(uv run --no-sync python -c 'import sys; print(sys.base_prefix)')" # MACOS + export PYTHONPATH="$(echo .venv/lib/python*/site-packages)" # MACOS + fi uv run --no-sync cargo test --no-default-features diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f681142..92a3e13 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -39,26 +39,7 @@ jobs: - uses: ./.github/actions/cache-rust-build - uses: ./.github/actions/install-uv - uses: ./.github/actions/install-python-deps - - - name: Run cargo tests - run: | - # pyo3 and uv do not work well together... - PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") - echo "Python libdir: $PY_LIBDIR" - # setting LD_LIBRARY_PATH for Linux: https://github.com/astral-sh/uv/issues/11006#issuecomment-2672486381 - export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" # LINUX - if [[ "$RUNNER_OS" == "Windows" ]]; then - uv run --no-sync python -c "import sys; print(sys.path)" - uv run --no-sync where python - export PYTHONPATH="$(echo .venv/Lib/site-packages)" - else - # setting PYTHONHOME and PYTHONPATH seem to be the best solution for macOS at the moment - # https://github.com/PyO3/pyo3/issues/1741#issuecomment-955805634 - export PYTHONHOME="$(uv run --no-sync python -c 'import sys; print(sys.base_prefix)')" # MACOS - export PYTHONPATH="$(echo .venv/lib/python*/site-packages)" # MACOS - fi - uv run --no-sync cargo test --no-default-features - shell: bash + - uses: ./.github/actions/run-cargo-tests build: needs: rust_tests @@ -114,24 +95,12 @@ jobs: is-musl: false steps: - uses: actions/checkout@v6 - - name: Cache Rust build - uses: actions/cache@v4 - with: - path: | - target - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-build-${{ matrix.platform.name }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} - restore-keys: | - ${{ runner.os }}-build-${{ matrix.platform.name }}- - - name: Build wheels - uses: PyO3/maturin-action@v1 + - uses: ./.github/actions/cache-rust-build + - uses: ./.github/actions/build-wheel with: - maturin-version: 1.9.6 target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter manylinux: ${{ matrix.platform.manylinux }} - container: ${{ matrix.platform.is-musl == true && 'off' || '' }} before-script-linux: ${{ matrix.platform.before-script }} - uses: ./.github/actions/upload-wheels with: @@ -145,7 +114,6 @@ jobs: - name: Build sdist uses: ./.github/actions/build-wheel with: - maturin-version: 1.9.6 command: sdist args: --out dist - name: Upload sdist @@ -245,28 +213,9 @@ jobs: with: name: wheels-${{ matrix.config.platform-name }} path: dist - - # Regular tests (non-musl platforms) - - name: Run regular tests - if: ${{ !matrix.config.is-min-deps && !matrix.config.is-musl }} - shell: bash - run: | - WHEEL_PATH=$(ls dist/*.whl) - uv venv - uv sync --no-install-project --no-default-groups --group=test - uv pip install --force-reinstall "$WHEEL_PATH" - uv run --no-sync pytest tests/ - - # Minimum dependencies test - - name: Run tests with minimum dependencies - if: ${{ matrix.config.is-min-deps }} - shell: bash - run: | - WHEEL_PATH=$(ls dist/*.whl) - uv venv - uv sync --resolution lowest-direct --no-install-project --no-default-groups --group=test - uv pip install --no-deps --force-reinstall "$WHEEL_PATH" - uv run --no-sync --no-default-groups --group=test pytest tests/ + - uses: ./.github/actions/run-python-tests + with: + min-deps: ${{ matrix.config.is-min-deps }} test-musl: needs: build @@ -290,10 +239,4 @@ jobs: path: dist - name: Run musl tests - shell: sh - run: | - WHEEL_PATH=$(ls dist/*.whl) - uv venv - uv sync --no-install-project --no-default-groups --group=test - uv pip install --force-reinstall "$WHEEL_PATH" - uv run --no-sync pytest tests/ + uses: ./.github/actions/run-python-tests diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 3aa331e..5067ba7 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -29,7 +29,6 @@ jobs: - uses: ./.github/actions/cache-rust-build - uses: ./.github/actions/build-wheel with: - maturin-version: 1.9.6 target: x86_64-unknown-linux-gnu args: --release --out dist --find-interpreter manylinux: "2_28" From 6e32856c6998e84aefe998047131066968ff6b24 Mon Sep 17 00:00:00 2001 From: terraputix Date: Thu, 19 Feb 2026 14:45:59 +0100 Subject: [PATCH 11/11] consolidate uv setup in deploy_docs --- .github/workflows/deploy_docs.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index dd6c16c..889ac52 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -9,15 +9,8 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v6 - - - name: Install uv - uses: astral-sh/setup-uv@v7 - with: - version: "0.9.11" - enable-cache: "true" - cache-dependency-glob: "**/uv.lock" + - uses: actions/checkout@v6 + - uses: ./.github/actions/install-uv - name: Build Sphinx documentation run: |