@@ -37,9 +37,89 @@ executors:
37
37
- image : google/cloud-sdk:alpine@sha256:7d0cae28cb282b76f2d9babe278c63c910d54f0cceca7a65fdf6806e2b43882e
38
38
39
39
40
+ # Filter Definitions
41
+
42
+ # Filter to run a job on all branches and any `v1.X.Y(-Z)` tags.
43
+ # Since the jobs need to run on tagged builds too, a `tags` section has to be explicitly specified.
44
+ # (The `branches` section could be omitted, since it defaults to all branches - just being explicit
45
+ # here).
46
+ # See also https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag.
47
+ var-filter-run-always : &run-always
48
+ filters :
49
+ branches :
50
+ only : /.*/
51
+ tags :
52
+ only : /v1\.\d+\.\d.*/
53
+
54
+ # Filter to run a job when code/docs might need to be deployed - i.e. on tagged builds and on builds
55
+ # for master and `v1.*.x` branches.
56
+ # (Further checks are needed to determine whether a deployment is actually needed, but these are not
57
+ # possible via filters.)
58
+ var-filter-run-on-tags-and-master-and-version-branches : &run-on-tags-and-master-and-version-branches
59
+ filters :
60
+ branches :
61
+ only :
62
+ - master
63
+ - /v1\.\d+\.x/
64
+ tags :
65
+ only : /v1\.\d+\.\d.*/
66
+
67
+ # Filter to run a job when docs might need to be deployed - i.e. on builds for `v1.*.x` branches,
68
+ # which might correspond to the stable branch.
69
+ # (Further checks are needed to determine whether a deployment is actually needed, but these are not
70
+ # possible via filters.)
71
+ var-filter-run-on-version-branches : &run-on-version-branches
72
+ filters :
73
+ branches :
74
+ only :
75
+ - /v1\.\d+\.x/
76
+ tags :
77
+ ignore : /.*/
78
+
79
+
40
80
# Command Definitions
41
81
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
42
82
commands :
83
+ skip_for_pr_and_fork_builds :
84
+ description : Skip a job for pull requests and fork builds
85
+ steps :
86
+ - run :
87
+ name : Skip this job for pull requests and fork builds
88
+ # Note: Using `CIRCLE_*` env variables (instead of those defined in `env.sh` so that this
89
+ # step can be run before `init_environment`.
90
+ command : >
91
+ if [[ -n "$CIRCLE_PR_NUMBER" ]] ||
92
+ [[ "$CIRCLE_PROJECT_USERNAME" != "angular" ]] ||
93
+ [[ "$CIRCLE_PROJECT_REPONAME" != "angular.js" ]]; then
94
+ echo "Skipping this job, because this is either a pull request or a fork build."
95
+ circleci step halt
96
+ fi
97
+
98
+ skip_for_non_stable_branch :
99
+ description : Skip a job on any branch other than the stable one
100
+ steps :
101
+ - run :
102
+ name : Skip this job if this is not the stable branch
103
+ command : >
104
+ if [[ "$DIST_TAG" != "latest" ]]; then
105
+ echo "Skipping deployment, because this is not the stable branch."
106
+ circleci step halt
107
+ fi
108
+
109
+ skip_for_non_tag_or_master_or_stable_branch :
110
+ description : Skip a job if this is neither a tag nor the master or stable branch
111
+ steps :
112
+ - run :
113
+ name : Skip this job if this is neither a tag nor the master or stable branch
114
+ command : >
115
+ if [[ "$CI_GIT_TAG" == "false" ]] &&
116
+ [[ "$CI_BRANCH" != "master" ]] &&
117
+ [[ "$DIST_TAG" != "latest" ]]; then
118
+ echo "Skipping this job, because this is neither a tag nor the master or stable branch."
119
+ circleci step halt
120
+ fi
121
+
122
+
43
123
custom_attach_workspace :
44
124
description : Attach workspace at a predefined location
45
125
steps :
@@ -112,7 +192,6 @@ commands:
112
192
name : Stopping Saucelabs tunnel service
113
193
command : ./lib/saucelabs/sauce-service.sh stop
114
194
115
-
116
195
run_e2e_tests :
117
196
parameters :
118
197
specs :
@@ -255,6 +334,7 @@ jobs:
255
334
executor :
256
335
name : default-executor
257
336
steps :
337
+ - skip_for_pr_and_fork_builds
258
338
- custom_attach_workspace
259
339
- init_environment
260
340
- run : yarn grunt prepareDeploy
@@ -264,23 +344,20 @@ jobs:
264
344
paths :
265
345
- ./ng/deploy
266
346
267
- deploy-docs :
268
- executor :
269
- name : default-executor
270
- steps :
271
- - custom_attach_workspace
272
- - init_environment
273
- - run : yarn grunt prepareDeploy
274
- # Install dependencies for Firebase functions to prevent parsing errors during deployment
275
- # See https://github.com/angular/angular.js/pull/16453
276
- - run : yarn -cwd ~/ng/scripts/docs.angularjs.org-firebase/functions
277
- - run : yarn firebase deploy --token "$FIREBASE_TOKEN" --only hosting
278
-
347
+ # The `deploy-code` job should only run when all of these conditions are true for the build:
348
+ # - It is for the `angular/angular.js` repository (not a fork).
349
+ # - It is not for a pull request.
350
+ # - It is for a tag or the master branch or the stable branch(*).
351
+ #
352
+ # *: The stable branch is the one that has the value `latest` in `package.json > distTag`.
279
353
deploy-code :
280
354
executor :
281
355
name : cloud-sdk
282
356
steps :
357
+ - skip_for_pr_and_fork_builds
283
358
- custom_attach_workspace
359
+ - init_environment
360
+ - skip_for_non_tag_or_master_or_stable_branch
284
361
- run : ls ~/ng/deploy/code
285
362
- run :
286
363
name : Authenticate and configure Docker
@@ -292,44 +369,70 @@ jobs:
292
369
command : |
293
370
gsutil -m rsync -r ~/ng/deploy/code gs://code-angularjs-org-338b8.appspot.com
294
371
372
+ # The `deploy-docs` job should only run when all of these conditions are true for the build:
373
+ # - It is for the `angular/angular.js` repository (not a fork).
374
+ # - It is not for a pull request.
375
+ # - It is for the stable branch(*).
376
+ #
377
+ # *: The stable branch is the one that has the value `latest` in `package.json > distTag`.
378
+ deploy-docs :
379
+ executor :
380
+ name : default-executor
381
+ steps :
382
+ - skip_for_pr_and_fork_builds
383
+ - custom_attach_workspace
384
+ - init_environment
385
+ - skip_for_non_stable_branch
386
+ - run : yarn grunt prepareDeploy
387
+ # Install dependencies for Firebase functions to prevent parsing errors during deployment
388
+ # See https://github.com/angular/angular.js/pull/16453
389
+ - run : yarn -cwd ~/ng/scripts/docs.angularjs.org-firebase/functions
390
+ - run : yarn firebase deploy --token "$FIREBASE_TOKEN" --only hosting
391
+
295
392
workflows :
296
393
version : 2
297
394
default_workflow :
298
395
jobs :
299
- - setup
396
+ - setup :
397
+ << : *run-always
300
398
- lint :
399
+ << : *run-always
301
400
requires :
302
401
- setup
303
402
- unit-test :
403
+ << : *run-always
304
404
requires :
305
405
- setup
306
406
- unit-test-jquery :
407
+ << : *run-always
307
408
requires :
308
409
- setup
309
410
- e2e-test-1 :
411
+ << : *run-always
310
412
requires :
311
413
- setup
312
414
- e2e-test-2a :
415
+ << : *run-always
313
416
requires :
314
417
- setup
315
418
- e2e-test-2b :
419
+ << : *run-always
316
420
requires :
317
421
- setup
318
422
- e2e-test-jquery-1 :
423
+ << : *run-always
319
424
requires :
320
425
- setup
321
426
- e2e-test-jquery-2a :
427
+ << : *run-always
322
428
requires :
323
429
- setup
324
430
- e2e-test-jquery-2b :
431
+ << : *run-always
325
432
requires :
326
433
- setup
327
434
- prepare-deployment :
328
- filters :
329
- branches :
330
- only :
331
- - master
332
- - latest
435
+ << : *run-on-tags-and-master-and-version-branches
333
436
requires :
334
437
- setup
335
438
- unit-test
@@ -340,19 +443,11 @@ workflows:
340
443
- e2e-test-jquery-1
341
444
- e2e-test-jquery-2a
342
445
- e2e-test-jquery-2b
343
-
344
- - deploy-docs :
345
- filters :
346
- branches :
347
- only :
348
- - latest
446
+ - deploy-code :
447
+ << : *run-on-tags-and-master-and-version-branches
349
448
requires :
350
449
- prepare-deployment
351
- - deploy-code :
352
- filters :
353
- branches :
354
- only :
355
- - master
356
- - latest
450
+ - deploy-docs :
451
+ << : *run-on-version-branches
357
452
requires :
358
453
- prepare-deployment
0 commit comments