44 workflow_dispatch :
55
66jobs :
7- test :
7+ build :
88 runs-on : ${{ matrix.os }}
99 strategy :
1010 matrix :
1111 os : [ubuntu-latest, macos-latest, windows-latest]
12- node-version : [18 ]
12+ node-version : [21 ]
1313 package-manager : [npm, pnpm, yarn]
1414
1515 steps :
16- # Checkout the repo
17- - uses : actions/checkout@v5
16+ # Checkout code
17+ - uses : actions/checkout@v6
1818
1919 # Setup Node.js without automatic caching
2020 - name : Setup Node.js
2121 uses : actions/setup-node@v6
2222 with :
2323 node-version : ${{ matrix.node-version }}
24+ package-manager-cache : false
2425
25- - name : Set cache path
26+ # Normalize runner architecture
27+ - name : Normalize runner architecture
28+ shell : bash
29+ run : |
30+ echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
31+
32+ # Determine cache path per package manager
33+ - name : Set Node cache path
2634 id : cache-path
35+ shell : bash
2736 run : |
2837 if [ "${{ matrix.package-manager }}" = "npm" ]; then
29- echo "CACHE_PATH =$(npm config get cache)" >> $GITHUB_ENV
38+ echo "NODE_CACHE =$(npm config get cache)" >> $GITHUB_ENV
3039 elif [ "${{ matrix.package-manager }}" = "pnpm" ]; then
31- echo "CACHE_PATH =$(pnpm store path)" >> $GITHUB_ENV
40+ echo "NODE_CACHE =$(pnpm store path)" >> $GITHUB_ENV
3241 elif [ "${{ matrix.package-manager }}" = "yarn" ]; then
33- echo "CACHE_PATH =$(yarn cache dir)" >> $GITHUB_ENV
42+ echo "NODE_CACHE =$(yarn cache dir)" >> $GITHUB_ENV
3443 fi
3544
45+ # Debug cache env
46+ - name : Debug cache environment
47+ run : |
48+ echo "ARCH=$ARCH"
49+ echo "NODE_CACHE=$NODE_CACHE"
50+ echo "Package Manager: ${{ matrix.package-manager }}"
3651
37- # Restore cache manually
52+ # Restore Node cache
3853 - name : Restore Node cache
39- uses : actions/cache@v5
54+ uses : actions/cache/restore @v5
4055 with :
41- path : ${{ env.CACHE_PATH }} # <- use CACHE_PATH
42- key : node-cache-${{ runner.os }}-${{ matrix.package-manager }}-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/pnpm-lock.yaml', '**/yarn.lock') }}
43- restore-keys : |
44- node-cache-${{ runner.os }}-${{ matrix.package-manager }}-
56+ path : ${{ env.NODE_CACHE }}
57+ key : node-cache-${{ runner.os }}-${{ env.ARCH }}-${{ matrix.package-manager }}-${{ hashFiles('**/package-lock.json','**/npm-shrinkwrap.json','**/pnpm-lock.yaml','**/yarn.lock') }}
4558
46- - name : Install Dependencies
59+ # Install dependencies
60+ - name : Install dependencies
61+ shell : bash
4762 run : |
4863 if [ "${{ matrix.package-manager }}" = "npm" ]; then
4964 npm ci
@@ -53,14 +68,14 @@ jobs:
5368 yarn install --frozen-lockfile
5469 fi
5570
56-
57- - name : Run Tests
71+ # Build
72+ - name : Build
73+ shell : bash
5874 run : |
5975 if [ "${{ matrix.package-manager }}" = "npm" ]; then
60- npm test
76+ npm run build --if-present
6177 elif [ "${{ matrix.package-manager }}" = "pnpm" ]; then
62- pnpm test
78+ pnpm run build --if-present
6379 elif [ "${{ matrix.package-manager }}" = "yarn" ]; then
64- yarn test
80+ yarn build || true
6581 fi
66-
0 commit comments