diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index d43db76414..5c2de96006 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -59,6 +59,15 @@ const Runners = { const prCacheKeyPrefix = `${cacheVersion}-cargo-target-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ matrix.profile }}-\${{ matrix.job }}-`; +const prCacheKey = `${prCacheKeyPrefix}\${{ github.sha }}`; +const prCachePath = [ + // this must match for save and restore (https://github.com/actions/cache/issues/1444) + "./target", + "!./target/*/gn_out", + "!./target/*/gn_root", + "!./target/*/*.zip", + "!./target/*/*.tar.gz", +].join("\n"); // Note that you may need to add more version to the `apt-get remove` line below if you change this const llvmVersion = 19; @@ -612,7 +621,7 @@ const ci = { `${cacheVersion}-cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ hashFiles('Cargo.lock') }}`, // We will try to restore from the closest cargo-home we can find "restore-keys": - `${cacheVersion}-cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}`, + `${cacheVersion}-cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}-`, }, }, { @@ -622,13 +631,7 @@ const ci = { if: "github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')", with: { - path: [ - "./target", - "!./target/*/gn_out", - "!./target/*/gn_root", - "!./target/*/*.zip", - "!./target/*/*.tar.gz", - ].join("\n"), + path: prCachePath, key: "never_saved", "restore-keys": prCacheKeyPrefix, }, @@ -1080,14 +1083,8 @@ const ci = { if: "(matrix.job == 'test' || matrix.job == 'lint') && github.ref == 'refs/heads/main'", with: { - path: [ - "./target", - "!./target/*/gn_out", - "!./target/*/*.zip", - "!./target/*/*.sha256sum", - "!./target/*/*.tar.gz", - ].join("\n"), - key: prCacheKeyPrefix + "${{ github.sha }}", + path: prCachePath, + key: prCacheKey, }, }, ]), diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29dd694c6c..44eb15cb95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -362,7 +362,7 @@ jobs: ~/.cargo/registry/index ~/.cargo/registry/cache key: '30-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' - restore-keys: '30-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' + restore-keys: '30-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-' if: '!(matrix.skip)' - name: Restore cache build output (PR) uses: actions/cache/restore@v4 @@ -682,8 +682,8 @@ jobs: path: |- ./target !./target/*/gn_out + !./target/*/gn_root !./target/*/*.zip - !./target/*/*.sha256sum !./target/*/*.tar.gz key: '30-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: