@@ -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,24 @@ 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+ # Optional but recommended: pin pnpm for reproducibility
28+ corepack prepare pnpm@9.12.2 --activate
2329
2430 - name : Setup Node.js
2531 uses : actions/setup-node@v4
2632 with :
2733 node-version : " 20"
28-
29- - name : Enable Corepack
30- run : corepack enable
34+ cache : " pnpm"
3135
3236 - name : Install dependencies
33- run : pnpm install
37+ run : pnpm install --frozen-lockfile
3438
3539 - name : Run format check
3640 run : pnpm format
@@ -42,63 +46,73 @@ jobs:
4246 strategy :
4347 matrix :
4448 node-version : [20, 22]
49+
4550 steps :
4651 - name : Checkout code
4752 uses : actions/checkout@v4
53+ with :
54+ fetch-depth : 1
55+
56+ # ✅ Make pnpm available before setup-node uses cache: 'pnpm'
57+ - name : Enable Corepack (pnpm)
58+ run : |
59+ corepack enable
60+ corepack prepare pnpm@9.12.2 --activate
4861
4962 - name : Setup Node.js
5063 uses : actions/setup-node@v4
5164 with :
5265 node-version : ${{ matrix.node-version }}
5366 registry-url : " https://registry.npmjs.org"
67+ cache : " pnpm"
5468
55- - name : Enable Corepack
56- run : corepack enable
57-
58- - name : Install dependencies
59- run : pnpm install
60-
61- - name : Install Java
62- run : |
63- sudo apt-get update
64- sudo apt-get install -y openjdk-17-jdk
65- java -version
69+ # Fast Java (no apt-get)
70+ - name : Setup Java (JDK 17)
71+ uses : actions/setup-java@v4
72+ with :
73+ distribution : " temurin"
74+ java-version : " 17"
6675
76+ # Cache Firebase emulators (JARs) once
6777 - name : Cache Firebase emulators
78+ if : matrix.node-version == '20'
6879 uses : actions/cache@v4
6980 with :
70- path : ~/.cache/firebase/emulators
71- key : ${{ runner.os }}-firebase-emulators-${{ hashFiles('.github/workflows/tests.yaml') }}
81+ path : |
82+ ~/.cache/firebase/emulators
83+ ~/.cache/firebase/runtime
84+ key : ${{ runner.os }}-firebase-emulators-${{ hashFiles('firebase.json', '.firebaserc', 'package.json', 'pnpm-lock.yaml') }}
7285 restore-keys : |
7386 ${{ runner.os }}-firebase-emulators-
7487
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
88+ # Pre-download emulator JARs (uses pnpm cache)
89+ - name : Pre-download Firebase emulators (cached)
90+ if : matrix.node-version == '20'
91+ run : pnpm dlx firebase-tools@14 setup:emulators:download
92+
93+ # Ensure firebase CLI is available for the test step (Node 20)
94+ - name : Install Firebase CLI (global, fast)
95+ if : matrix.node-version == '20'
96+ run : |
97+ pnpm add -g firebase-tools@14
98+ echo "$(pnpm bin -g)" >> $GITHUB_PATH
99+
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+ # ✅ Only run emulator tests once on Node 20
119132 - name : Run tests with emulator
133+ if : matrix.node-version == '20'
120134 run : pnpm test:emulator
0 commit comments