@@ -2,13 +2,10 @@ name: Tests
22
33on :
44 push :
5- branches :
6- - main
5+ branches : [main]
76 pull_request :
8- branches :
9- - main
7+ branches : [main]
108
11- # Cancel in-progress runs when a new run is queued on the same branch
129concurrency :
1310 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1411 cancel-in-progress : true
@@ -20,17 +17,23 @@ jobs:
2017 steps :
2118 - name : Checkout
2219 uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 1
22+
23+ # Make pnpm available before setup-node uses cache: 'pnpm'
24+ - name : Enable Corepack (pnpm)
25+ run : |
26+ corepack enable
27+ corepack prepare pnpm@9.12.2 --activate
2328
2429 - name : Setup Node.js
2530 uses : actions/setup-node@v4
2631 with :
2732 node-version : " 20"
28-
29- - name : Enable Corepack
30- run : corepack enable
33+ cache : " pnpm"
3134
3235 - name : Install dependencies
33- run : pnpm install
36+ run : pnpm install --frozen-lockfile
3437
3538 - name : Run format check
3639 run : pnpm format
@@ -42,63 +45,74 @@ jobs:
4245 strategy :
4346 matrix :
4447 node-version : [20, 22]
48+
4549 steps :
4650 - name : Checkout code
4751 uses : actions/checkout@v4
52+ with :
53+ fetch-depth : 1
54+
55+ # Make pnpm available before setup-node uses cache: 'pnpm'
56+ - name : Enable Corepack (pnpm)
57+ run : |
58+ corepack enable
59+ corepack prepare pnpm@9.12.2 --activate
4860
4961 - name : Setup Node.js
5062 uses : actions/setup-node@v4
5163 with :
5264 node-version : ${{ matrix.node-version }}
53- registry-url : " https://registry.npmjs.org"
54-
55- - name : Enable Corepack
56- run : corepack enable
57-
58- - name : Install dependencies
59- run : pnpm install
65+ cache : " pnpm"
6066
61- - name : Install Java
62- run : |
63- sudo apt-get update
64- sudo apt-get install -y openjdk-17-jdk
65- java -version
67+ # Fast Java (no apt-get)
68+ - name : Setup Java (JDK 17)
69+ uses : actions/setup-java@v4
70+ with :
71+ distribution : " temurin"
72+ java-version : " 17"
6673
74+ # Cache Firebase emulators (JARs) once
6775 - name : Cache Firebase emulators
76+ if : matrix.node-version == '20'
6877 uses : actions/cache@v4
6978 with :
70- path : ~/.cache/firebase/emulators
71- key : ${{ runner.os }}-firebase-emulators-${{ hashFiles('.github/workflows/tests.yaml') }}
79+ path : |
80+ ~/.cache/firebase/emulators
81+ ~/.cache/firebase/runtime
82+ key : ${{ runner.os }}-firebase-emulators-${{ hashFiles('firebase.json', '.firebaserc', 'package.json', 'pnpm-lock.yaml') }}
7283 restore-keys : |
7384 ${{ runner.os }}-firebase-emulators-
7485
75- - name : Install Firebase CLI
76- uses : nick-invision/retry@v3
77- with :
78- timeout_minutes : 10
79- retry_wait_seconds : 60
80- max_attempts : 3
81- command : npm i -g firebase-tools@latest
82-
83- # Determine which packages have changed
84- - name : Determine changed packages
85- id : changes
86- uses : dorny/paths-filter@v2
86+ # Ensure pnpm has a global bin dir on Linux runners (fixes ERR_PNPM_NO_GLOBAL_BIN_DIR)
87+ - name : Configure PNPM global bin
88+ if : matrix.node-version == '20'
89+ run : |
90+ echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
91+ mkdir -p "$HOME/.local/share/pnpm"
92+ echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
93+
94+ # Install Firebase CLI globally so pnpm test:emulator works
95+ - name : Install Firebase CLI (global, fast)
96+ if : matrix.node-version == '20'
97+ run : pnpm add -g firebase-tools@14
98+
99+ # Optional turbo cache
100+ - name : Cache turbo build metadata
101+ uses : actions/cache@v4
87102 with :
88- filters : |
89- react:
90- - 'packages/react/**'
91- angular:
92- - 'packages/angular/**'
103+ path : .turbo
104+ key : ${{ runner.os }}-turbo-${{ github.sha }}
105+ restore-keys : |
106+ ${{ runner.os }}-turbo-
107+
108+ - name : Install dependencies
109+ run : pnpm install --frozen-lockfile
93110
94- # Build packages before testing
95111 - name : Build packages
96112 run : pnpm turbo build
97113
98- # Verify build outputs
99114 - name : Verify build outputs
100115 run : |
101- # Check all packages for dist directories
102116 MISSING_BUILDS=""
103117 for PKG_DIR in packages/*; do
104118 if [ -d "$PKG_DIR" ] && [ -f "$PKG_DIR/package.json" ]; then
@@ -108,13 +122,13 @@ jobs:
108122 fi
109123 fi
110124 done
111-
112125 if [ -n "$MISSING_BUILDS" ]; then
113126 echo "❌ Build outputs not found for: $MISSING_BUILDS"
114127 exit 1
115128 fi
116129 echo "✅ All build outputs verified"
117130
118- # Run tests with all emulators (auth, firestore, and data-connect )
131+ # Run emulator tests only once (Node 20 )
119132 - name : Run tests with emulator
133+ if : matrix.node-version == '20'
120134 run : pnpm test:emulator
0 commit comments