-
Notifications
You must be signed in to change notification settings - Fork 31
324 lines (314 loc) · 12.9 KB
/
tests.yml
File metadata and controls
324 lines (314 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
name: Test
on:
push:
branches:
- main
pull_request:
merge_group:
permissions:
contents: read
pages: write
id-token: write
deployments: write
jobs:
unit-tests:
name: Unit tests (${{ matrix.workspace }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
workspace: [injected, special-pages]
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Build (injected only)
if: ${{ matrix.workspace == 'injected' }}
run: npm run build -w injected
- run: npm run test-unit -w ${{ matrix.workspace }}
unit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run stylelint
- run: npm run test-unit -w types-generator
- name: 'Clean tree'
run: 'npm run test-clean-tree'
get-playwright-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.pw.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: pw
run: |
VERSION=$(node -e "const l=require('./package-lock.json'); console.log((l.packages['node_modules/@playwright/test']||l.packages['node_modules/playwright']).version)")
echo "version=$VERSION" >> $GITHUB_OUTPUT
integration-tests-special-pages:
name: Integration tests (special-pages/${{ matrix.group }}, ubuntu-latest)
needs: get-playwright-version
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v${{ needs.get-playwright-version.outputs.version }}-noble
env:
HOME: /root
strategy:
fail-fast: false
matrix:
include:
- group: chromium
# windows=Desktop Edge, integration=Desktop Chrome
projects: --project windows --project integration
- group: webkit
# macos=Desktop Safari, ios=iPhone 14, android/android-landscape=Galaxy S III (webkit)
projects: --project macos --project ios --project android --project android-landscape
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Run integration tests
run: npx playwright test ${{ matrix.projects }} --grep-invert '@screenshots'
working-directory: special-pages
- uses: actions/upload-artifact@v7
if: always()
with:
name: tests-playwright-report-pages-${{ matrix.group }}
path: special-pages/playwright-report
retention-days: 5
integration-tests:
name: Integration tests (injected/${{ matrix.project }}, ubuntu-latest)
needs: get-playwright-version
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v${{ needs.get-playwright-version.outputs.version }}-noble
env:
HOME: /root
strategy:
fail-fast: false
matrix:
include:
- project: windows
- project: apple-isolated
# apple runs in Chromium (Playwright default) - no device preset is set in playwright.config.js
- project: apple
- project: ios
- project: android
- project: android-autofill-import
- project: chrome-mv3
- project: firefox
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Run integration tests
run: xvfb-run --server-args='-screen 0 1024x768x24' npx playwright test --project ${{ matrix.project }} --grep-invert '@screenshots' --reporter list
working-directory: injected
- uses: actions/upload-artifact@v7
if: always()
with:
name: tests-playwright-report-injected-${{ matrix.project }}
path: injected/playwright-report
retention-days: 5
integration:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Cache docs output
id: docs-output
uses: actions/cache@v5
with:
path: docs
key: docs-output-${{ github.run_id }}
- name: Build docs
run: npm run docs
needs:
- integration-tests
- integration-tests-special-pages
deploy-docs:
runs-on: ubuntu-latest
needs: integration
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Cache build outputs
id: docs-output
uses: actions/cache@v5
with:
path: docs
key: docs-output-${{ github.run_id }}
- name: Setup Github Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: docs
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# This job ensures all runtime dependencies for the injected/ subproject are correctly listed in 'dependencies' (not 'devDependencies')
# by running the build with only production dependencies installed in injected/. It will fail if any required dependency is missing.
production-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache node_modules (production)
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
injected/node_modules
special-pages/node_modules
messaging/node_modules
types-generator/node_modules
key: ${{ runner.os }}-node-modules-prod-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install production dependencies only (injected/)
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --production
- name: Build with production dependencies (injected/)
run: cd injected && npm run build
- name: Simulate extension esbuild for GPC feature (production deps only)
run: npx esbuild injected/src/features/gpc.js --bundle --outfile=/tmp/gpc-bundle.js
# Single stable check to use for branch protection rules.
# This job will fail if any required job fails/skips/cancels.
ci-gate:
name: CI gate
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- unit
- unit-tests
- integration
- integration-tests
- integration-tests-special-pages
- production-deps
steps:
- name: Ensure all required jobs succeeded
run: |
echo "unit: ${{ needs.unit.result }}"
echo "unit-tests: ${{ needs.unit-tests.result }}"
echo "integration: ${{ needs.integration.result }}"
echo "integration-tests: ${{ needs.integration-tests.result }}"
echo "integration-tests-special-pages: ${{ needs.integration-tests-special-pages.result }}"
echo "production-deps: ${{ needs.production-deps.result }}"
test "${{ needs.unit.result }}" = "success"
test "${{ needs.unit-tests.result }}" = "success"
test "${{ needs.integration.result }}" = "success"
test "${{ needs.integration-tests.result }}" = "success"
test "${{ needs.integration-tests-special-pages.result }}" = "success"
test "${{ needs.production-deps.result }}" = "success"