From 05637a09a22b7fc84e378a86e0dc3bfa3afabe41 Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Mon, 13 Apr 2026 13:39:32 -0500 Subject: [PATCH 1/3] ci: only run ci on PRs (against any branch) Running ci on push to any branch was unintentional and puts more load on CI. Creating a PR or doing a workflow_dispatch request seems like it should cover things well enough for now and avoid too many long-running jobs. --- .github/workflows/python-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 88a12df..65e578c 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -1,10 +1,10 @@ name: Python CI on: - push: # Runs on pushes to all branches - pull_request: + push: branches: - main + pull_request: workflow_dispatch: # Allows manual triggering from GitHub Actions UI env: From 1da26a54f3a6838430ff09a9a14732b88a28e1e1 Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Mon, 13 Apr 2026 13:44:44 -0500 Subject: [PATCH 2/3] ci: fix clippy rebuild, split caches, drop sccache --- .github/workflows/python-ci.yml | 63 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 65e578c..35788fd 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -21,7 +21,7 @@ jobs: toolchain: 1.92.0 target: wasm32-unknown-unknown components: rustfmt, clippy - # Disable the built-in cargo cache - we'll use a more sophisticated setup below + # Disable the built-in cargo cache - we use our own below cache: false - name: Set up nightly Rust toolchain with rust-src run: | @@ -33,7 +33,7 @@ jobs: python-version: '3.12' - name: Install uv run: pip install uv - + # Cache cargo binaries (viceroy, wasm-tools, etc.) - name: Cache cargo binaries id: cache-cargo-bins @@ -41,19 +41,25 @@ jobs: with: key: cargo-bins-${{ runner.os }}-${{ env.VICEROY_TAG }} path: | - ~/.cargo/bin/viceroy* - ~/.cargo/bin/wasm-tools* - ~/.cargo/bin/wac* + ~/.cargo/bin/viceroy* + ~/.cargo/bin/wasm-tools* + ~/.cargo/bin/wac* - name: Install wasm-tools and wac if: steps.cache-cargo-bins.outputs.cache-hit != 'true' run: cargo install wasm-tools wac-cli - name: Install viceroy if: steps.cache-cargo-bins.outputs.cache-hit != 'true' run: cargo install --git https://github.com/fastly/Viceroy.git --tag "$VICEROY_TAG" viceroy - - # Cache Rust dependencies and build artifacts - # CRITICAL: ~/.cargo/git/checkouts/ contains componentize-py source + built CPython (5+ min build) - - name: Cache Rust dependencies + + # Cache Rust registry and git sources separately from build artifacts. + # + # Sources are keyed only on Cargo.lock so they survive a clean target/ + # and are shared across build profiles (release, clippy, etc.). + # + # Build artifacts (target/) are cached separately per Cargo.lock AND + # Rust toolchain version, because different toolchain versions produce + # incompatible artifacts. + - name: Cache Rust sources uses: actions/cache@v4 with: path: | @@ -61,21 +67,24 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ ~/.cargo/git/checkouts/ - target/ - key: cargo-deps-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-v3 + key: cargo-sources-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-v1 restore-keys: | - cargo-deps-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}- - cargo-deps-${{ runner.os }}- - - # Setup sccache for Rust compilation caching - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.8 - - name: Configure sccache - run: | - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + cargo-sources-${{ runner.os }}- + + # Build artifacts are cached per Cargo.lock + toolchain. We cache both + # release and debug/clippy profiles together since they share most deps. + - name: Cache Rust build artifacts + uses: actions/cache@v4 + with: + path: target/ + key: cargo-target-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTUP_TOOLCHAIN }}-v1 + restore-keys: | + cargo-target-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}- + cargo-target-${{ runner.os }}- - # Build the Rust native extension (this is the slow part - builds componentize-py + CPython) + # Build the native extension in release mode first so the release + # artifacts are in target/. Clippy reuses these artifacts for deps + # that don't change between profiles. - name: Build native extension run: uv run maturin develop --release @@ -83,11 +92,17 @@ jobs: - name: Install Python dependencies run: uv sync --extra dev --extra test --extra examples - # Finally, do our final checks + # Run clippy using the same --release flag and features as the build + # above so that Cargo can reuse the already-compiled dependency + # artifacts and only checks our own crate. - name: Check formatting run: make format-check - name: Run linting - run: make lint + run: | + uv run python scripts/check_version_sync.py + uv run --extra dev ruff check . + uv run --extra dev --extra test pyrefly check + cd crates/fastly-compute-py && cargo clippy --release --no-default-features --features binary -- -D warnings - name: Run tests # Use DEV_MODE=0 to use the installed fastly-compute-py binary instead of rebuilding with cargo run: DEV_MODE=0 make test From ef60669cea92afb93cb68e59535d65498207bb1f Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Mon, 13 Apr 2026 14:10:36 -0500 Subject: [PATCH 3/3] ci: move clippy changes into `make lint` This is just more consistent; it does tie some specifics that are required by CI with the makefile, but I think that's probably fine and it's preferable to have what clippy does locally and in ci match. --- .github/workflows/python-ci.yml | 6 +----- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 35788fd..7f91a5b 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -98,11 +98,7 @@ jobs: - name: Check formatting run: make format-check - name: Run linting - run: | - uv run python scripts/check_version_sync.py - uv run --extra dev ruff check . - uv run --extra dev --extra test pyrefly check - cd crates/fastly-compute-py && cargo clippy --release --no-default-features --features binary -- -D warnings + run: make lint - name: Run tests # Use DEV_MODE=0 to use the installed fastly-compute-py binary instead of rebuilding with cargo run: DEV_MODE=0 make test diff --git a/Makefile b/Makefile index fc90f60..99e1d11 100644 --- a/Makefile +++ b/Makefile @@ -99,13 +99,13 @@ lint: fastly_compute/runtime_patching/patches.py | $(STUBS_DIR) uv run --extra dev ruff check . uv run --extra dev --extra test pyrefly check @echo "Linting Rust code..." - cd crates/fastly-compute-py && cargo clippy -- -D warnings + cd crates/fastly-compute-py && cargo clippy --release --no-default-features --features binary -- -D warnings lint-fix: fastly_compute/runtime_patching/patches.py @echo "Fixing Python code..." uv run --extra dev ruff check --fix . @echo "Fixing Rust code..." - cd crates/fastly-compute-py && cargo clippy --fix --allow-dirty --allow-staged + cd crates/fastly-compute-py && cargo clippy --release --no-default-features --features binary --fix --allow-dirty --allow-staged format: @echo "Formatting Python code..."