@@ -2,13 +2,10 @@ name: Tests
2
2
3
3
on :
4
4
push :
5
- branches :
6
- - main
5
+ branches : [main]
7
6
pull_request :
8
- branches :
9
- - main
7
+ branches : [main]
10
8
11
- # Cancel in-progress runs when a new run is queued on the same branch
12
9
concurrency :
13
10
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14
11
cancel-in-progress : true
@@ -20,17 +17,23 @@ jobs:
20
17
steps :
21
18
- name : Checkout
22
19
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
23
28
24
29
- name : Setup Node.js
25
30
uses : actions/setup-node@v4
26
31
with :
27
32
node-version : " 20"
28
-
29
- - name : Enable Corepack
30
- run : corepack enable
33
+ cache : " pnpm"
31
34
32
35
- name : Install dependencies
33
- run : pnpm install
36
+ run : pnpm install --frozen-lockfile
34
37
35
38
- name : Run format check
36
39
run : pnpm format
@@ -42,63 +45,74 @@ jobs:
42
45
strategy :
43
46
matrix :
44
47
node-version : [20, 22]
48
+
45
49
steps :
46
50
- name : Checkout code
47
51
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
48
60
49
61
- name : Setup Node.js
50
62
uses : actions/setup-node@v4
51
63
with :
52
64
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"
60
66
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"
66
73
74
+ # Cache Firebase emulators (JARs) once
67
75
- name : Cache Firebase emulators
76
+ if : matrix.node-version == '20'
68
77
uses : actions/cache@v4
69
78
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') }}
72
83
restore-keys : |
73
84
${{ runner.os }}-firebase-emulators-
74
85
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
87
102
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
93
110
94
- # Build packages before testing
95
111
- name : Build packages
96
112
run : pnpm turbo build
97
113
98
- # Verify build outputs
99
114
- name : Verify build outputs
100
115
run : |
101
- # Check all packages for dist directories
102
116
MISSING_BUILDS=""
103
117
for PKG_DIR in packages/*; do
104
118
if [ -d "$PKG_DIR" ] && [ -f "$PKG_DIR/package.json" ]; then
@@ -108,13 +122,13 @@ jobs:
108
122
fi
109
123
fi
110
124
done
111
-
112
125
if [ -n "$MISSING_BUILDS" ]; then
113
126
echo "❌ Build outputs not found for: $MISSING_BUILDS"
114
127
exit 1
115
128
fi
116
129
echo "✅ All build outputs verified"
117
130
118
- # Run tests with all emulators (auth, firestore, and data-connect )
131
+ # Run emulator tests only once (Node 20 )
119
132
- name : Run tests with emulator
133
+ if : matrix.node-version == '20'
120
134
run : pnpm test:emulator
0 commit comments