diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7a9bdecac2e..d314e06c7af 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -24,7 +24,15 @@ jobs: uses: actions/cache@v4 with: path: ./benchmarks - key: ${{ runner.os }}-benchmark + # Use the current commit SHA as the cache key. + # This key won't exist on the first run, so the cache match falls back to restore-keys. + # Though, it won't be matched, the cache created will use this key as the cache key. + # So the next commit will be able to restore this cache (from the restore-keys). + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + key: ${{ runner.os }}-benchmark-${{ github.sha }} + # `github.event.before` means the commit before the push (i.e. the previous commit). + # So we can fetch the exact benchmark data from the previous commit. + restore-keys: ${{ runner.os }}-benchmark-${{ github.event.before }} - name: Store benchmarks result uses: benchmark-action/github-action-benchmark@v1.20.3 with: