Skip to content

Commit b32fab8

Browse files
devversionandrewseguin
authored andcommitted
build: update yarn to v1.16.0 (#16260)
Currently our version of Yarn is installed through the "angular/ngcontainer" docker image. This is problematic because in order to be able to update Yarn, we always need to update the docker image to a version that comes with the desired Yarn version. Sometimes there is no docker image with the desired latest Yarn version, and therefore we cannot easily update the Yarn version. Additionally the latest Yarn versions contain various fixes for debugging timeout issues and also have improved logic for restoring existing `node_modules`. This is **essential** to take advantage of the CircleCI caching mechanism.
1 parent cadf1b4 commit b32fab8

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

.circleci/config.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,41 @@ var_8: &gcp_decrypt_token "angular"
5454
# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because
5555
# CircleCI automatically discards the cache if the checksum of the lock file has changed.
5656
var_9: &yarn_install
57-
run: yarn install --frozen-lockfile --non-interactive
57+
run:
58+
name: "Installing project dependencies"
59+
command: yarn install --frozen-lockfile --non-interactive
60+
61+
# Anchor that can be used to download and install Yarn globally in the bash environment.
62+
var_10: &yarn_download
63+
run:
64+
name: "Downloading and installing Yarn"
65+
command: |
66+
touch $BASH_ENV
67+
curl -o- -L https://yarnpkg.com/install.sh | PROFILE=$BASH_ENV bash -s -- --version "1.16.0"
5868
5969
# Copies the Bazel config which is specifically for CircleCI to a location where Bazel picks it
6070
# up and merges it with the project-wide bazel configuration (tools/bazel.rc)
61-
var_10: &copy_bazel_config
71+
var_11: &copy_bazel_config
6272
# Set up the CircleCI specific bazel configuration.
6373
run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc
6474

6575
# Sets up a different Docker image that includes a moe recent Firefox version which
6676
# is needed for headless testing.
67-
var_11: &docker-firefox-image
77+
var_12: &docker-firefox-image
6878
# TODO(devversion): Temporarily use a image that includes Firefox 62 because the
6979
# ngcontainer image does include an old Firefox version that does not support headless.
7080
- image: circleci/node:11.4.0-browsers
7181

7282
# Attaches the release output which has been stored in the workspace to the current job.
7383
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
74-
var_12: &attach_release_output
84+
var_13: &attach_release_output
7585
attach_workspace:
7686
at: dist/
7787

7888
# Branch filter that we can specify for jobs that should only run on publish branches. This filter
7989
# is used to ensure that not all upstream branches will be published as Github builds
8090
# (e.g. revert branches, feature branches)
81-
var_13: &publish_branches_filter
91+
var_14: &publish_branches_filter
8292
branches:
8393
only:
8494
- master
@@ -92,15 +102,15 @@ var_13: &publish_branches_filter
92102
# In order to reduce duplication we use a YAML anchor that just always excludes the "_presubmit"
93103
# branch. We don't want to run Circle for the temporary "_presubmit" branch which is reserved
94104
# for the caretaker.
95-
var_14: &ignore_presubmit_branch_filter
105+
var_15: &ignore_presubmit_branch_filter
96106
branches:
97107
ignore:
98108
- "_presubmit"
99109
- "ivy-2019"
100110

101111
# Runs a script that sets up the Bazel remote execution. This will be used by jobs that run
102112
# Bazel primarily and should benefit from remote caching and execution.
103-
var_15: &setup_bazel_remote_execution
113+
var_16: &setup_bazel_remote_execution
104114
run:
105115
name: "Setup bazel RBE remote execution"
106116
command: ./scripts/circleci/bazel/setup-remote-execution.sh
@@ -180,6 +190,7 @@ jobs:
180190
steps:
181191
- *checkout_code
182192
- *restore_cache
193+
- *yarn_download
183194
- *yarn_install
184195

185196
- run: ./scripts/circleci/run-local-browser-tests.sh
@@ -197,6 +208,7 @@ jobs:
197208
steps:
198209
- *checkout_code
199210
- *restore_cache
211+
- *yarn_download
200212
- *yarn_install
201213

202214
- run: ./scripts/circleci/run-browserstack-tests.sh
@@ -217,6 +229,7 @@ jobs:
217229
steps:
218230
- *checkout_code
219231
- *restore_cache
232+
- *yarn_download
220233
- *yarn_install
221234

222235
- run: ./scripts/circleci/run-saucelabs-tests.sh
@@ -230,6 +243,7 @@ jobs:
230243
steps:
231244
- *checkout_code
232245
- *restore_cache
246+
- *yarn_download
233247
- *yarn_install
234248
- *attach_release_output
235249

@@ -244,6 +258,7 @@ jobs:
244258
steps:
245259
- *checkout_code
246260
- *restore_cache
261+
- *yarn_download
247262
- *yarn_install
248263

249264
- run: yarn gulp ci:prerender
@@ -256,6 +271,7 @@ jobs:
256271
steps:
257272
- *checkout_code
258273
- *restore_cache
274+
- *yarn_download
259275
- *yarn_install
260276

261277
- run: ./scripts/circleci/lint-bazel-files.sh
@@ -271,6 +287,7 @@ jobs:
271287
steps:
272288
- *checkout_code
273289
- *restore_cache
290+
- *yarn_download
274291
- *yarn_install
275292

276293
- run: yarn gulp ci:build-release-packages
@@ -342,6 +359,7 @@ jobs:
342359
steps:
343360
- *checkout_code
344361
- *restore_cache
362+
- *yarn_download
345363
- *yarn_install
346364

347365
- run: node ./scripts/circleci/setup-angular-snapshots.js
@@ -362,6 +380,7 @@ jobs:
362380
- *restore_cache
363381
- *copy_bazel_config
364382
- *setup_bazel_remote_execution
383+
- *yarn_download
365384
- *yarn_install
366385

367386
# Setup Angular ivy snapshots built with ngtsc but locked to a specific tag. We
@@ -392,6 +411,7 @@ jobs:
392411
- *restore_cache
393412
- *copy_bazel_config
394413
- *setup_bazel_remote_execution
414+
- *yarn_download
395415
- *yarn_install
396416

397417
# Setup Angular ivy snapshots built with ngtsc.

WORKSPACE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ check_bazel_version("0.18.0")
2525
node_repositories(
2626
# For deterministic builds, specify explicit NodeJS and Yarn versions.
2727
node_version = "10.13.0",
28-
# Use latest yarn version to support integrity field (added in yarn 1.10)
29-
yarn_version = "1.12.1",
28+
yarn_repositories = {
29+
"1.16.0": ("yarn-v1.16.0.tar.gz", "yarn-v1.16.0", "df202627d9a70cf09ef2fb11cb298cb619db1b958590959d6f6e571b50656029"),
30+
},
31+
yarn_version = "1.16.0",
3032
)
3133

3234
yarn_install(

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"license": "MIT",
1111
"engines": {
12-
"node": ">= 5.4.1"
12+
"node": ">= 5.4.1",
13+
"yarn": ">= 1.13.0"
1314
},
1415
"scripts": {
1516
"postinstall": "ngc -p angular-tsconfig.json",

0 commit comments

Comments
 (0)