forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic_config.yml
478 lines (440 loc) · 15.3 KB
/
dynamic_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
# Configuration file for https://circleci.com/gh/angular/angular-cli
# Note: YAML anchors allow an object to be re-used, reducing duplication.
# The ampersand declares an alias for an object, then later the `<<: *name`
# syntax dereferences it.
# See http://blog.daemonl.com/2016/02/yaml.html
# To validate changes, use an online parser, eg.
# http://yaml-online-parser.appspot.com/
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.4.0
devinfra: angular/dev-infra@1.0.8
parameters:
snapshot_changed:
type: boolean
default: false
# Variables
## IMPORTANT
# Windows needs its own cache key because binaries in node_modules are different.
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
var_1: &cache_key v1-angular_devkit-16.13-{{ checksum "yarn.lock" }}
var_1_win: &cache_key_win v1-angular_devkit-win-16.13-{{ checksum "yarn.lock" }}
var_3: &default_nodeversion '16.13'
var_3_major: &default_nodeversion_major '16'
# The major version of node toolchains. See tools/toolchain_info.bzl
# NOTE: entries in this array may be repeated elsewhere in the file, find them before adding more
var_3_all_major: &all_nodeversion_major ['16', '18']
# Workspace initially persisted by the `setup` job, and then enhanced by `setup-and-build-win`.
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
# https://circleci.com/blog/deep-diving-into-circleci-workspaces/
var_4: &workspace_location .
# Filter to only release branches on a given job.
var_5_only_releases: &only_release_branches
filters:
branches:
only:
- main
- /\d+\.\d+\.x/
var_5_only_snapshots: &only_snapshot_branches
filters:
branches:
only:
- main
# This is needed to run this steps on Renovate PRs that amend the snapshots package.json
- /^pull\/.*/
var_6: &only_pull_requests
filters:
branches:
only:
- /pull\/\d+/
# All e2e test suites
var_7: &all_e2e_subsets ['npm', 'esbuild', 'yarn']
# Executor Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
executors:
action-executor:
parameters:
nodeversion:
type: string
default: *default_nodeversion
docker:
- image: cimg/node:<< parameters.nodeversion >>
working_directory: ~/ng
resource_class: small
bazel-executor:
parameters:
nodeversion:
type: string
default: *default_nodeversion
docker:
- image: cimg/node:<< parameters.nodeversion >>-browsers
working_directory: ~/ng
resource_class: xlarge
windows-executor:
# Same as https://circleci.com/orbs/registry/orb/circleci/windows, but named.
working_directory: ~/ng
resource_class: windows.large
shell: powershell.exe -ExecutionPolicy Bypass
machine:
# Contents of this image:
# https://circleci.com/docs/2.0/hello-world-windows/#software-pre-installed-in-the-windows-image
image: windows-server-2019-vs2019:stable
# Command Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
commands:
fail_fast:
steps:
- run:
name: 'Cancel workflow on fail'
shell: bash
when: on_fail
command: |
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${CIRCLE_TOKEN}"
initialize_env:
steps:
- run:
name: Initialize Environment
command: ./.circleci/env.sh
rebase_pr:
steps:
- devinfra/rebase-pr-on-target-branch:
base_revision: << pipeline.git.base_revision >>
head_revision: << pipeline.git.revision >>
rebase_pr_win:
steps:
- devinfra/rebase-pr-on-target-branch:
base_revision: << pipeline.git.base_revision >>
head_revision: << pipeline.git.revision >>
# Use `bash.exe` as Shell because the CircleCI-orb command is an
# included Bash script and expects Bash as shell.
shell: bash.exe
custom_attach_workspace:
description: Attach workspace at a predefined location
steps:
- attach_workspace:
at: *workspace_location
setup_windows:
steps:
- initialize_env
- run: nvm install 16.13
- run: nvm use 16.13
- run: npm install -g yarn@1.22.10 @bazel/bazelisk@${BAZELISK_VERSION}
- run: node --version
- run: yarn --version
setup_bazel_rbe:
parameters:
key:
type: env_var_name
default: CIRCLE_PROJECT_REPONAME
steps:
- run:
name: 'Copy Bazel RC'
shell: bash
command: |
# Conditionally, copy bazel configuration based on the current VM
# operating system running. We detect Windows by checking for `%AppData%`.
if [[ -n "${APPDATA}" ]]; then
cp "./.circleci/bazel.windows.rc" ".bazelrc.user";
else
cp "./.circleci/bazel.linux.rc" ".bazelrc.user";
fi
- devinfra/setup-bazel-remote-exec:
shell: bash
# Job definitions
jobs:
setup:
executor: action-executor
resource_class: medium
steps:
- checkout
- rebase_pr
- initialize_env
- restore_cache:
keys:
- *cache_key
- run: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
- persist_to_workspace:
root: *workspace_location
paths:
- ./*
- save_cache:
key: *cache_key
paths:
- ~/.cache/yarn
lint:
executor: action-executor
steps:
- custom_attach_workspace
- run: yarn lint
validate:
executor: action-executor
steps:
- custom_attach_workspace
- run:
name: Validate Commit Messages
command: >
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
yarn ng-dev commit-message validate-range <<pipeline.git.base_revision>> <<pipeline.git.revision>>
else
echo "This build is not over a PR, nothing to do."
fi
- run:
name: Validate Code Formatting
command: yarn -s ng-dev format changed <<pipeline.git.base_revision>> --check
- run:
name: Validate NgBot Configuration
command: yarn ng-dev ngbot verify
- run:
name: Validate Circular Dependencies
command: yarn ts-circular-deps:check
- run: yarn -s admin validate
- run: yarn -s check-tooling-setup
build:
executor: bazel-executor
steps:
- custom_attach_workspace
- setup_bazel_rbe
- run:
name: Bazel Build Packages
command: yarn bazel build //...
- fail_fast
test:
executor: bazel-executor
parameters:
nodeversion:
type: string
default: *default_nodeversion_major
steps:
- custom_attach_workspace
- setup_bazel_rbe
- when:
# The default nodeversion runs all *excluding* other versions
condition:
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
steps:
- run:
command: yarn bazel test --test_tag_filters=-node18,-node<< parameters.nodeversion >>-broken //packages/...
# This timeout provides time for the actual tests to timeout and report status
# instead of CircleCI stopping the job without test failure information.
no_output_timeout: 40m
- when:
# Non-default nodeversion runs only that specific nodeversion
condition:
not:
equal: [*default_nodeversion_major, << parameters.nodeversion >>]
steps:
- run:
command: yarn bazel test --test_tag_filters=node<< parameters.nodeversion >>,-node<< parameters.nodeversion >>-broken //packages/...
# This timeout provides time for the actual tests to timeout and report status
# instead of CircleCI stopping the job without test failure information.
no_output_timeout: 40m
- fail_fast
e2e-tests:
executor: bazel-executor
parallelism: 8
parameters:
nodeversion:
type: string
default: *default_nodeversion
snapshots:
type: boolean
default: false
subset:
type: enum
enum: *all_e2e_subsets
default: 'npm'
steps:
- custom_attach_workspace
- initialize_env
- setup_bazel_rbe
- run: mkdir /mnt/ramdisk/e2e
- run:
name: Execute CLI E2E Tests with << parameters.subset >>
command: yarn bazel test --define=E2E_TEMP=/mnt/ramdisk/e2e --define=E2E_SHARD_TOTAL=${CIRCLE_NODE_TOTAL} --define=E2E_SHARD_INDEX=${CIRCLE_NODE_INDEX} --config=e2e //tests/legacy-cli:e2e<<# parameters.snapshots >>.snapshots<</ parameters.snapshots >>.<< parameters.subset >>_node<< parameters.nodeversion >>
no_output_timeout: 40m
- store_artifacts:
path: dist/testlogs/tests/legacy-cli/e2e<<# parameters.snapshots >>.snapshots<</ parameters.snapshots >>.<< parameters.subset >>_node<< parameters.nodeversion >>
- store_test_results:
path: dist/testlogs/tests/legacy-cli/e2e<<# parameters.snapshots >>.snapshots<</ parameters.snapshots >>.<< parameters.subset >>_node<< parameters.nodeversion >>
- fail_fast
test-browsers:
executor: bazel-executor
steps:
- custom_attach_workspace
- initialize_env
- setup_bazel_rbe
- run:
name: Initialize Saucelabs
command: setSecretVar SAUCE_ACCESS_KEY $(echo $SAUCE_ACCESS_KEY | rev)
- run:
name: Start Saucelabs Tunnel
command: ./scripts/saucelabs/start-tunnel.sh
background: true
# Waits for the Saucelabs tunnel to be ready. This ensures that we don't run tests
# too early without Saucelabs not being ready.
- run: ./scripts/saucelabs/wait-for-tunnel.sh
- run:
name: E2E Saucelabs Tests
command: yarn bazel test --config=saucelabs //tests/legacy-cli:e2e.saucelabs
- run: ./scripts/saucelabs/stop-tunnel.sh
- store_artifacts:
path: dist/testlogs/tests/legacy-cli/e2e.saucelabs
- store_test_results:
path: dist/testlogs/tests/legacy-cli/e2e.saucelabs
- fail_fast
snapshot_publish:
executor: action-executor
resource_class: medium
steps:
- custom_attach_workspace
- run:
name: Deployment to Snapshot
command: yarn admin snapshots --verbose
- fail_fast
publish_artifacts:
executor: action-executor
resource_class: medium
environment:
steps:
- custom_attach_workspace
- run:
name: Create artifacts for packages
command: yarn ng-dev release build
- run:
name: Copy tarballs to folder
command: |
mkdir -p dist/artifacts/
cp dist/releases/*.tgz dist/artifacts/
- store_artifacts:
path: dist/artifacts/
destination: angular
# Windows jobs
e2e-cli-win:
executor: windows-executor
parallelism: 12
steps:
- checkout
- rebase_pr_win
- setup_windows
- setup_bazel_rbe
- restore_cache:
keys:
- *cache_key_win
- run:
# We use Arsenal Image Mounter (AIM) instead of ImDisk because of: https://github.com/nodejs/node/issues/6861
# Useful resources for AIM: http://reboot.pro/index.php?showtopic=22068
name: 'Arsenal Image Mounter (RAM Disk)'
command: |
pwsh ./.circleci/win-ram-disk.ps1
- run: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
- save_cache:
key: *cache_key_win
paths:
- ~/.cache/yarn
# Path where Arsenal Image Mounter files are downloaded.
# Must match path in .circleci/win-ram-disk.ps1
- ./aim
- run:
name: Execute E2E Tests
environment:
# Required by `yarn ng-dev`
# See https://github.com/angular/angular/issues/46858
PWD: .
command: |
mkdir X:/ramdisk/e2e
bazel test --define=E2E_TEMP=X:/ramdisk/e2e --define=E2E_SHARD_TOTAL=$env:CIRCLE_NODE_TOTAL --define=E2E_SHARD_INDEX=$env:CIRCLE_NODE_INDEX --config=e2e //tests/legacy-cli:e2e.npm_node16
# This timeout provides time for the actual tests to timeout and report status
# instead of CircleCI stopping the job without test failure information.
no_output_timeout: 40m
- fail_fast
- store_artifacts:
path: dist/testlogs/tests/legacy-cli/e2e.npm_node16
- store_test_results:
path: dist/testlogs/tests/legacy-cli/e2e.npm_node16
workflows:
version: 2
default_workflow:
jobs:
# Linux jobs
- setup
- lint:
requires:
- setup
- validate:
requires:
- setup
# These jobs only really depend on Setup, but the build job is very quick to run (~35s) and
# will catch any build errors before proceeding to the more lengthy and resource intensive
- test:
name: test-node<< matrix.nodeversion >>
matrix:
parameters:
# Disable running this on Node.js 18 for now. This causes failures when using RBE.
# Example: `GLIBC_2.28' not found.
# Likely this is caused by outdated Ubuntu image https://github.com/angular/dev-infra/blob/main/bazel/remote-execution/BUILD.bazel#L21
nodeversion: ['16']
requires:
- build
# Bazel jobs
- build:
requires:
- setup
- e2e-tests:
name: e2e-cli-<< matrix.subset >>
nodeversion: *default_nodeversion_major
matrix:
parameters:
subset: *all_e2e_subsets
filters:
branches:
ignore:
- main
- /\d+\.\d+\.x/
requires:
- build
- e2e-tests:
name: e2e-cli-node-<<matrix.nodeversion>>-<< matrix.subset >>
matrix:
alias: e2e-cli
parameters:
nodeversion: *all_nodeversion_major
subset: *all_e2e_subsets
requires:
- build
<<: *only_release_branches
- e2e-tests:
name: e2e-snapshots-<< matrix.subset >>
nodeversion: *default_nodeversion_major
matrix:
parameters:
subset: *all_e2e_subsets
snapshots: true
pre-steps:
- when:
# Don't run snapshot E2E's unless it's on the main branch or the snapshots file has been updated.
condition:
and:
- not:
equal: [main, << pipeline.git.branch >>]
- not: << pipeline.parameters.snapshot_changed >>
steps:
- run: circleci-agent step halt
requires:
- build
<<: *only_snapshot_branches
- test-browsers:
requires:
- build
# Windows jobs
- e2e-cli-win:
<<: *only_release_branches
# Publish jobs
- snapshot_publish:
<<: *only_release_branches
requires:
- setup
- e2e-cli
- publish_artifacts:
<<: *only_pull_requests
requires:
- build