Skip to content

Commit 2ce5ffd

Browse files
devversionjelbourn
authored andcommitted
build: no longer use bazel from "ngcontainer" image
We no longer use Bazel from the `ngcontainer` image as it is no longer maintained and we need to use the latest version of Bazel in CircleCI. It's not ideal to use Bazel through Yarn since binaries like that should be actually part of the docker image, but for now we need to do this for jobs that use NodeJS & Bazel at the same time. This is similar to what `angulart/angular` does.
1 parent f6d4acb commit 2ce5ffd

File tree

5 files changed

+75
-69
lines changed

5 files changed

+75
-69
lines changed

.circleci/config.yml

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,88 +7,90 @@
77
# To validate changes, use an online parser, eg.
88
# http://yaml-online-parser.appspot.com/
99

10-
var_1: &docker_image angular/ngcontainer:0.10.0
10+
var_1: &docker_image circleci/node:10.16
11+
var_2: &docker_bazel_image l.gcr.io/google/bazel:0.26.1
1112

1213
# **Note**: When updating the beginning of the cache key, also update the cache key to match
1314
# the new cache key prefix. This allows us to take advantage of CircleCI's fallback caching.
1415
# Read more here: https://circleci.com/docs/2.0/caching/#restoring-cache.
15-
var_2: &cache_key v2-ng-mat-{{ checksum "WORKSPACE" }}-{{ checksum "yarn.lock" }}
16-
var_3: &cache_fallback_key v2-ng-mat-
16+
var_3: &cache_key v3-ng-mat-{{ checksum "WORKSPACE" }}-{{ checksum "yarn.lock" }}
17+
var_4: &cache_fallback_key v3-ng-mat-
1718

1819
# Settings common to each job
19-
var_4: &job_defaults
20+
var_5: &job_defaults
2021
working_directory: ~/ng
2122
docker:
2223
- image: *docker_image
2324

2425
# Job step for checking out the source code from GitHub. This also ensures that the source code
2526
# is rebased on top of master.
26-
var_5: &checkout_code
27+
var_6: &checkout_code
2728
checkout:
2829
# After checkout, rebase on top of master. By default, PRs are not rebased on top of master,
2930
# which we want. See https://discuss.circleci.com/t/1662
3031
post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge"
3132

3233
# Restores the cache that could be available for the current Yarn lock file. The cache usually
3334
# includes the node modules and the Bazel repository cache.
34-
var_6: &restore_cache
35+
var_7: &restore_cache
3536
restore_cache:
3637
keys:
3738
- *cache_key
3839
- *cache_fallback_key
3940

4041
# Saves the cache for the current Yarn lock file. We store the node modules and the Bazel
4142
# repository cache in order to make subsequent builds faster.
42-
var_7: &save_cache
43+
var_8: &save_cache
4344
save_cache:
4445
key: *cache_key
4546
paths:
4647
- "node_modules"
4748
- "~/bazel_repository_cache"
4849

4950
# Decryption token that is used to decode the GCP credentials file in ".circleci/gcp_token".
50-
var_8: &gcp_decrypt_token "angular"
51+
var_9: &gcp_decrypt_token "angular"
5152

5253
# Job step that ensures that the node module dependencies are installed and up-to-date. We use
5354
# Yarn with the frozen lockfile option in order to make sure that lock file and package.json are
5455
# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because
5556
# CircleCI automatically discards the cache if the checksum of the lock file has changed.
56-
var_9: &yarn_install
57+
var_10: &yarn_install
5758
run:
5859
name: "Installing project dependencies"
5960
command: yarn install --frozen-lockfile --non-interactive
6061

6162
# Anchor that can be used to download and install Yarn globally in the bash environment.
62-
var_10: &yarn_download
63+
var_11: &yarn_download
6364
run:
6465
name: "Downloading and installing Yarn"
6566
command: |
6667
touch $BASH_ENV
6768
curl -o- -L https://yarnpkg.com/install.sh | PROFILE=$BASH_ENV bash -s -- --version "1.16.0"
6869
69-
# Copies the Bazel config which is specifically for CircleCI to a location where Bazel picks it
70-
# up and merges it with the project-wide bazel configuration (tools/bazel.rc)
71-
var_11: &copy_bazel_config
72-
# Set up the CircleCI specific bazel configuration.
73-
run: sudo cp ./.circleci/bazel.rc /etc/bazel.bazelrc
70+
# Sets up the Bazel config which is specific for CircleCI builds.
71+
var_12: &setup_bazel_ci_config
72+
run:
73+
name: "Setting up Bazel configuration for CI"
74+
command: |
75+
echo "import %workspace%/.circleci/bazel.rc" >> ./.bazelrc
7476
7577
# Sets up a different Docker image that includes a moe recent Firefox version which
7678
# is needed for headless testing.
77-
var_12: &docker-firefox-image
79+
var_13: &docker-firefox-image
7880
# TODO(devversion): Temporarily use a image that includes Firefox 62 because the
7981
# ngcontainer image does include an old Firefox version that does not support headless.
8082
- image: circleci/node:11.4.0-browsers
8183

8284
# Attaches the release output which has been stored in the workspace to the current job.
8385
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
84-
var_13: &attach_release_output
86+
var_14: &attach_release_output
8587
attach_workspace:
8688
at: dist/
8789

8890
# Branch filter that we can specify for jobs that should only run on publish branches. This filter
8991
# is used to ensure that not all upstream branches will be published as Github builds
9092
# (e.g. revert branches, feature branches)
91-
var_14: &publish_branches_filter
93+
var_15: &publish_branches_filter
9294
branches:
9395
only:
9496
- master
@@ -102,15 +104,15 @@ var_14: &publish_branches_filter
102104
# In order to reduce duplication we use a YAML anchor that just always excludes the "_presubmit"
103105
# branch. We don't want to run Circle for the temporary "_presubmit" branch which is reserved
104106
# for the caretaker.
105-
var_15: &ignore_presubmit_branch_filter
107+
var_16: &ignore_presubmit_branch_filter
106108
branches:
107109
ignore:
108110
- "_presubmit"
109111
- "ivy-2019"
110112

111113
# Runs a script that sets up the Bazel remote execution. This will be used by jobs that run
112114
# Bazel primarily and should benefit from remote caching and execution.
113-
var_16: &setup_bazel_remote_execution
115+
var_17: &setup_bazel_remote_execution
114116
run:
115117
name: "Setup bazel RBE remote execution"
116118
command: ./scripts/circleci/bazel/setup-remote-execution.sh
@@ -130,36 +132,34 @@ jobs:
130132
# Build and test job that uses Bazel.
131133
# -----------------------------------
132134
bazel_build_test:
133-
<<: *job_defaults
135+
docker:
136+
- image: *docker_bazel_image
134137
resource_class: xlarge
135138
environment:
136139
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
137140
steps:
138141
- *checkout_code
139142
- *restore_cache
140-
- *copy_bazel_config
143+
- *setup_bazel_ci_config
141144
- *setup_bazel_remote_execution
142145

143146
- run: bazel build src/... --build_tag_filters=-docs-package
144147
- run: bazel test src/... --build_tag_filters=-docs-package --test_tag_filters=-e2e
145148

146-
# Note: We want to save the cache in this job because the workspace cache also
147-
# includes the Bazel repository cache that will be updated in this job.
148-
- *save_cache
149-
150149
# --------------------------------------------------------------------------------------------
151150
# Job that runs ts-api-guardian against our API goldens in "tools/public_api_guard".
152151
# This job fails whenever an API has been updated but not explicitly approved through goldens.
153152
# --------------------------------------------------------------------------------------------
154153
api_golden_checks:
155-
<<: *job_defaults
154+
docker:
155+
- image: *docker_bazel_image
156156
resource_class: xlarge
157157
environment:
158158
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
159159
steps:
160160
- *checkout_code
161161
- *restore_cache
162-
- *copy_bazel_config
162+
- *setup_bazel_ci_config
163163
- *setup_bazel_remote_execution
164164

165165
- run: bazel test tools/public_api_guard/...
@@ -168,14 +168,15 @@ jobs:
168168
# Job that runs the e2e tests with Protractor and Chromium headless
169169
# -----------------------------------------------------------------
170170
e2e_tests:
171-
<<: *job_defaults
171+
docker:
172+
- image: *docker_bazel_image
172173
resource_class: xlarge
173174
environment:
174175
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
175176
steps:
176177
- *checkout_code
177178
- *restore_cache
178-
- *copy_bazel_config
179+
- *setup_bazel_ci_config
179180
- *setup_bazel_remote_execution
180181

181182
- run: bazel test src/... --test_tag_filters=e2e
@@ -277,6 +278,8 @@ jobs:
277278
- run: ./scripts/circleci/lint-bazel-files.sh
278279
- run: yarn gulp ci:lint
279280

281+
- *save_cache
282+
280283
# -------------------------------------------------------------------------------------------
281284
# Job that builds all release packages with Gulp. The built packages can be then used in the
282285
# same workflow to publish snapshot builds or test the dev-app with the release packages.
@@ -327,15 +330,16 @@ jobs:
327330
# Job that publishes the build snapshots
328331
# ----------------------------------------
329332
publish_snapshots:
330-
<<: *job_defaults
333+
docker:
334+
- image: *docker_bazel_image
331335
resource_class: xlarge
332336
environment:
333337
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
334338
steps:
335339
- *checkout_code
336340
- *restore_cache
337341
- *attach_release_output
338-
- *copy_bazel_config
342+
- *setup_bazel_ci_config
339343
- *setup_bazel_remote_execution
340344

341345
# CircleCI has a config setting to enforce SSH for all github connections.
@@ -371,25 +375,24 @@ jobs:
371375
# specified in the project dev dependencies.
372376
# ----------------------------------------------------------------------------
373377
ivy_test:
374-
<<: *job_defaults
378+
docker:
379+
- image: *docker_bazel_image
375380
resource_class: xlarge
376381
environment:
377382
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
378383
steps:
379384
- *checkout_code
380385
- *restore_cache
381-
- *copy_bazel_config
386+
- *setup_bazel_ci_config
382387
- *setup_bazel_remote_execution
383-
- *yarn_download
384-
- *yarn_install
385388

386389
# Setup Angular ivy snapshots built with ngtsc but locked to a specific tag. We
387390
# cannot determine the tag automatically based on the Angular version specified in
388391
# the "package.json" because the SHA is not known for the given release. Nor can
389392
# we use ngcc to apply the ivy switches because ngcc currently does not handle the
390393
# UMD format which is used by Bazel when running tests. UMD processing is in
391394
# progress and tracked with FW-85.
392-
- run: node ./scripts/circleci/setup-angular-snapshots.js --tag 8.0.0-rc.0-ivy-aot+bd37622
395+
- run: bazel run @nodejs//:node -- ./scripts/circleci/setup-angular-snapshots.js --tag 8.1.0-next.1-ivy-aot+82e0b4a
393396
# Disable type checking when building with Ivy. This is necessary because
394397
# type checking is not complete yet and can incorrectly break compilation.
395398
# Issue is tracked with FW-1004.
@@ -402,20 +405,19 @@ jobs:
402405
# Job that runs all Bazel tests against Ivy from angular/angular#master.
403406
# ----------------------------------------------------------------------------
404407
ivy_snapshot_test_cronjob:
405-
<<: *job_defaults
408+
docker:
409+
- image: *docker_bazel_image
406410
resource_class: xlarge
407411
environment:
408412
GCP_DECRYPT_TOKEN: *gcp_decrypt_token
409413
steps:
410414
- *checkout_code
411415
- *restore_cache
412-
- *copy_bazel_config
416+
- *setup_bazel_ci_config
413417
- *setup_bazel_remote_execution
414-
- *yarn_download
415-
- *yarn_install
416418

417419
# Setup Angular ivy snapshots built with ngtsc.
418-
- run: node ./scripts/circleci/setup-angular-snapshots.js --tag master-ivy-aot
420+
- run: bazel run @nodejs//:node -- ./scripts/circleci/setup-angular-snapshots.js --tag master-ivy-aot
419421
# Disable type checking when building with Ivy. This is necessary because
420422
# type checking is not complete yet and can incorrectly break compilation.
421423
# Issue is tracked with FW-1004.

WORKSPACE

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ http_archive(
1919

2020
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
2121

22-
# The minimum bazel version to use with this repo is 0.18.0
23-
check_bazel_version("0.18.0")
22+
# The minimum bazel version to use with this repo is 0.26.1
23+
check_bazel_version("0.26.1")
2424

2525
node_repositories(
2626
# For deterministic builds, specify explicit NodeJS and Yarn versions.
@@ -39,6 +39,10 @@ yarn_install(
3939
"//:tools/npm/check-npm.js",
4040
],
4141
package_json = "//:package.json",
42+
# Temporarily disable node_modules symlinking until the fix for
43+
# https://github.com/bazelbuild/bazel/issues/8487 makes it into a
44+
# future Bazel release
45+
symlink_node_modules = False,
4246
yarn_lock = "//:yarn.lock",
4347
)
4448

@@ -80,9 +84,9 @@ sass_repositories()
8084
# Bring in bazel_toolchains for RBE setup configuration.
8185
http_archive(
8286
name = "bazel_toolchains",
83-
sha256 = "67335b3563d9b67dc2550b8f27cc689b64fadac491e69ce78763d9ba894cc5cc",
84-
strip_prefix = "bazel-toolchains-cddc376d428ada2927ad359211c3e356bd9c9fbb",
85-
url = "https://github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
87+
sha256 = "4598bf5a8b4f5ced82c782899438a7ba695165d47b3bf783ce774e89a8c6e617",
88+
strip_prefix = "bazel-toolchains-0.27.0",
89+
url = "https://github.com/bazelbuild/bazel-toolchains/archive/0.27.0.tar.gz",
8690
)
8791

8892
load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")
@@ -97,10 +101,10 @@ rbe_autoconfig(
97101
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
98102
# need to pull the image and run it in order determine the toolchain configuration.
99103
# See: https://github.com/bazelbuild/bazel-toolchains/blob/master/rules/rbe_repo.bzl#L229
100-
base_container_digest = "sha256:da0f21c71abce3bbb92c3a0c44c3737f007a82b60f8bd2930abc55fe64fc2729",
101-
digest = "sha256:e874885f5e3d9ac0c0d3176e5369cb5969467dbf9ad8d42b862829cec8d84b9b",
102-
registry = "gcr.io",
104+
base_container_digest = "sha256:94d7d8552902d228c32c8c148cc13f0effc2b4837757a6e95b73fdc5c5e4b07b",
105+
digest = "sha256:76e2e4a894f9ffbea0a0cb2fbde741b5d223d40f265dbb9bca78655430173990",
106+
registry = "marketplace.gcr.io",
103107
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
104108
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
105-
repository = "asci-toolchain/nosla-ubuntu16_04-webtest",
109+
repository = "google/rbe-ubuntu16-04-webtest",
106110
)

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
"@angular/platform-server": "^8.0.1",
6363
"@angular/router": "^8.0.1",
6464
"@angular/upgrade": "^8.0.1",
65-
"@bazel/bazel": "^0.26.1",
65+
"@bazel/bazel": "0.26.1",
6666
"@bazel/buildifier": "^0.25.1",
6767
"@bazel/ibazel": "^0.9.0",
68-
"@bazel/jasmine": "^0.31.1",
69-
"@bazel/karma": "^0.31.1",
70-
"@bazel/typescript": "^0.31.1",
68+
"@bazel/jasmine": "0.31.1",
69+
"@bazel/karma": "0.31.1",
70+
"@bazel/typescript": "0.31.1",
7171
"@firebase/app-types": "^0.3.2",
7272
"@octokit/rest": "^15.9.4",
7373
"@schematics/angular": "^8.0.3",
@@ -141,7 +141,7 @@
141141
"selenium-webdriver": "^3.6.0",
142142
"sorcery": "^0.10.0",
143143
"stylelint": "^9.10.1",
144-
"ts-api-guardian": "^0.4.4",
144+
"ts-api-guardian": "^0.4.6",
145145
"ts-node": "^3.0.4",
146146
"tsconfig-paths": "^2.3.0",
147147
"tslint": "^5.16.0",

scripts/circleci/bazel/setup-remote-execution.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ if [[ -z "${GCP_DECRYPT_TOKEN}" ]]; then
77
fi
88

99
# Decode the GCP token that is needed to authenticate the Bazel remote execution.
10-
openssl aes-256-cbc -d -in .circleci/gcp_token -k ${GCP_DECRYPT_TOKEN} \
11-
-out /home/circleci/.gcp_credentials
10+
openssl aes-256-cbc -d -in .circleci/gcp_token -md md5 -k ${GCP_DECRYPT_TOKEN} \
11+
-out /home/.gcp_credentials
1212

1313
# Export the "GOOGLE_APPLICATION_CREDENTIALS" variable that should refer to the GCP credentials
1414
# file. Bazel automatically picks up the credentials from that variable.
1515
# https://github.com/bazelbuild/bazel/blob/master/third_party/grpc/include/grpc/grpc_security.h#L134-L137
16-
echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV
16+
echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/.gcp_credentials" >> $BASH_ENV
1717

18-
# Update the global Bazel configuration to always use remote execution.
19-
sudo bash -c "echo 'build --config=remote' >> /etc/bazel.bazelrc"
18+
# Update the CircleCI Bazel configuration to always use remote execution.
19+
echo 'build --config=remote' >> .circleci/bazel.rc

0 commit comments

Comments
 (0)