Skip to content

Commit e9e2f43

Browse files
Update workflow for Node.js SDK validation
1 parent c97e2c8 commit e9e2f43

File tree

1 file changed

+19
-46
lines changed

1 file changed

+19
-46
lines changed
Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Node.js Dependencies (Cache Restore Only)
1+
name: Validate corrupted Node.js SDK
22

33
on:
44
workflow_dispatch:
@@ -9,73 +9,46 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest, windows-latest]
12-
node-version: [21]
13-
package-manager: [npm, pnpm, yarn]
1412

1513
steps:
16-
# Checkout code
1714
- uses: actions/checkout@v6
1815

19-
# Setup Node.js without automatic caching
2016
- name: Setup Node.js
17+
id: setup-node
2118
uses: actions/setup-node@v6
2219
with:
23-
node-version: ${{ matrix.node-version }}
24-
package-manager-cache: false
20+
node-version: '21'
21+
package-manager-cache: true # IMPORTANT
2522

26-
# Normalize runner architecture
23+
# Normalize arch
2724
- name: Normalize runner architecture
2825
shell: bash
2926
run: |
3027
echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
31-
32-
# Determine cache path per package manager
28+
# Node equivalent of `go env GOMODCACHE`
3329
- name: Set Node cache path
34-
id: cache-path
30+
if: runner.os != 'Windows'
3531
shell: bash
3632
run: |
37-
if [ "${{ matrix.package-manager }}" = "npm" ]; then
38-
echo "node_cache_path=$(npm config get cache)" >> $GITHUB_OUTPUT
39-
elif [ "${{ matrix.package-manager }}" = "pnpm" ]; then
40-
echo "node_cache_path=$(pnpm store path)" >> $GITHUB_OUTPUT
41-
elif [ "${{ matrix.package-manager }}" = "yarn" ]; then
42-
echo "node_cache_path=$(yarn cache dir)" >> $GITHUB_OUTPUT
43-
fi
44-
45-
46-
# Debug cache env
47-
- name: Debug cache environment
33+
set -e
34+
echo "NODE_CACHE=$(npm config get cache)" >> $GITHUB_ENV
35+
- name: Set Node cache path (Windows)
36+
if: runner.os == 'Windows'
37+
shell: pwsh
38+
run: |
39+
"NODE_CACHE=$(npm config get cache)" | Out-File $env:GITHUB_ENV -Append
40+
- name: Debug cache env
4841
run: |
4942
echo "ARCH=$ARCH"
5043
echo "NODE_CACHE=$NODE_CACHE"
51-
echo "Package Manager: ${{ matrix.package-manager }}"
52-
5344
- name: Restore Node cache
5445
uses: actions/cache/restore@v5
5546
with:
56-
path: ${{ steps.cache-path.outputs.node_cache_path }}
57-
key: node-cache-${{ runner.os }}-${{ env.ARCH }}-${{ matrix.package-manager }}-${{ hashFiles('**/package-lock.json','**/npm-shrinkwrap.json','**/pnpm-lock.yaml','**/yarn.lock') }}
47+
path: ${{ env.NODE_CACHE }}
48+
key: node-cache-${{ runner.os }}-${{ env.ARCH }}-pnpm-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json') }}
5849

59-
# Install dependencies
6050
- name: Install dependencies
61-
shell: bash
62-
run: |
63-
if [ "${{ matrix.package-manager }}" = "npm" ]; then
64-
npm ci
65-
elif [ "${{ matrix.package-manager }}" = "pnpm" ]; then
66-
pnpm install
67-
elif [ "${{ matrix.package-manager }}" = "yarn" ]; then
68-
yarn install --frozen-lockfile
69-
fi
51+
run: npm ci
7052

71-
# Build
7253
- name: Build
73-
shell: bash
74-
run: |
75-
if [ "${{ matrix.package-manager }}" = "npm" ]; then
76-
npm run build --if-present
77-
elif [ "${{ matrix.package-manager }}" = "pnpm" ]; then
78-
pnpm run build --if-present
79-
elif [ "${{ matrix.package-manager }}" = "yarn" ]; then
80-
yarn build || true
81-
fi
54+
run: npm run build --if-present

0 commit comments

Comments
 (0)