77# To validate changes, use an online parser, eg.
88# http://yaml-online-parser.appspot.com/
99
10- # Variables
11-
12- # # IMPORTANT
13- # If you change the `docker_image` version, also change the `cache_key` suffix and the version of
14- # `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file.
15- var_1 : &docker_image angular/ngcontainer:0.7.0
16- var_2 : &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.7.0
10+ # Note that the browser docker image comes with Chrome and Firefox preinstalled. This is just
11+ # needed for jobs that run tests without Bazel. Bazel runs tests with browsers that will be
12+ # fetched by the Webtesting rules. Therefore for jobs that run tests with Bazel, we don't need a
13+ # docker image with browsers pre-installed.
14+ # **NOTE**: If you change the version of the docker images, also change the `cache_key` suffix.
15+ var_1 : &default_docker_image circleci/node:10.12
16+ var_2 : &browsers_docker_image circleci/node:10.12-browsers
17+ var_3 : &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-10.12
1718
1819# Define common ENV vars
19- var_3 : &define_env_vars
20+ var_4 : &define_env_vars
2021 run :
2122 name : Define environment variables
2223 command : ./.circleci/env.sh
2324
24- # See remote cache documentation in /docs/BAZEL.md
25- var_4 : &setup-bazel-remote-cache
26- run :
27- name : Start up bazel remote cache proxy
28- command : ~/bazel-remote-proxy -backend circleci://
29- background : true
30-
3125var_5 : &setup_bazel_remote_execution
3226 run :
3327 name : " Setup bazel RBE remote execution"
3428 command : openssl aes-256-cbc -d -in .circleci/gcp_token -k "$CI_REPO_NAME" -out /home/circleci/.gcp_credentials && echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV && sudo bash -c "cat .circleci/rbe-bazel.rc >> /etc/bazel.bazelrc"
3529
30+ # Settings common to each job
31+ var_6 : &job_defaults
32+ working_directory : ~/ng
33+ docker :
34+ - image : *default_docker_image
35+
3636var_7 : &start-xvfb
3737 run :
3838 name : Running X virtual framebuffer
3939 command : Xvfb :99 -screen 0 1280x1024x24
4040 background : true
4141
42- # Settings common to each job
43- anchor_1 : &job_defaults
44- working_directory : ~/ng
45- docker :
46- - image : *docker_image
47-
4842# After checkout, rebase on top of master.
4943# Similar to travis behavior, but not quite the same.
5044# See https://discuss.circleci.com/t/1662
51- anchor_2 : &post_checkout
45+ var_8 : &post_checkout
5246 post : git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
5347
48+ var_9 : &yarn_install
49+ run :
50+ name : Running Yarn install
51+ command : yarn install --frozen-lockfile --non-interactive
52+
53+ var_10 : &setup_circleci_bazel_config
54+ run :
55+ name : Setting up CircleCI bazel configuration
56+ command : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
57+
5458version : 2
5559jobs :
5660 lint :
@@ -59,21 +63,18 @@ jobs:
5963 steps :
6064 - checkout :
6165 << : *post_checkout
66+ - restore_cache :
67+ key : *cache_key
6268 - *define_env_vars
63- - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
69+ - *setup_circleci_bazel_config
70+ - *yarn_install
6471
65- # Check BUILD.bazel formatting before we have a node_modules directory
66- # Then we don't need any exclude pattern to avoid checking those files
6772 - run : ' yarn buildifier -mode=check ||
6873 (echo "BUILD files not formatted. Please run '' yarn buildifier'' " ; exit 1)'
6974 # Run the skylark linter to check our Bazel rules
7075 - run : ' yarn skylint ||
7176 (echo -e "\n.bzl files have lint errors. Please run '' yarn skylint'' "; exit 1)'
7277
73- - restore_cache :
74- key : *cache_key
75-
76- - run : yarn install --frozen-lockfile --non-interactive
7778 - run : ./node_modules/.bin/gulp lint
7879
7980 test :
@@ -82,17 +83,18 @@ jobs:
8283 steps :
8384 - checkout :
8485 << : *post_checkout
86+ - restore_cache :
87+ key : *cache_key
8588 - *define_env_vars
86- - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
89+ - *setup_circleci_bazel_config
90+ - *yarn_install
8791
88- - run : bazel info release
89- - run : bazel run @nodejs//:yarn
9092 # Setup remote execution and run RBE-compatible tests.
9193 - *setup_bazel_remote_execution
92- - run : bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-local
94+ - run : yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-local
9395 # Now run RBE incompatible tests locally.
9496 - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
95- - run : bazel test //... --build_tag_filters=-ivy-only,local --test_tag_filters=-ivy-only,local
97+ - run : yarn bazel test //... --build_tag_filters=-ivy-only,local --test_tag_filters=-ivy-only,local
9698
9799 # CircleCI will allow us to go back and view/download these artifacts from past builds.
98100 # Also we can use a service like https://buildsize.org/ to automatically track binary size of these artifacts.
@@ -126,11 +128,13 @@ jobs:
126128 steps :
127129 - checkout :
128130 << : *post_checkout
131+ - restore_cache :
132+ key : *cache_key
129133 - *define_env_vars
130- - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
131-
132- - run : bazel run @yarn//:yarn
134+ - *setup_circleci_bazel_config
135+ - *yarn_install
133136 - *setup_bazel_remote_execution
137+
134138 - run : yarn test-ivy-jit //...
135139
136140 test_ivy_aot :
@@ -139,22 +143,27 @@ jobs:
139143 steps :
140144 - checkout :
141145 << : *post_checkout
146+ - restore_cache :
147+ key : *cache_key
142148 - *define_env_vars
143- - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
144-
145- - run : bazel run @yarn//:yarn
149+ - *setup_circleci_bazel_config
150+ - *yarn_install
146151 - *setup_bazel_remote_execution
152+
147153 - run : yarn test-ivy-aot //...
148154
149155 test_aio :
150156 << : *job_defaults
157+ docker :
158+ # Needed because the AIO tests and the PWA score test depend on Chrome being available.
159+ - image : *browsers_docker_image
151160 steps :
152161 - checkout :
153162 << : *post_checkout
154- - *define_env_vars
155- - *start-xvfb
156163 - restore_cache :
157164 key : *cache_key
165+ - *define_env_vars
166+ - *start-xvfb
158167 # Build aio
159168 - run : yarn --cwd aio build --progress=false
160169 # Lint the code
@@ -174,28 +183,34 @@ jobs:
174183
175184 deploy_aio :
176185 << : *job_defaults
186+ docker :
187+ # Needed because before deploying the deploy-production script runs the PWA score tests.
188+ - image : *browsers_docker_image
177189 steps :
178190 - checkout :
179191 << : *post_checkout
180- - *define_env_vars
181- - *start-xvfb
182192 - restore_cache :
183193 key : *cache_key
194+ - *define_env_vars
195+ - *start-xvfb
184196 # Deploy angular.io to production (if necessary)
185197 - run : setPublicVar CI_STABLE_BRANCH "$(npm info @angular/core dist-tags.latest | sed -r 's/^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$/\1.x/')"
186198 - run : yarn --cwd aio deploy-production
187199
188200 test_aio_local :
189201 << : *job_defaults
202+ docker :
203+ # Needed because the AIO tests and the PWA score test depend on Chrome being available.
204+ - image : *browsers_docker_image
190205 steps :
191206 - checkout :
192207 << : *post_checkout
193- - *define_env_vars
194- - *start-xvfb
195- - attach_workspace :
196- at : dist
197208 - restore_cache :
198209 key : *cache_key
210+ - attach_workspace :
211+ at : dist
212+ - *define_env_vars
213+ - *start-xvfb
199214 # Build aio (with local Angular packages)
200215 - run : yarn --cwd aio build-local --progress=false
201216 # Run PWA-score tests
@@ -211,11 +226,11 @@ jobs:
211226 steps :
212227 - checkout :
213228 << : *post_checkout
214- - *define_env_vars
215- - attach_workspace :
216- at : dist
217229 - restore_cache :
218230 key : *cache_key
231+ - attach_workspace :
232+ at : dist
233+ - *define_env_vars
219234 # Install
220235 - run : yarn --cwd aio install --frozen-lockfile --non-interactive
221236 - run : yarn --cwd aio extract-cli-command-docs
@@ -225,35 +240,41 @@ jobs:
225240
226241 test_docs_examples_0 :
227242 << : *job_defaults
243+ docker :
244+ # Needed because the example e2e tests depend on Chrome.
245+ - image : *browsers_docker_image
228246 steps :
229247 - checkout :
230248 << : *post_checkout
231- - *define_env_vars
232- - *start-xvfb
233- - attach_workspace :
234- at : dist
235249 - restore_cache :
236250 key : *cache_key
251+ - attach_workspace :
252+ at : dist
253+ - *define_env_vars
254+ - *start-xvfb
237255 # Install root
238- - run : yarn install --frozen-lockfile --non-interactive
256+ - *yarn_install
239257 # Install aio
240258 - run : yarn --cwd aio install --frozen-lockfile --non-interactive
241259 # Run examples tests
242260 - run : yarn --cwd aio example-e2e --setup --local --shard=0/2
243261
244262 test_docs_examples_1 :
245263 << : *job_defaults
264+ docker :
265+ # Needed because the example e2e tests depend on Chrome.
266+ - image : *browsers_docker_image
246267 steps :
247268 - checkout :
248269 << : *post_checkout
249- - *define_env_vars
250- - *start-xvfb
251- - attach_workspace :
252- at : dist
253270 - restore_cache :
254271 key : *cache_key
272+ - attach_workspace :
273+ at : dist
274+ - *define_env_vars
275+ - *start-xvfb
255276 # Install root
256- - run : yarn install --frozen-lockfile --non-interactive
277+ - *yarn_install
257278 # Install aio
258279 - run : yarn --cwd aio install --frozen-lockfile --non-interactive
259280 # Run examples tests
@@ -267,10 +288,10 @@ jobs:
267288 steps :
268289 - checkout :
269290 << : *post_checkout
270- - *define_env_vars
271291 - restore_cache :
272292 key : *cache_key
273- - run : yarn install --frozen-lockfile --non-interactive
293+ - *define_env_vars
294+ - *yarn_install
274295 - run : ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CI_PULL_REQUEST $CI_COMMIT
275296 - store_artifacts :
276297 path : *aio_preview_artifact_path
@@ -281,13 +302,16 @@ jobs:
281302 # This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`.
282303 test_aio_preview :
283304 << : *job_defaults
305+ docker :
306+ # Needed because the test-preview script runs e2e tests and the PWA score test with Chrome.
307+ - image : *browsers_docker_image
284308 steps :
285309 - checkout :
286310 << : *post_checkout
287- - *define_env_vars
288- - *start-xvfb
289311 - restore_cache :
290312 key : *cache_key
313+ - *define_env_vars
314+ - *start-xvfb
291315 - run : yarn install --cwd aio --frozen-lockfile --non-interactive
292316 - run :
293317 name : Wait for preview and run tests
@@ -306,10 +330,13 @@ jobs:
306330 steps :
307331 - checkout :
308332 << : *post_checkout
333+ - restore_cache :
334+ key : *cache_key
309335 - *define_env_vars
310- - run : sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
311- - run : bazel run @nodejs//:yarn
336+ - *setup_circleci_bazel_config
337+ - *yarn_install
312338 - *setup_bazel_remote_execution
339+
313340 - run : scripts/build-packages-dist.sh
314341
315342 # Save the npm packages from //packages/... for other workflow jobs to read
@@ -329,17 +356,22 @@ jobs:
329356 # See comments inside the integration/run_tests.sh script.
330357 integration_test :
331358 << : *job_defaults
359+ docker :
360+ # Needed because the integration tests expect Chrome to be installed (e.g cli-hello-world)
361+ - image : *browsers_docker_image
332362 # Note: we run Bazel in one of the integration tests, and it can consume >2G
333363 # of memory. Together with the system under test, this can exhaust the RAM
334364 # on a 4G worker so we use a larger machine here too.
335365 resource_class : xlarge
336366 steps :
337367 - checkout :
338368 << : *post_checkout
339- - *define_env_vars
340- - *start-xvfb
369+ - restore_cache :
370+ key : *cache_key
341371 - attach_workspace :
342372 at : dist
373+ - *define_env_vars
374+ - *start-xvfb
343375 - run : ./integration/run_tests.sh
344376
345377 # This job updates the content of repos like github.com/angular/core-builds
@@ -373,13 +405,17 @@ jobs:
373405
374406 aio_monitoring :
375407 << : *job_defaults
408+ docker :
409+ # This job needs Chrome to be globally installed because the tests run with Protractor
410+ # which does not load the browser through the Bazel webtesting rules.
411+ - image : *browsers_docker_image
376412 steps :
377413 - checkout :
378414 << : *post_checkout
379- - *define_env_vars
380- - *start-xvfb
381415 - restore_cache :
382416 key : *cache_key
417+ - *define_env_vars
418+ - *start-xvfb
383419 - run :
384420 name : Run tests against the deployed apps
385421 command : ./aio/scripts/test-production.sh $CI_AIO_MIN_PWA_SCORE
0 commit comments