From 9bd52e34ea28904aa84f2b4b6a87b224e77b8ffa Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Fri, 3 Jul 2026 08:38:34 +0100 Subject: [PATCH] ci: cancel superseded runs, cache bun downloads and transform output, bound matrix cells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add concurrency groups to ci.yml and native-rn-matrix.yml: a force-push to a PR branch previously left the superseded run (5 gate legs + 12 matrix cells) executing to completion alongside the new one. Main pushes stay uncancelled so every landed commit gets a full verdict. - Cache bun's package-download store keyed on the lockfile; installs still verify against --frozen-lockfile, they just skip re-downloading tarballs. - Persist vitest-native's own on-disk caches (Babel transform of the RN graph + V8 compile cache) across runs, keyed per OS/Node leg and per RN × Vitest matrix cell. The entries are content/version-keyed internally, so a stale restore is a miss, never a wrong hit. (Effective once the cache moves under node_modules/.cache — see the transform-cache change; the step is a no-op before that.) - Bound matrix cells with timeout-minutes: 30 — a hung cell previously burned the 360-minute default; healthy cells finish well under 15. --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++ .github/workflows/native-rn-matrix.yml | 30 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1af3b1a..16a15a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,13 @@ on: permissions: contents: read +# A force-push to a PR branch previously left the superseded run executing to +# completion alongside the new one. Cancel superseded runs on PR refs; keep +# main pushes uncancelled so every landed commit gets a full verdict. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: check: name: Full gate (${{ matrix.os }}, Node ${{ matrix.node-version }}) @@ -48,9 +55,30 @@ jobs: with: node-version: ${{ matrix.node-version }} + # Package-download cache: bun still verifies against the frozen lockfile, + # it just skips re-downloading unchanged tarballs. + - name: Cache bun downloads + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: ~/.bun/install/cache + key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }} + restore-keys: bun-${{ runner.os }}- + - name: Install dependencies run: bun install --frozen-lockfile + # vitest-native's own on-disk caches (the Babel transform of the RN graph + + # the V8 compile cache) live under node_modules/.cache/vitest-native and are + # content/version-keyed internally, so restoring a stale snapshot is safe — + # outdated entries simply miss. Restored after install (bun may reshape + # node_modules), saved automatically post-job. + - name: Cache vitest-native transform output + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: packages/vitest-native/node_modules/.cache/vitest-native + key: vn-transform-${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('bun.lock') }} + restore-keys: vn-transform-${{ runner.os }}-node${{ matrix.node-version }}- + - name: Verify dependencies are pinned run: bun run lint:deps diff --git a/.github/workflows/native-rn-matrix.yml b/.github/workflows/native-rn-matrix.yml index d7d2925..d5e03b0 100644 --- a/.github/workflows/native-rn-matrix.yml +++ b/.github/workflows/native-rn-matrix.yml @@ -36,10 +36,19 @@ on: permissions: contents: read +# Cancel superseded runs on PR refs (a force-push previously left 10+ stale +# cells running to completion); keep main/scheduled runs uncancelled. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: matrix: name: native+hot — vitest ${{ matrix.vitest }} × RN ${{ matrix.rn }} runs-on: ubuntu-latest + # Without a bound, a hung cell (e.g. a stuck hot-soak worker) burns the + # 360-minute default. A healthy cell finishes well under 15 minutes. + timeout-minutes: 30 strategy: # Report every cell independently rather than stopping at the first failure. fail-fast: false @@ -58,6 +67,15 @@ jobs: with: node-version: '22.13.0' + # Package-download cache: bun still verifies against the frozen lockfile, + # it just skips re-downloading unchanged tarballs. + - name: Cache bun downloads + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: ~/.bun/install/cache + key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }} + restore-keys: bun-${{ runner.os }}- + - name: Install dependencies run: bun install --frozen-lockfile @@ -67,6 +85,18 @@ jobs: run: | bun add -d "react-native@${{ matrix.rn }}" "@react-native/babel-preset@${{ matrix.rn }}" --cwd packages/vitest-native + # vitest-native's on-disk caches (Babel transform of the RN graph + V8 + # compile cache), keyed per matrix cell — each cell transforms a different + # RN version. Entries are content/version-keyed internally, so a stale + # restore is a miss, never a wrong hit. Restored after the version pins + # (bun add reshapes node_modules), saved automatically post-job. + - name: Cache vitest-native transform output + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: packages/vitest-native/node_modules/.cache/vitest-native + key: vn-transform-${{ runner.os }}-rn${{ matrix.rn }}-vitest-${{ matrix.vitest }}-${{ hashFiles('bun.lock') }} + restore-keys: vn-transform-${{ runner.os }}-rn${{ matrix.rn }}-vitest-${{ matrix.vitest }}- + - name: Pin Vitest to the newest supported 4.x release if: matrix.vitest == 'latest-supported' # Bump the coverage provider in lockstep — a mismatched @vitest/coverage-v8