Skip to content

Commit c1cc586

Browse files
authored
Merge pull request #92720 from Expensify/chuckdries/jest-ci-cache
[No QA] One Weird Trick To Make Your Jest Suite 10x Faster
2 parents 8ea16a6 + 684eb6b commit c1cc586

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ jobs:
3636
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb
3737
with:
3838
path: .jest-cache
39-
key: ${{ runner.os }}-jest
39+
# Per-shard key: each shard only instruments the ~1/8 of suites it runs, so a single
40+
# shared key freezes one shard's partial cache for all shards. The hash refreshes the
41+
# cache when dependencies or Babel config change; restore-keys warms it in between.
42+
key: ${{ runner.os }}-jest-${{ matrix.chunk }}-${{ hashFiles('package-lock.json', 'babel.config.js') }}
43+
restore-keys: ${{ runner.os }}-jest-${{ matrix.chunk }}-
4044

4145
- name: Jest tests
4246
run: npm test -- --silent --shard=${{ fromJSON(matrix.chunk) }}/${{ strategy.job-total }} --maxWorkers=6 --coverage --coverageDirectory=coverage/shard-${{ matrix.chunk }}

0 commit comments

Comments
 (0)