-
Notifications
You must be signed in to change notification settings - Fork 5.6k
460 lines (408 loc) · 14.8 KB
/
Copy pathmain.yml
File metadata and controls
460 lines (408 loc) · 14.8 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
name: Main
on:
push:
branches:
- main
- master
- stable
- Version-v*
- release/*
- trigger-ci*
pull_request:
types:
- opened
- reopened
- synchronize
branches-ignore:
- master
merge_group:
schedule:
# Run the full suite "overnight," once every half hour from 1:00am UTC until 2:59am UTC.
# This helps with "Top 10 failed tests on the metamask-extension repository main branch,"
# especially the Monday morning list, which is otherwise usually a fake empty.
- cron: '0,30 1-2 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !(contains(github.ref, 'refs/heads/main') || contains(github.ref, 'refs/heads/master') || contains(github.ref, 'refs/heads/stable')) }}
env:
# For a `pull_request` event, the branch is `github.head_ref``.
# For a `push` event, the branch is `github.ref_name`.
BRANCH: ${{ github.head_ref || github.ref_name }}
# For a `pull_request` event, the fork is `github.event.pull_request.head.repo.fork`.
# For a `push` event, the fork is `github.event.repository.fork`.
IS_FORK: ${{ github.event.pull_request.head.repo.fork || github.event.repository.fork }}
permissions:
contents: write # required for releases
id-token: write # required for s3 uploads
jobs:
prep-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
cache-node-modules: true
skip-allow-scripts: true
yarn-custom-url: ${{ vars.YARN_URL }}
# Need to cache `.metamask` folder for the anvil binary
- name: Cache .metamask folder
uses: actions/cache/save@v4
with:
path: .metamask
key: .metamask-${{ hashFiles('yarn.lock') }}
lint-workflows:
name: Lint workflows
uses: metamask/github-tools/.github/workflows/lint-workflows.yml@1299bb1de0c6974ae6d0a32c7e8897fe168239ac
test-lint:
needs:
- prep-deps
uses: ./.github/workflows/test-lint.yml
test-circular-deps:
name: Test circular deps
needs:
- prep-deps
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
skip-allow-scripts: true
yarn-custom-url: ${{ vars.YARN_URL }}
- name: Check circular dependencies
run: yarn circular-deps:check
repository-health-checks:
needs:
- prep-deps
uses: ./.github/workflows/repository-health-checks.yml
test-storybook:
name: Test storybook
needs:
- prep-deps
uses: ./.github/workflows/test-storybook.yml
validate-lavamoat-policy-build:
needs:
- prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-build.yml
validate-lavamoat-policy-webapp:
needs:
- prep-deps
uses: ./.github/workflows/validate-lavamoat-policy-webapp.yml
build-dist-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-dist-browserify
build-command: ${{ ((github.head_ref || github.ref_name) == 'master' || (github.head_ref || github.ref_name) == 'stable') && 'yarn build prod' || 'yarn build dist' }}
secrets: inherit
build-dist-mv2-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-dist-mv2-browserify
build-command: ${{ ((github.head_ref || github.ref_name) == 'master' || (github.head_ref || github.ref_name) == 'stable') && 'yarn build prod' || 'yarn build dist' }}
mozilla-lint: true
enable-mv3: false
secrets: inherit
build-beta-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-beta-browserify
build-command: yarn build --build-type beta dist
secrets: inherit
build-beta-mv2-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-beta-mv2-browserify
build-command: yarn build --build-type beta dist
mozilla-lint: false # Disabled as it is failing for some reason
enable-mv3: false
secrets: inherit
build-flask-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-flask-browserify
build-command: ${{ ((github.head_ref || github.ref_name) == 'master' || (github.head_ref || github.ref_name) == 'stable') && 'yarn build --build-type flask prod' || 'yarn build --build-type flask dist' }}
secrets: inherit
build-flask-mv2-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-flask-mv2-browserify
build-command: ${{ ((github.head_ref || github.ref_name) == 'master' || (github.head_ref || github.ref_name) == 'stable') && 'yarn build --build-type flask prod' || 'yarn build --build-type flask dist' }}
mozilla-lint: true
enable-mv3: false
secrets: inherit
build-test-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-test-browserify
build-command: yarn build:test
secrets: inherit
build-test-mv2-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-test-mv2-browserify
build-command: yarn build:test:mv2
mozilla-lint: false # Disabled as it is failing for some reason
enable-mv3: false
secrets: inherit
build-test-flask-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-test-flask-browserify
build-command: yarn build:test:flask
secrets: inherit
build-test-flask-mv2-browserify:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-test-flask-mv2-browserify
build-command: yarn build:test:flask:mv2
mozilla-lint: false # Disabled as it is failing for some reason
enable-mv3: false
secrets: inherit
build-test-webpack:
uses: ./.github/workflows/run-build.yml
with:
build-name: build-test-webpack
build-command: yarn build:test:webpack
validate-source-maps: false # Disabled as webpack outputs are not supported by validate-source-maps
secrets: inherit
run-benchmarks:
uses: ./.github/workflows/run-benchmarks.yml
needs:
- prep-deps
- build-test-browserify
- build-test-webpack
run-tests:
name: Run tests
needs:
- prep-deps
uses: ./.github/workflows/run-tests.yml
bundle-size:
needs:
- build-dist-browserify
runs-on: ubuntu-latest
env:
EXTENSION_BUNDLESIZE_STATS_TOKEN: ${{ secrets.EXTENSION_BUNDLESIZE_STATS_TOKEN }}
SELENIUM_BROWSER: chrome
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
skip-allow-scripts: true
yarn-custom-url: ${{ vars.YARN_URL }}
- name: Download artifact 'build-dist-browserify'
uses: actions/download-artifact@v4
with:
name: build-dist-browserify
- name: Measure bundle size
run: yarn tsx test/e2e/mv3-perf-stats/bundle-size.ts --out test-artifacts/chrome
- name: Record bundle size at commit
if: ${{ env.BRANCH == 'main' && env.IS_FORK == 'false'}}
run: ./.github/scripts/bundle-stats-commit.sh
- name: Upload 'bundle-size' to S3
if: ${{ vars.AWS_REGION && vars.AWS_IAM_ROLE && vars.AWS_S3_BUCKET }}
uses: metamask/github-tools/.github/actions/upload-s3@1233659b3850eb84824d7375e2e0c58eb237701d
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/bundle-size
path: test-artifacts/chrome
benchmark-pr:
needs:
- build-dist-browserify
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref_name == 'main') }}
uses: ./.github/workflows/benchmark-pr.yml
with:
browser-loads: '10'
page-loads: '10'
secrets:
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
EXTENSION_BENCHMARK_STATS_TOKEN: ${{ secrets.EXTENSION_BENCHMARK_STATS_TOKEN }}
needs-e2e:
needs:
- prep-deps
uses: ./.github/workflows/needs-e2e.yml
e2e-chrome:
needs:
- needs-e2e
- build-test-browserify
- build-test-webpack
- build-dist-browserify
- build-test-flask-browserify
if: ${{ needs.needs-e2e.outputs.needs-e2e == 'true' }}
uses: ./.github/workflows/e2e-chrome.yml
secrets:
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
e2e-firefox:
needs:
- needs-e2e
- build-test-mv2-browserify
- build-test-flask-mv2-browserify
if: ${{ needs.needs-e2e.outputs.needs-e2e == 'true' }}
uses: ./.github/workflows/e2e-firefox.yml
build-storybook:
name: Build storybook
uses: ./.github/workflows/build-storybook.yml
secrets:
STORYBOOK_TOKEN: ${{ secrets.STORYBOOK_TOKEN }}
build-ts-migration-dashboard:
name: Build ts migration dashboard
uses: ./.github/workflows/build-ts-migration-dashboard.yml
secrets:
TS_MIGRATION_DASHBOARD_TOKEN: ${{ secrets.TS_MIGRATION_DASHBOARD_TOKEN }}
build-source-map-explorer:
needs:
- prep-deps
- build-dist-browserify
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
skip-allow-scripts: true
yarn-custom-url: ${{ vars.YARN_URL }}
- name: Download artifact 'build-dist-browserify'
uses: actions/download-artifact@v4
with:
name: build-dist-browserify
- run: ./development/source-map-explorer.sh
- name: Upload 'source-map-explorer' to S3
if: ${{ vars.AWS_REGION && vars.AWS_IAM_ROLE && vars.AWS_S3_BUCKET }}
uses: metamask/github-tools/.github/actions/upload-s3@1233659b3850eb84824d7375e2e0c58eb237701d
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/source-map-explorer
path: build-artifacts/source-map-explorer
build-lavamoat-viz:
needs:
- prep-deps
- build-dist-browserify
runs-on: ubuntu-latest
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
GOOGLE_PROD_CLIENT_ID: 00000000000
APPLE_PROD_CLIENT_ID: 00000000000
GOOGLE_BETA_CLIENT_ID: 00000000000
APPLE_BETA_CLIENT_ID: 00000000000
GOOGLE_FLASK_CLIENT_ID: 00000000000
APPLE_FLASK_CLIENT_ID: 00000000000
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
skip-allow-scripts: true
yarn-custom-url: ${{ vars.YARN_URL }}
- name: Download artifact 'build-dist-browserify'
uses: actions/download-artifact@v4
with:
name: build-dist-browserify
- run: ./.github/scripts/create-lavamoat-viz.sh
- name: Upload 'build-viz' to S3
if: ${{ vars.AWS_REGION && vars.AWS_IAM_ROLE && vars.AWS_S3_BUCKET }}
uses: metamask/github-tools/.github/actions/upload-s3@1233659b3850eb84824d7375e2e0c58eb237701d
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/lavamoat-viz
path: build-artifacts/build-viz
publish-prerelease:
name: Publish prerelease
needs:
- build-dist-browserify
- build-dist-mv2-browserify
- build-beta-browserify
- build-beta-mv2-browserify
- build-flask-browserify
- build-flask-mv2-browserify
- build-test-browserify
- build-test-mv2-browserify
- build-test-flask-browserify
- build-test-flask-mv2-browserify
- run-benchmarks
- bundle-size
- build-storybook
- build-ts-migration-dashboard
- build-source-map-explorer
- build-lavamoat-viz
uses: ./.github/workflows/publish-prerelease.yml
secrets:
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
publish-release:
name: Publish release
if: ${{ github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'stable') }}
needs:
- build-dist-browserify
- build-dist-mv2-browserify
- build-flask-browserify
- build-flask-mv2-browserify
- run-tests
- e2e-chrome
- e2e-firefox
uses: ./.github/workflows/publish-release.yml
secrets: inherit
# Explanation for all-jobs-completed and all-jobs-pass being separate:
# https://github.com/MetaMask/metamask-module-template/pull/151
all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- lint-workflows
- test-lint
- repository-health-checks
- test-storybook
- validate-lavamoat-policy-build
- validate-lavamoat-policy-webapp
- build-dist-browserify
- build-dist-mv2-browserify
- build-beta-browserify
- build-beta-mv2-browserify
- build-flask-browserify
- build-flask-mv2-browserify
- build-test-browserify
- build-test-mv2-browserify
- build-test-flask-browserify
- build-test-flask-mv2-browserify
- build-test-webpack
- run-tests
- needs-e2e
- e2e-chrome
- e2e-firefox
- build-storybook
- build-ts-migration-dashboard
- build-source-map-explorer
- build-lavamoat-viz
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"
all-jobs-pass:
name: All jobs pass
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
needs:
- all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi
log-merge-group-failure:
name: Log merge group failure
# Only run this job if the merge group event fails, skip on forks
if: ${{ github.event_name == 'merge_group' && failure() && !github.event.repository.fork }}
needs:
- all-jobs-pass
uses: metamask/github-tools/.github/workflows/log-merge-group-failure.yml@6bbad335a01fce1a9ec1eabd9515542c225d46c0
secrets:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
SPREADSHEET_ID: ${{ secrets.GOOGLE_MERGE_QUEUE_SPREADSHEET_ID }}
SHEET_NAME: ${{ secrets.GOOGLE_MERGE_QUEUE_SHEET_NAME }}