Skip to content

Commit 35f0556

Browse files
Update test-cache-restore.yml
1 parent 7bb44a3 commit 35f0556

1 file changed

Lines changed: 8 additions & 29 deletions

File tree

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

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,34 @@ jobs:
1818
uses: actions/setup-node@v6
1919
with:
2020
node-version: '21'
21-
cache: npm
22-
# Normalize runner.arch (same role as in setup-go)
23-
- name: Normalize runner architecture (Linux/macOS)
24-
if: runner.os != 'Windows'
21+
package-manager-cache: false # IMPORTANT
22+
23+
# Normalize arch
24+
- name: Normalize runner architecture
2525
shell: bash
2626
run: |
2727
echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
2828
29-
- name: Normalize runner architecture (Windows)
30-
if: runner.os == 'Windows'
31-
shell: pwsh
32-
run: |
33-
"ARCH=$($env:RUNNER_ARCH.ToLower())" | Out-File $env:GITHUB_ENV -Append
34-
3529
# Node equivalent of `go env GOMODCACHE`
36-
- name: Set Node cache path (Linux/macOS)
30+
- name: Set Node cache path
3731
if: runner.os != 'Windows'
3832
shell: bash
3933
run: |
40-
if [ -f pnpm-lock.yaml ]; then
41-
echo "NODE_CACHE=$(pnpm store path)" >> $GITHUB_ENV
42-
elif [ -f yarn.lock ]; then
43-
echo "NODE_CACHE=$(yarn cache dir)" >> $GITHUB_ENV
44-
else
45-
echo "NODE_CACHE=$(npm config get cache)" >> $GITHUB_ENV
46-
fi
34+
set -e
35+
echo "NODE_CACHE=$(npm config get cache)" >> $GITHUB_ENV
4736
4837
- name: Set Node cache path (Windows)
4938
if: runner.os == 'Windows'
5039
shell: pwsh
5140
run: |
52-
if (Test-Path pnpm-lock.yaml) {
53-
$cache = pnpm store path
54-
} elseif (Test-Path yarn.lock) {
55-
$cache = yarn cache dir
56-
} else {
57-
$cache = npm config get cache
58-
}
59-
"NODE_CACHE=$cache" | Out-File $env:GITHUB_ENV -Append
41+
"NODE_CACHE=$(npm config get cache)" | Out-File $env:GITHUB_ENV -Append
6042
61-
# Optional sanity check (recommended while debugging)
6243
- name: Debug cache env
6344
run: |
6445
echo "ARCH=$ARCH"
6546
echo "NODE_CACHE=$NODE_CACHE"
6647
67-
# Restore Node cache (mirrors Restore Go cache)
6848
- name: Restore Node cache
69-
id: node-cache
7049
uses: actions/cache/restore@v5
7150
with:
7251
path: ${{ env.NODE_CACHE }}

0 commit comments

Comments
 (0)