Skip to content

Commit 831ab8d

Browse files
Update test-cache-restore.yml
1 parent 968ff6c commit 831ab8d

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

.github/workflows/test-cache-restore.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,52 @@ jobs:
1818
uses: actions/setup-node@v6
1919
with:
2020
node-version: '21'
21-
cache : npm
21+
cache: false # IMPORTANT: disable built-in cache
22+
23+
# Normalize runner.arch (same role as in setup-go)
24+
- name: Normalize runner architecture (Linux/macOS)
25+
if: runner.os != 'Windows'
26+
shell: bash
27+
run: |
28+
echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
29+
30+
- name: Normalize runner architecture (Windows)
31+
if: runner.os == 'Windows'
32+
shell: pwsh
33+
run: |
34+
"ARCH=$($env:RUNNER_ARCH.ToLower())" | Out-File $env:GITHUB_ENV -Append
35+
36+
# Node equivalent of `go env GOMODCACHE`
37+
- name: Set Node cache path (Linux/macOS)
38+
if: runner.os != 'Windows'
39+
shell: bash
40+
run: |
41+
if [ -f pnpm-lock.yaml ]; then
42+
echo "NODE_CACHE=$(pnpm store path)" >> $GITHUB_ENV
43+
elif [ -f yarn.lock ]; then
44+
echo "NODE_CACHE=$(yarn cache dir)" >> $GITHUB_ENV
45+
else
46+
echo "NODE_CACHE=$(npm config get cache)" >> $GITHUB_ENV
47+
fi
48+
49+
- name: Set Node cache path (Windows)
50+
if: runner.os == 'Windows'
51+
shell: pwsh
52+
run: |
53+
if (Test-Path pnpm-lock.yaml) {
54+
$cache = pnpm store path
55+
} elseif (Test-Path yarn.lock) {
56+
$cache = yarn cache dir
57+
} else {
58+
$cache = npm config get cache
59+
}
60+
"NODE_CACHE=$cache" | Out-File $env:GITHUB_ENV -Append
61+
62+
# Optional sanity check (recommended while debugging)
63+
- name: Debug cache env
64+
run: |
65+
echo "ARCH=$ARCH"
66+
echo "NODE_CACHE=$NODE_CACHE"
2267
2368
# Restore Node cache (mirrors Restore Go cache)
2469
- name: Restore Node cache
@@ -33,4 +78,3 @@ jobs:
3378

3479
- name: Build
3580
run: npm run build --if-present
36-

0 commit comments

Comments
 (0)