-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
config.yml
488 lines (478 loc) · 15.1 KB
/
config.yml
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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
version: 2.1
orbs:
aws-cli: circleci/aws-cli@4.2.3
aws-s3: circleci/aws-s3@4.1.0
parameters:
browserstack-force:
description: Whether to force browserstack usage. We have limited resources on browserstack so the pipeline might decide to skip browserstack if this parameter isn't set to true.
type: boolean
default: false
react-version:
description: The version of react to be used
type: string
default: stable
workflow:
description: The name of the workflow to run
type: string
default: pipeline
e2e-base-url:
description: The base url for running end-to-end test
type: string
default: ''
default-job: &default-job
parameters:
react-version:
description: The version of react to be used
type: string
default: << pipeline.parameters.react-version >>
test-gate:
description: A particular type of tests that should be run
type: string
default: undefined
e2e-base-url:
description: The base url for running end-to-end test
type: string
default: << pipeline.parameters.e2e-base-url >>
environment:
# expose it globally otherwise we have to thread it from each job to the install command
BROWSERSTACK_FORCE: << pipeline.parameters.browserstack-force >>
REACT_VERSION: << parameters.react-version >>
TEST_GATE: << parameters.test-gate >>
AWS_REGION_ARTIFACTS: eu-central-1
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
working_directory: /tmp/base-ui
docker:
- image: cimg/node:18.20
default-context: &default-context
context:
- org-global
# CircleCI has disabled the cache across forks for security reasons.
# Following their official statement, it was a quick solution, they
# are working on providing this feature back with appropriate security measures.
# https://discuss.circleci.com/t/saving-cache-stopped-working-warning-skipping-this-step-disabled-in-configuration/24423/21
#
# restore_repo: &restore_repo
# restore_cache:
# key: v1-repo-{{ .Branch }}-{{ .Revision }}
commands:
install_js:
parameters:
browsers:
type: boolean
default: false
description: 'Set to true if you intend to any browser (for example with playwright).'
react-version:
description: The version of react to be used
type: string
default: stable
steps:
- when:
condition: << parameters.browsers >>
steps:
- run:
name: Install pnpm package manager
command: corepack enable
- when:
condition:
not: << parameters.browsers >>
steps:
- run:
name: Install pnpm package manager
# See https://stackoverflow.com/a/73411601
command: corepack enable --install-directory ~/bin
- run:
name: Resolve React version
command: |
echo 'Using React version: << parameters.react-version >>'
node scripts/useReactVersion.mjs
# log a patch for maintainers who want to check out this change
git --no-pager diff HEAD
- run:
name: View install environment
command: |
node --version
pnpm --version
- when:
condition:
equal: [<< parameters.react-version >>, stable]
steps:
- run:
name: Install JS dependencies
command: pnpm install
- unless:
condition:
equal: [<< parameters.react-version >>, stable]
steps:
- run:
name: Install JS dependencies (without frozen lockfile)
command: pnpm install --no-frozen-lockfile
- run:
name: Restore clean working copy
command: git restore .
jobs:
checkout:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- when:
# Install can be "dirty" when running with non-default versions of React
condition:
equal: [<< parameters.react-version >>, stable]
steps:
- run:
name: Should not have any git not staged
command: git add -A && git diff --exit-code --staged
- run:
name: '`pnpm dedupe` was run?'
command: |
# #default-branch-switch
if [[ $(git diff --name-status master | grep -E 'pnpm-workspace\.yaml|pnpm-lock.yaml|package\.json') == "" ]];
then
echo "No changes to dependencies detected. Skipping..."
else
pnpm dedupe --check
fi
test_unit:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: Run tests on JSDOM
command: pnpm test:jsdom --coverage
- run:
name: Check if coverage report is generated
command: |
if ! [[ -s coverage/lcov.info ]]
then
exit 1
fi
- run:
name: Upload coverage report to Codecov
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-jsdom"
test_lint:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: Eslint
command: pnpm eslint:ci
- run:
name: Stylelint
command: pnpm stylelint
- run:
name: Lint JSON
command: pnpm jsonlint
- run:
name: Lint Markdown
command: pnpm markdownlint
test_static:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: '`pnpm prettier` changes committed?'
command: pnpm prettier --check
- run:
name: Generate PropTypes
command: pnpm proptypes
- run:
name: '`pnpm proptypes` changes committed?'
command: git add -A && git diff --exit-code --staged
- run:
name: Generate the documentation
command: pnpm docs:api
- run:
name: '`pnpm docs:api` changes committed?'
command: git add -A && git diff --exit-code --staged
- run:
name: '`pnpm extract-error-codes` changes committed?'
command: |
pnpm extract-error-codes
git add -A && git diff --exit-code --staged
- run:
name: '`pnpm docs:link-check` changes committed?'
command: |
pnpm docs:link-check
git add -A && git diff --exit-code --staged
test_types:
<<: *default-job
resource_class: 'medium+'
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: Tests TypeScript definitions
command: pnpm typescript
environment:
NODE_OPTIONS: --max-old-space-size=3072
- run:
name: Any defect declaration files?
command: node scripts/testBuiltTypes.mjs
- save_cache:
name: Save generated declaration files
key: typescript-declaration-files-{{ .Branch }}-{{ .Revision }}
paths:
# packages with generated declaration files
- packages/react/build
test_types_next:
<<: *default-job
resource_class: 'medium+'
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: Resolve typescript version
command: |
pnpm add typescript@next -d -w
# log a patch for maintainers who want to check out this change
git --no-pager diff HEAD
- run:
name: Tests TypeScript definitions
command: |
# ignore build failures
# it's expected that typescript@next fails since the lines of the errors
# change frequently. This build is monitored regardless of its status
set +e
pnpm typescript
exit 0
- restore_cache:
name: Restore generated declaration files
keys:
# We assume that the target branch is `master` and that declaration files are persisted in commit order.
# "If there are multiple matches, the most recently generated cache will be used."
- typescript-declaration-files-master
- run:
name: Diff declaration files
command: |
git add -f packages/react/build || echo 'Base UI declarations do not exist'
pnpm -r build:types
git --no-pager diff
- run:
name: Log defect declaration files
command: |
# ignore build failures
# Fixing these takes some effort that isn't viable to merge in a single PR.
# We'll simply monitor them for now.
set +e
node scripts/testBuiltTypes.mjs
exit 0
test_browser:
<<: *default-job
resource_class: 'medium+'
docker:
- image: mcr.microsoft.com/playwright:v1.49.1-noble
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Run tests on headless Chromium
command: pnpm test:chromium --coverage
- run:
name: Check if coverage report is generated
command: |
if ! [[ -s coverage/lcov.info ]]
then
exit 1
fi
- run:
name: Upload coverage report to Codecov
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-browser"
- store_artifacts:
# hardcoded in karma-webpack
path: /tmp/_karma_webpack_
destination: artifact-file
test_profile:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.49.1-noble
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Tests real browsers
# Run a couple of times for a better sample.
# TODO: hack something together where we can compile once and run multiple times e.g. by abusing watchmode.
command: |
# Running on chrome only since actual times are innaccurate anyway
# The other reason is that browserstack allows little concurrency so it's likely that we're starving other runs.
pnpm test:karma:profile --browsers chrome,chromeHeadless
pnpm test:karma:profile --browsers chrome,chromeHeadless
pnpm test:karma:profile --browsers chrome,chromeHeadless
pnpm test:karma:profile --browsers chrome,chromeHeadless
pnpm test:karma:profile --browsers chrome,chromeHeadless
# Persist reports for inspection in https://mui-dashboard.netlify.app/
- store_artifacts:
# see karma.conf.profile.js reactProfilerReporter.outputDir
path: tmp/react-profiler-report/karma
destination: react-profiler-report/karma
test_regressions:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.49.1-noble
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
browsers: true
- run:
name: Run visual regression tests
command: xvfb-run pnpm test:regressions
- run:
name: Upload screenshots to Argos CI
command: pnpm test:argos
test_e2e:
<<: *default-job
docker:
- image: mcr.microsoft.com/playwright:v1.49.1-noble
steps:
- checkout
- install_js:
browsers: true
- run:
name: pnpm test:e2e
command: pnpm test:e2e
test_bundle_size_monitor:
<<: *default-job
steps:
- checkout
- install_js
- run:
name: Run danger on PRs
command: pnpm danger ci --fail-on-errors
# TODO test bundle size https://github.com/mui/base-ui/issues/201
test_package:
<<: *default-job
steps:
- checkout
- install_js:
react-version: << parameters.react-version >>
- run:
name: Build packages
command: pnpm release:build
- run:
name: Verify built packages
command: pnpm -r test:package
workflows:
version: 2
pipeline:
when:
equal: [pipeline, << pipeline.parameters.workflow >>]
jobs:
- checkout:
<<: *default-context
- test_unit:
<<: *default-context
name: 'JSDOM tests'
requires:
- checkout
- test_lint:
<<: *default-context
requires:
- checkout
- test_static:
<<: *default-context
requires:
- checkout
- test_types:
<<: *default-context
name: 'Typechecking'
requires:
- checkout
- test_browser:
<<: *default-context
name: 'Browser tests'
requires:
- checkout
- test_regressions:
<<: *default-context
name: 'Regression tests'
requires:
- checkout
- test_e2e:
<<: *default-context
requires:
- checkout
- test_bundle_size_monitor:
<<: *default-context
requires:
- checkout
- test_package:
<<: *default-context
requires:
- checkout
profile:
when:
equal: [profile, << pipeline.parameters.workflow >>]
jobs:
- test_profile:
<<: *default-context
react-17:
triggers:
- schedule:
cron: '0 0 * * *'
filters:
branches:
only:
- master
jobs:
- test_unit:
<<: *default-context
react-version: ^17.0.0
- test_browser:
<<: *default-context
react-version: ^17.0.0
- test_regressions:
<<: *default-context
react-version: ^17.0.0
react-18:
when:
equal: [pipeline, << pipeline.parameters.workflow >>]
jobs:
- test_unit:
<<: *default-context
name: 'JSDOM tests (React 18)'
react-version: '^18'
- test_browser:
<<: *default-context
name: 'Browser tests (React 18)'
react-version: '^18'
- test_regressions:
<<: *default-context
name: 'Regression tests (React 18)'
react-version: '^18'
- test_types:
<<: *default-context
name: 'Typechecking (React 18)'
react-version: '^18'
typescript-next:
triggers:
- schedule:
cron: '0 0 * * *'
filters:
branches:
only:
- master
jobs:
- test_types_next:
<<: *default-context
name: 'Typechecking (typescript@next)'