Skip to content

Commit c6f7179

Browse files
mydeaclaude
andcommitted
fix(ci): Use relative paths for cache to fix host/container mismatch
github.workspace resolves to different absolute paths on the host (/home/runner/work/...) vs inside a container (/__w/...), causing cache version hash mismatches. Use relative paths instead, which actions/cache resolves from the working directory. Bust cache key to v3 since the path format changed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7daf56f commit c6f7179

3 files changed

Lines changed: 18 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,21 @@ concurrency:
2828
env:
2929
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
3030

31-
# WARNING: this disables cross os caching as ~ and
32-
# github.workspace evaluate to differents paths
3331
CACHED_DEPENDENCY_PATHS: |
34-
${{ github.workspace }}/node_modules
35-
${{ github.workspace }}/packages/*/node_modules
36-
${{ github.workspace }}/dev-packages/*/node_modules
32+
node_modules
33+
packages/*/node_modules
34+
dev-packages/*/node_modules
3735
~/.cache/mongodb-binaries/
3836
3937
# DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock
4038

41-
# WARNING: this disables cross os caching as ~ and
42-
# github.workspace evaluate to differents paths
4339
# packages/utils/cjs and packages/utils/esm: Symlinks to the folders inside of `build`, needed for tests
4440
CACHED_BUILD_PATHS: |
45-
${{ github.workspace }}/dev-packages/*/build
46-
${{ github.workspace }}/packages/*/build
47-
${{ github.workspace }}/packages/*/lib
48-
${{ github.workspace }}/packages/ember/*.d.ts
49-
${{ github.workspace }}/packages/gatsby/*.d.ts
41+
dev-packages/*/build
42+
packages/*/build
43+
packages/*/lib
44+
packages/ember/*.d.ts
45+
packages/gatsby/*.d.ts
5046
5147
BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }}
5248

@@ -906,7 +902,7 @@ jobs:
906902
- name: Stores tarballs in cache
907903
uses: actions/cache/save@v5
908904
with:
909-
path: ${{ github.workspace }}/packages/*/*.tgz
905+
path: packages/*/*.tgz
910906
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}
911907
enableCrossOsArchive: true
912908

@@ -989,7 +985,7 @@ jobs:
989985
uses: actions/cache/restore@v5
990986
id: restore-tarball-cache
991987
with:
992-
path: ${{ github.workspace }}/packages/*/*.tgz
988+
path: packages/*/*.tgz
993989
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}
994990
enableCrossOsArchive: true
995991

@@ -1103,7 +1099,7 @@ jobs:
11031099
uses: actions/cache/restore@v5
11041100
id: restore-tarball-cache
11051101
with:
1106-
path: ${{ github.workspace }}/packages/*/*.tgz
1102+
path: packages/*/*.tgz
11071103
key: ${{ env.BUILD_CACHE_TARBALL_KEY }}
11081104
enableCrossOsArchive: true
11091105

.github/workflows/canary.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ env:
1313
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
1414

1515
CACHED_BUILD_PATHS: |
16-
${{ github.workspace }}/packages/*/*.tgz
17-
${{ github.workspace }}/node_modules
18-
${{ github.workspace }}/packages/*/node_modules
19-
${{ github.workspace }}/dev-packages/*/node_modules
20-
${{ github.workspace }}/dev-packages/*/build
21-
${{ github.workspace }}/packages/*/build
16+
packages/*/*.tgz
17+
node_modules
18+
packages/*/node_modules
19+
dev-packages/*/node_modules
20+
dev-packages/*/build
21+
packages/*/build
2222
2323
permissions:
2424
contents: read

scripts/dependency-hash-key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function outputDependencyCacheKey() {
3636
// We log the output in a way that the GitHub Actions can append it to the output
3737
// We prefix it with `dependencies-` so it is easier to identify in the logs
3838
// eslint-disable-next-line no-console
39-
console.log(`hash=v2-dependencies-${hash}`);
39+
console.log(`hash=v3-dependencies-${hash}`);
4040
}
4141

4242
function getNormalizedDependencies(packageJson, workspacePackageNames) {

0 commit comments

Comments
 (0)