From e72204813c4801050df43a844a1e149e47fd6053 Mon Sep 17 00:00:00 2001 From: Ray Walker Date: Sun, 17 May 2026 10:57:40 +1000 Subject: [PATCH] ci: skip native builds on no-rust PRs; matrix shrinks to linux x64 on PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Build Native workflow ran the full 5-platform matrix (linux x64 + linux arm64 + mac x86 + mac arm + windows) on every PR push, even when the PR didn't touch the native crate. macOS runners are ~10x ubuntu cost, windows ~2x — this PR cuts that: - pull_request trigger now path-filtered to packages/cachekit-core-ts/**, pnpm-lock.yaml, and this workflow file. PRs that don't touch the crate skip the workflow entirely. - A new `matrix` job resolves the build matrix dynamically: PRs build only x86_64-unknown-linux-gnu on the self-hosted runner (catches the vast majority of compile errors cheaply). push to main and release tags still build the full 5-target matrix, which is what actually gates publication. No change to the test or publish jobs: test downloads the linux x64 artifact (always produced) and publish only fires on tags (full matrix). --- .github/workflows/build-native.yml | 44 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 360bca9..9061d82 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -6,6 +6,11 @@ on: tags: ['cachekit-core-ts-v*'] pull_request: branches: [main] + # Skip the whole workflow for PRs that don't touch the native crate. + paths: + - 'packages/cachekit-core-ts/**' + - '.github/workflows/build-native.yml' + - 'pnpm-lock.yaml' permissions: contents: read @@ -14,21 +19,38 @@ env: CARGO_INCREMENTAL: 0 jobs: + matrix: + name: Resolve build matrix + runs-on: ubuntu-latest + outputs: + builds: ${{ steps.set.outputs.builds }} + steps: + - id: set + # PRs build the cheap linux-x64 target only (catches the vast majority + # of compile errors on the self-hosted runner). Full cross-platform + # validation runs on push to main and on release tags, which is what + # actually gates publication — keeping the macOS/Windows cost off the + # PR review loop without losing coverage where it matters. + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + builds='[{"target":"x86_64-unknown-linux-gnu","os":"cachekit-lean"}]' + else + builds='[ + {"target":"x86_64-unknown-linux-gnu","os":"cachekit-lean"}, + {"target":"aarch64-unknown-linux-gnu","os":"ubuntu-latest"}, + {"target":"x86_64-apple-darwin","os":"macos-latest"}, + {"target":"aarch64-apple-darwin","os":"macos-latest"}, + {"target":"x86_64-pc-windows-msvc","os":"windows-latest"} + ]' + fi + echo "builds=$(echo "$builds" | tr -d '\n ')" >> "$GITHUB_OUTPUT" + build: + needs: matrix strategy: fail-fast: false matrix: - include: - - target: x86_64-unknown-linux-gnu - os: cachekit-lean - - target: aarch64-unknown-linux-gnu - os: ubuntu-latest - - target: x86_64-apple-darwin - os: macos-latest - - target: aarch64-apple-darwin - os: macos-latest - - target: x86_64-pc-windows-msvc - os: windows-latest + include: ${{ fromJSON(needs.matrix.outputs.builds) }} runs-on: ${{ matrix.os }}