diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 163a97c69349..35fb200f8c8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,10 +30,10 @@ 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 @@ -45,6 +45,15 @@ jobs: - 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