From 9c5812e4686927090531931e86f6590f6e87221f Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Thu, 16 Jul 2026 00:50:57 -0600 Subject: [PATCH 1/2] fix(ci): skip native-host-build when no native-relevant paths changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit native-host-build, test, parity, and pre-publish-benchmark all ran a full 3-OS Rust build (via native-host-build) unconditionally on every push/PR, even for pure-TS/docs changes that can't affect the native addon. Add a detect-changes job that diffs against the PR base (or previous push SHA) for crates/**, Cargo.toml/lock, and the native addon loader. When none of those changed, native-host-build is skipped entirely (fail-open: any detection failure still builds, so a broken detector can't hide a real Rust regression). test/parity/pre-publish-benchmark keep running on all 3 OSes regardless — they just fall back to the last-published native binary via npm install instead of a freshly PR-built one, preserving full cross-platform test/parity coverage while cutting the redundant rebuild. --- .github/workflows/ci.yml | 66 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de3f6b019..d8d9eee95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,45 @@ jobs: - name: Run Biome run: npx @biomejs/biome check src/ tests/ + detect-changes: + name: Detect native-relevant changes + runs-on: ubuntu-latest + outputs: + native_changed: ${{ steps.check.outputs.native_changed }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Check for native-relevant changes + id: check + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + BASE_SHA="${{ github.event.pull_request.base.sha }}" + else + BASE_SHA="${{ github.event.before }}" + fi + + if [ -z "$BASE_SHA" ] || ! git cat-file -e "$BASE_SHA" 2>/dev/null; then + echo "No usable base SHA to diff against — assuming native changed" + echo "native_changed=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if git diff --name-only "$BASE_SHA" HEAD | grep -qE '^(crates/|Cargo\.toml$|Cargo\.lock$|src/infrastructure/native\.ts$)'; then + echo "Native-relevant paths changed" + echo "native_changed=true" >> "$GITHUB_OUTPUT" + else + echo "No native-relevant paths changed" + echo "native_changed=false" >> "$GITHUB_OUTPUT" + fi + native-host-build: + needs: detect-changes + # Fail open: only skip when detect-changes positively confirmed nothing + # native-relevant changed. Any other outcome (failure, skip) still builds, + # so a broken change-detector can't silently hide a real Rust regression. + if: needs.detect-changes.result != 'success' || needs.detect-changes.outputs.native_changed == 'true' strategy: fail-fast: false matrix: @@ -96,6 +134,13 @@ jobs: test: needs: native-host-build + # native-host-build may have been legitimately skipped (no native-relevant + # changes) — that's not a failure, so keep running against the published + # binary rather than cascading a skip. + if: | + always() && + needs.native-host-build.result != 'failure' && + needs.native-host-build.result != 'cancelled' strategy: fail-fast: false matrix: @@ -131,12 +176,14 @@ jobs: done - name: Download PR-built native addon + if: needs.native-host-build.result == 'success' uses: actions/download-artifact@v8 with: name: native-host-${{ matrix.os }} path: crates/codegraph-core - name: Install native addon over published binary + if: needs.native-host-build.result == 'success' shell: bash run: node scripts/ci-install-native.mjs @@ -224,6 +271,10 @@ jobs: parity: needs: native-host-build + if: | + always() && + needs.native-host-build.result != 'failure' && + needs.native-host-build.result != 'cancelled' strategy: fail-fast: false matrix: @@ -258,12 +309,14 @@ jobs: done - name: Download PR-built native addon + if: needs.native-host-build.result == 'success' uses: actions/download-artifact@v8 with: name: native-host-${{ matrix.os }} path: crates/codegraph-core - name: Install native addon over published binary + if: needs.native-host-build.result == 'success' shell: bash run: node scripts/ci-install-native.mjs @@ -351,8 +404,15 @@ jobs: # Only run on PRs — push-to-main re-runs the same benchmarks the merged # PR already gated on, doubling CI minutes per landed change with no new # signal. Mirrors the `if: github.event_name != 'push'` skip in - # publish.yml's equivalent gate. - if: github.event_name == 'pull_request' + # publish.yml's equivalent gate. Also tolerates native-host-build being + # legitimately skipped (no native-relevant changes) — benchmarks still + # need to run against the published binary since most regressions are + # TS-side, not Rust-side. + if: | + always() && + github.event_name == 'pull_request' && + needs.native-host-build.result != 'failure' && + needs.native-host-build.result != 'cancelled' needs: native-host-build runs-on: ubuntu-latest env: @@ -383,6 +443,7 @@ jobs: cache: false - name: Download PR-built native addon + if: needs.native-host-build.result == 'success' uses: actions/download-artifact@v8 with: name: native-host-ubuntu-latest @@ -406,6 +467,7 @@ jobs: done - name: Install native addon over published binary + if: needs.native-host-build.result == 'success' run: node scripts/ci-install-native.mjs # Build dist/ so benchmarks load the same compiled JS that ships to npm. From 485dd63e238841b64e1f62b57ca2700706661e69 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Thu, 16 Jul 2026 03:01:54 -0600 Subject: [PATCH 2/2] fix(ci): diff native-relevant changes against last release tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit native-host-build was skipping based on a diff against the PR base SHA (or previous push SHA), which only answers whether *this* change touched native code. It says nothing about whether the published npm binary that test/parity/pre-publish-benchmark fall back to has already drifted from HEAD. That binary is pinned to the last workflow_dispatch release and only gets rebuilt on demand — native-relevant commits routinely land on main between releases (62 since v3.15.0 at time of writing) without republishing. Diff against the last release tag instead, so native-host-build correctly reruns whenever the fallback binary would be stale, not just when the current PR/push touched crates/. --- .github/workflows/ci.yml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8d9eee95..27d320fcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,26 +58,34 @@ jobs: with: fetch-depth: 0 - - name: Check for native-relevant changes + - name: Check for native-relevant changes since the last published release id: check run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then - BASE_SHA="${{ github.event.pull_request.base.sha }}" - else - BASE_SHA="${{ github.event.before }}" - fi - - if [ -z "$BASE_SHA" ] || ! git cat-file -e "$BASE_SHA" 2>/dev/null; then - echo "No usable base SHA to diff against — assuming native changed" + # When this job says "unchanged", test/parity/pre-publish-benchmark + # fall back to the published npm platform packages (pinned exactly + # to package.json's version). Those packages only get rebuilt by an + # on-demand release (workflow_dispatch) — native-relevant commits + # routinely land on main between releases without republishing (this + # repo has shipped 60+ crates/ fixes since the last tag at the time + # of writing). Diffing against the PR base or the previous push SHA + # only answers "did *this* change touch native code" — it says + # nothing about whether the published binary this job's skip relies + # on has already drifted from HEAD. The only baseline that actually + # answers "is the published fallback binary still trustworthy" is + # the last release tag. + LAST_TAG=$(git tag --sort=-version:refname --list 'v[0-9]*.[0-9]*.[0-9]*' | grep -v dev | head -1) + + if [ -z "$LAST_TAG" ] || ! git cat-file -e "$LAST_TAG" 2>/dev/null; then + echo "No usable release tag to diff against — assuming native changed" echo "native_changed=true" >> "$GITHUB_OUTPUT" exit 0 fi - if git diff --name-only "$BASE_SHA" HEAD | grep -qE '^(crates/|Cargo\.toml$|Cargo\.lock$|src/infrastructure/native\.ts$)'; then - echo "Native-relevant paths changed" + if git diff --name-only "$LAST_TAG" HEAD | grep -qE '^(crates/|Cargo\.toml$|Cargo\.lock$|src/infrastructure/native\.ts$)'; then + echo "Native-relevant paths changed since $LAST_TAG (last published release)" echo "native_changed=true" >> "$GITHUB_OUTPUT" else - echo "No native-relevant paths changed" + echo "No native-relevant paths changed since $LAST_TAG (last published release)" echo "native_changed=false" >> "$GITHUB_OUTPUT" fi