From da7eb7c84bbda45dc6ed0f07bb9db7acf3281ce2 Mon Sep 17 00:00:00 2001 From: Robert Chen Date: Wed, 21 Oct 2026 13:55:20 -0700 Subject: [PATCH 1/2] Save the Jest cache even when tests fail --- .github/workflows/test.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 163a97c69349..af7e39b8a449 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,21 +30,31 @@ jobs: - name: Setup Node uses: ./.github/actions/composite/setupNode - - name: Cache Jest cache + - name: Restore Jest cache id: cache-jest-cache # v5.0.1 - uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb + uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb with: path: .jest-cache # Per-shard key: each shard only instruments the ~1/8 of suites it runs, so a single # shared key freezes one shard's partial cache for all shards. The hash refreshes the - # cache when dependencies or Babel config change; restore-keys warms it in between. - key: ${{ runner.os }}-jest-${{ matrix.chunk }}-${{ hashFiles('package-lock.json', 'patches/**', 'babel.config.js') }} + # cache when dependencies, Babel config or Node change (babel-jest keys entries on the + # Node version); restore-keys warms it in between. + key: ${{ runner.os }}-jest-${{ matrix.chunk }}-${{ hashFiles('package-lock.json', 'patches/**', 'babel.config.js', '.nvmrc') }} restore-keys: ${{ runner.os }}-jest-${{ matrix.chunk }}- - name: Jest tests run: npm test -- --silent --shard=${{ fromJSON(matrix.chunk) }}/${{ strategy.job-total }} --maxWorkers=6 --coverage --coverageDirectory=coverage/shard-${{ matrix.chunk }} + # Saves even when tests fail, so a shard that timed out on a cold cache runs warm next time. + - name: Save Jest cache + if: ${{ always() && steps.cache-jest-cache.outputs.cache-hit != 'true' }} + # v5.0.1 + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb + with: + path: .jest-cache + key: ${{ steps.cache-jest-cache.outputs.cache-primary-key }} + - name: Upload coverage to Codecov (PRs - tokenless) if: ${{ github.event_name == 'pull_request' }} # v7 From f79ffe7a1e0b25ec66fbd3a5e85bfd2f7a718eb5 Mon Sep 17 00:00:00 2001 From: Robert Chen Date: Wed, 21 Oct 2026 14:02:31 -0700 Subject: [PATCH 2/2] Drop .nvmrc from the Jest cache key --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af7e39b8a449..35fb200f8c8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,9 +38,8 @@ jobs: path: .jest-cache # Per-shard key: each shard only instruments the ~1/8 of suites it runs, so a single # shared key freezes one shard's partial cache for all shards. The hash refreshes the - # cache when dependencies, Babel config or Node change (babel-jest keys entries on the - # Node version); restore-keys warms it in between. - key: ${{ runner.os }}-jest-${{ matrix.chunk }}-${{ hashFiles('package-lock.json', 'patches/**', 'babel.config.js', '.nvmrc') }} + # cache when dependencies or Babel config change; restore-keys warms it in between. + key: ${{ runner.os }}-jest-${{ matrix.chunk }}-${{ hashFiles('package-lock.json', 'patches/**', 'babel.config.js') }} restore-keys: ${{ runner.os }}-jest-${{ matrix.chunk }}- - name: Jest tests