Skip to content

Commit 495d1b5

Browse files
devversionjelbourn
authored andcommitted
build: switch to rbe_autoconfig (#15624)
1 parent 434ef99 commit 495d1b5

File tree

4 files changed

+52
-134
lines changed

4 files changed

+52
-134
lines changed

.circleci/base-rbe-bazelrc

Lines changed: 15 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,25 @@
1-
# ------------------------------
2-
# This file is taken from the "bazel-toolchains" repository and is used in order to reduce the
3-
# manual configuration overhead. https://github.com/bazelbuild/bazel-toolchains/tree/master/bazelrc
4-
# ------------------------------
5-
6-
# Copyright 2016 The Bazel Authors. All rights reserved.
7-
#
8-
# Licensed under the Apache License, Version 2.0 (the "License");
9-
# you may not use this file except in compliance with the License.
10-
# You may obtain a copy of the License at
11-
#
12-
# http://www.apache.org/licenses/LICENSE-2.0
13-
#
14-
# Unless required by applicable law or agreed to in writing, software
15-
# distributed under the License is distributed on an "AS IS" BASIS,
16-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
# See the License for the specific language governing permissions and
18-
# limitations under the License.
19-
20-
# Depending on how many machines are in the remote execution instance, setting
21-
# this higher can make builds faster by allowing more jobs to run in parallel.
22-
# Setting it too high can result in jobs that timeout, however, while waiting
23-
# for a remote machine to execute them.
24-
build:remote --jobs=50
25-
26-
# Set several flags related to specifying the platform, toolchain and java
27-
# properties.
28-
# These flags are duplicated rather than imported from (for example)
29-
# %workspace%/configs/ubuntu16_04_clang/1.1/toolchain.bazelrc to make this
30-
# bazelrc a standalone file that can be copied more easily.
31-
# These flags should only be used as is for the rbe-ubuntu16-04 container
32-
# and need to be adapted to work with other toolchain containers.
33-
build:remote --host_javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:jdk8
34-
build:remote --javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:jdk8
35-
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
36-
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
37-
build:remote --crosstool_top=@bazel_toolchains//configs/ubuntu16_04_clang/1.1/bazel_0.22.0/default:toolchain
38-
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
39-
# Platform flags:
40-
# The toolchain container used for execution is defined in the target indicated
41-
# by "extra_execution_platforms", "host_platform" and "platforms".
42-
# If you are using your own toolchain container, you need to create a platform
43-
# target with "constraint_values" that allow for the toolchain specified with
44-
# "extra_toolchains" to be selected (given constraints defined in
45-
# "exec_compatible_with").
46-
# More about platforms: https://docs.bazel.build/versions/master/platforms.html
47-
build:remote --extra_toolchains=@bazel_toolchains//configs/ubuntu16_04_clang/1.1/bazel_0.22.0/cpp:cc-toolchain-clang-x86_64-default
48-
build:remote --extra_execution_platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
49-
build:remote --host_platform=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
50-
build:remote --platforms=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:rbe_ubuntu1604
51-
52-
# Set various strategies so that all actions execute remotely. Mixing remote
53-
# and local execution will lead to errors unless the toolchain and remote
54-
# machine exactly match the host machine.
1+
# Setup the build strategy for various types of actions. Mixing "local" and "remote"
2+
# can cause unexpected results and we want to run everything remotely if possible.
553
build:remote --spawn_strategy=remote
564
build:remote --strategy=Javac=remote
575
build:remote --strategy=Closure=remote
58-
build:remote --genrule_strategy=remote
6+
build:remote --strategy=Genrule=remote
597
build:remote --define=EXECUTOR=remote
608

61-
# Enable the remote cache so action results can be shared across machines,
62-
# developers, and workspaces.
9+
# Setup the remote build execution servers.
6310
build:remote --remote_cache=remotebuildexecution.googleapis.com
64-
65-
# Enable remote execution so actions are performed on the remote systems.
6611
build:remote --remote_executor=remotebuildexecution.googleapis.com
67-
68-
# Enable encryption.
6912
build:remote --tls_enabled=true
70-
71-
# Enforce stricter environment rules, which eliminates some non-hermetic
72-
# behavior and therefore improves both the remote cache hit rate and the
73-
# correctness and repeatability of the build.
74-
build:remote --experimental_strict_action_env=true
75-
76-
# Set a higher timeout value, just in case.
77-
build:remote --remote_timeout=3600
78-
79-
# Enable authentication. This will pick up application default credentials by
80-
# default. You can use --auth_credentials=some_file.json to use a service
81-
# account credential instead.
8213
build:remote --auth_enabled=true
8314

84-
# Set flags for uploading to BES in order to view results in the Bazel Build
85-
# Results UI.
86-
build:results --bes_backend="buildeventservice.googleapis.com"
87-
build:results --bes_timeout=60s
88-
build:results --tls_enabled
89-
90-
# Output BES results url
91-
build:results --bes_results_url="https://source.cloud.google.com/results/invocations/"
92-
93-
# Set flags for uploading to BES without Remote Build Execution.
94-
build:results-local --bes_backend="buildeventservice.googleapis.com"
95-
build:results-local --bes_timeout=60s
96-
build:results-local --tls_enabled=true
97-
build:results-local --auth_enabled=true
98-
build:results-local --spawn_strategy=local
99-
build:results-local --remote_cache=remotebuildexecution.googleapis.com
100-
build:results-local --remote_timeout=3600
101-
build:results-local --bes_results_url="https://source.cloud.google.com/results/invocations/"
102-
103-
# The following flags are only necessary for local docker sandboxing
104-
# with the rbe-ubuntu16-04 container. Use of these flags is still experimental.
105-
build:docker-sandbox --host_javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:jdk8
106-
build:docker-sandbox --javabase=@bazel_toolchains//configs/ubuntu16_04_clang/1.1:jdk8
107-
build:docker-sandbox --crosstool_top=@bazel_toolchains//configs/ubuntu16_04_clang/1.1/bazel_0.22.0/default:toolchain
108-
build:docker-sandbox --experimental_docker_image=gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:9bd8ba020af33edb5f11eff0af2f63b3bcb168cd6566d7b27c6685e717787928
109-
build:docker-sandbox --spawn_strategy=docker
110-
build:docker-sandbox --strategy=Javac=docker
111-
build:docker-sandbox --strategy=Closure=docker
112-
build:docker-sandbox --genrule_strategy=docker
113-
build:docker-sandbox --define=EXECUTOR=remote
114-
build:docker-sandbox --experimental_docker_verbose
115-
build:docker-sandbox --experimental_enable_docker_sandbox
116-
117-
# The following flags enable the remote cache so action results can be shared
118-
# across machines, developers, and workspaces.
119-
build:remote-cache --remote_cache=remotebuildexecution.googleapis.com
120-
build:remote-cache --tls_enabled=true
121-
build:remote-cache --remote_timeout=3600
122-
build:remote-cache --auth_enabled=true
123-
build:remote-cache --spawn_strategy=standalone
124-
build:remote-cache --strategy=Javac=standalone
125-
build:remote-cache --strategy=Closure=standalone
126-
build:remote-cache --genrule_strategy=standalone
15+
# Setup the toolchain and platform for the remote build execution. The platform
16+
# is automatically configured by the "rbe_autoconfig" rule in the project workpsace.
17+
build:remote --crosstool_top=@rbe_default//cc:toolchain
18+
build:remote --host_javabase=@rbe_default//java:jdk
19+
build:remote --javabase=@rbe_default//java:jdk
20+
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
21+
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
22+
build:remote --extra_execution_platforms=//tools:rbe_platform
23+
build:remote --host_platform=//tools:rbe_platform
24+
build:remote --platforms=//tools:rbe_platform
25+
build:remote --extra_toolchains=@rbe_default//config:cc-toolchain

.circleci/bazel.rc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,9 @@ build --repository_cache=/home/circleci/bazel_repository_cache
1010
# Remote Build Execution support on CI #
1111
########################################
1212

13-
# Load default settings for Remote Build Execution.
13+
# Load base settings for remote build execution.
1414
import %workspace%/.circleci/base-rbe-bazelrc
1515

16-
# Custom execution platform defined in the Angular repository. See:
17-
# https://github.com/angular/angular/blob/master/tools/BUILD.bazel#L21
18-
build:remote --extra_execution_platforms=@angular//tools:rbe_ubuntu1604-angular
19-
build:remote --host_platform=@angular//tools:rbe_ubuntu1604-angular
20-
build:remote --platforms=@angular//tools:rbe_ubuntu1604-angular
21-
22-
# Increase the amount of parallel jobs. The default RBE base configuration specifies a low
23-
# number of parallel jobs, but our build and testing should be parallelizable.
24-
build:remote --jobs=150
25-
2616
# Use the Angular team internal GCP instance for remote execution.
2717
build:remote --remote_instance_name=projects/internal-200822/instances/default_instance
2818

WORKSPACE

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,28 @@ yarn_install(
8585
yarn_lock = "@angular//tools/ts-api-guardian:yarn.lock",
8686
)
8787

88-
# Bring in bazel_toolchains for RBE stuff.
88+
# Bring in bazel_toolchains for RBE setup configuration.
8989
http_archive(
9090
name = "bazel_toolchains",
91-
sha256 = "109a99384f9d08f9e75136d218ebaebc68cc810c56897aea2224c57932052d30",
92-
strip_prefix = "bazel-toolchains-94d31935a2c94fe7e7c7379a0f3393e181928ff7",
93-
urls = [
94-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/94d31935a2c94fe7e7c7379a0f3393e181928ff7.tar.gz",
95-
"https://github.com/bazelbuild/bazel-toolchains/archive/94d31935a2c94fe7e7c7379a0f3393e181928ff7.tar.gz",
96-
]
91+
sha256 = "67335b3563d9b67dc2550b8f27cc689b64fadac491e69ce78763d9ba894cc5cc",
92+
strip_prefix = "bazel-toolchains-cddc376d428ada2927ad359211c3e356bd9c9fbb",
93+
url = "https://github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
94+
)
95+
96+
load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")
97+
bazel_toolchains_repositories()
98+
99+
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
100+
rbe_autoconfig(
101+
name = "rbe_default",
102+
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
103+
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
104+
repository = "asci-toolchain/nosla-ubuntu16_04-webtest",
105+
registry = "gcr.io",
106+
digest = "sha256:e874885f5e3d9ac0c0d3176e5369cb5969467dbf9ad8d42b862829cec8d84b9b",
107+
# Need to specify a base container digest in order to ensure that we can use the checked-in
108+
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
109+
# need to pull the image and run it in order determine the toolchain configuration.
110+
# See: https://github.com/bazelbuild/bazel-toolchains/blob/master/rules/rbe_repo.bzl#L229
111+
base_container_digest = "sha256:da0f21c71abce3bbb92c3a0c44c3737f007a82b60f8bd2930abc55fe64fc2729",
97112
)

tools/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ nodejs_binary(
2121
],
2222
entry_point = "angular_material/tools/sass-bundle.js",
2323
)
24+
25+
# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
26+
# "SYS_ADMIN" capability in order to run browsers with sandbox enabled.
27+
platform(
28+
name = "rbe_platform",
29+
parents = ["@rbe_default//config:platform"],
30+
remote_execution_properties = """
31+
{PARENT_REMOTE_EXECUTION_PROPERTIES}
32+
properties: {
33+
name: "dockerAddCapabilities"
34+
value: "SYS_ADMIN"
35+
}
36+
""",
37+
)

0 commit comments

Comments
 (0)