Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ec2e14b

Browse files

File tree

2 files changed

+127
-33
lines changed

2 files changed

+127
-33
lines changed

.circleci/config.yml

Lines changed: 126 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,89 @@ executors:
3737
- image: google/cloud-sdk:alpine@sha256:7d0cae28cb282b76f2d9babe278c63c910d54f0cceca7a65fdf6806e2b43882e
3838

3939

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+
4080
# Command Definitions
4181
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
4282
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+
43123
custom_attach_workspace:
44124
description: Attach workspace at a predefined location
45125
steps:
@@ -112,7 +192,6 @@ commands:
112192
name: Stopping Saucelabs tunnel service
113193
command: ./lib/saucelabs/sauce-service.sh stop
114194

115-
116195
run_e2e_tests:
117196
parameters:
118197
specs:
@@ -255,6 +334,7 @@ jobs:
255334
executor:
256335
name: default-executor
257336
steps:
337+
- skip_for_pr_and_fork_builds
258338
- custom_attach_workspace
259339
- init_environment
260340
- run: yarn grunt prepareDeploy
@@ -264,23 +344,20 @@ jobs:
264344
paths:
265345
- ./ng/deploy
266346

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`.
279353
deploy-code:
280354
executor:
281355
name: cloud-sdk
282356
steps:
357+
- skip_for_pr_and_fork_builds
283358
- custom_attach_workspace
359+
- init_environment
360+
- skip_for_non_tag_or_master_or_stable_branch
284361
- run: ls ~/ng/deploy/code
285362
- run:
286363
name: Authenticate and configure Docker
@@ -292,44 +369,70 @@ jobs:
292369
command: |
293370
gsutil -m rsync -r ~/ng/deploy/code gs://code-angularjs-org-338b8.appspot.com
294371
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+
295392
workflows:
296393
version: 2
297394
default_workflow:
298395
jobs:
299-
- setup
396+
- setup:
397+
<<: *run-always
300398
- lint:
399+
<<: *run-always
301400
requires:
302401
- setup
303402
- unit-test:
403+
<<: *run-always
304404
requires:
305405
- setup
306406
- unit-test-jquery:
407+
<<: *run-always
307408
requires:
308409
- setup
309410
- e2e-test-1:
411+
<<: *run-always
310412
requires:
311413
- setup
312414
- e2e-test-2a:
415+
<<: *run-always
313416
requires:
314417
- setup
315418
- e2e-test-2b:
419+
<<: *run-always
316420
requires:
317421
- setup
318422
- e2e-test-jquery-1:
423+
<<: *run-always
319424
requires:
320425
- setup
321426
- e2e-test-jquery-2a:
427+
<<: *run-always
322428
requires:
323429
- setup
324430
- e2e-test-jquery-2b:
431+
<<: *run-always
325432
requires:
326433
- setup
327434
- prepare-deployment:
328-
filters:
329-
branches:
330-
only:
331-
- master
332-
- latest
435+
<<: *run-on-tags-and-master-and-version-branches
333436
requires:
334437
- setup
335438
- unit-test
@@ -340,19 +443,11 @@ workflows:
340443
- e2e-test-jquery-1
341444
- e2e-test-jquery-2a
342445
- 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
349448
requires:
350449
- prepare-deployment
351-
- deploy-code:
352-
filters:
353-
branches:
354-
only:
355-
- master
356-
- latest
450+
- deploy-docs:
451+
<<: *run-on-version-branches
357452
requires:
358453
- prepare-deployment

.circleci/env.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ setPublicVar PROJECT_ROOT "$projectDir";
1919
setPublicVar CI_BRANCH "$CIRCLE_BRANCH";
2020
setPublicVar CI_BUILD_URL "$CIRCLE_BUILD_URL";
2121
setPublicVar CI_COMMIT "$CIRCLE_SHA1";
22-
# `CI_COMMIT_RANGE` is only used on push builds (a.k.a. non-PR, non-scheduled builds and rerun
23-
# workflows of such builds).
2422
setPublicVar CI_GIT_BASE_REVISION "${CIRCLE_GIT_BASE_REVISION}";
2523
setPublicVar CI_GIT_REVISION "${CIRCLE_GIT_REVISION}";
24+
setPublicVar CI_GIT_TAG "${CIRCLE_TAG:-false}";
2625
setPublicVar CI_COMMIT_RANGE "$CIRCLE_GIT_BASE_REVISION..$CIRCLE_GIT_REVISION";
2726
setPublicVar CI_PULL_REQUEST "${CIRCLE_PR_NUMBER:-false}";
2827
setPublicVar CI_REPO_NAME "$CIRCLE_PROJECT_REPONAME";

0 commit comments

Comments
 (0)