Skip to content

Commit 17c10d1

Browse files
josephperrottKeen Yee Liau
authored andcommitted
ci: setup RBE on CI
1 parent ec925af commit 17c10d1

File tree

7 files changed

+124
-0
lines changed

7 files changed

+124
-0
lines changed

.bazelrc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,57 @@ build --strategy=TypeScriptCompile=worker
66
build --watchfs
77

88
test --test_output=errors
9+
10+
################################
11+
# Remote Execution Setup #
12+
################################
13+
14+
# Use the Angular team internal GCP instance for remote execution.
15+
build:remote --remote_instance_name=projects/internal-200822/instances/default_instance
16+
build:remote --project_id=internal-200822
17+
18+
# Setup the build strategy for various types of actions. Mixing "local" and "remote"
19+
# can cause unexpected results and we want to run everything remotely if possible.
20+
build:remote --spawn_strategy=remote
21+
build:remote --strategy=Javac=remote
22+
build:remote --strategy=Closure=remote
23+
build:remote --strategy=Genrule=remote
24+
build:remote --define=EXECUTOR=remote
25+
26+
# Setup the remote build execution servers.
27+
build:remote --remote_cache=remotebuildexecution.googleapis.com
28+
build:remote --remote_executor=remotebuildexecution.googleapis.com
29+
build:remote --tls_enabled=true
30+
build:remote --auth_enabled=true
31+
build:remote --remote_timeout=3600
32+
build:remote --jobs=50
33+
34+
# Setup the toolchain and platform for the remote build execution. The platform
35+
# is automatically configured by the "rbe_autoconfig" rule in the project workpsace.
36+
build:remote --host_javabase=@rbe_ubuntu1604_angular//java:jdk
37+
build:remote --javabase=@rbe_ubuntu1604_angular//java:jdk
38+
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
39+
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
40+
build:remote --crosstool_top=@rbe_ubuntu1604_angular//cc:toolchain
41+
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
42+
build:remote --extra_toolchains=@rbe_ubuntu1604_angular//config:cc-toolchain
43+
build:remote --extra_execution_platforms=//tools:rbe_ubuntu1604-angular
44+
build:remote --host_platform=//tools:rbe_ubuntu1604-angular
45+
build:remote --platforms=//tools:rbe_ubuntu1604-angular
46+
47+
# Setup Build Event Service
48+
build:remote --bes_backend=buildeventservice.googleapis.com
49+
build:remote --bes_timeout=30s
50+
build:remote --bes_results_url="https://source.cloud.google.com/results/invocations/"
51+
52+
# Set remote caching settings
53+
build:remote --remote_accept_cached=true
54+
55+
####################################################
56+
# User bazel configuration
57+
# NOTE: This needs to be the *last* entry in the config.
58+
####################################################
59+
60+
# Load any settings which are specific to the current user. Needs to be *last* statement
61+
# in this config, as the user configuration should be able to overwrite flags from this file.
62+
try-import .bazelrc.user

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,27 @@ anchor_6: &ignore_pull_requests
7171
branches:
7272
ignore:
7373
- /pull\/.*/
74+
anchor_7: &setup_bazel_remote_execution
75+
run:
76+
name: "Setup bazel RBE remote execution"
77+
command: |
78+
touch .bazelrc.user;
79+
# We need ensure that the same default digest is used for encoding and decoding
80+
# with openssl. Openssl versions might have different default digests which can
81+
# cause decryption failures based on the openssl version. https://stackoverflow.com/a/39641378/4317734
82+
openssl aes-256-cbc -d -in .circleci/gcp_token -md md5 -k "${CIRCLE_PROJECT_REPONAME}" -out /home/circleci/.gcp_credentials;
83+
sudo bash -c "echo -e 'build --google_credentials=/home/circleci/.gcp_credentials' >> .bazelrc.user";
84+
# Upload/don't upload local results to cache based on environment
85+
if [[ -n "{$CIRCLE_PR_NUMBER}" ]]; then
86+
sudo bash -c "echo -e 'build:remote --remote_upload_local_results=false\n' >> .bazelrc.user";
87+
echo "Not uploading local build results to remote cache.";
88+
else
89+
sudo bash -c "echo -e 'build:remote --remote_upload_local_results=true\n' >> .bazelrc.user";
90+
echo "Uploading local build results to remote cache.";
91+
fi
92+
# Enable remote builds
93+
sudo bash -c "echo -e 'build --config=remote' >> .bazelrc.user";
94+
echo "Reading from remote cache for bazel remote jobs.";
7495
7596
# Job definitions
7697
version: 2.1
@@ -204,6 +225,7 @@ jobs:
204225
resource_class: xlarge
205226
steps:
206227
- attach_workspace: *attach_options
228+
- *setup_bazel_remote_execution
207229
- run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc
208230
- run: yarn bazel:test
209231

.circleci/gcp_token

2.3 KB
Binary file not shown.

WORKSPACE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,34 @@ rules_karma_dependencies()
8080
load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
8181

8282
web_test_repositories()
83+
84+
##########################
85+
# Remote Execution Setup #
86+
##########################
87+
# Bring in bazel_toolchains for RBE setup configuration.
88+
http_archive(
89+
name = "bazel_toolchains",
90+
sha256 = "142bcbd8cb751ce1193a1d7fef4e328493cd0a69cc0555183ad237f81418ba40",
91+
strip_prefix = "bazel-toolchains-628224f6cf48e81116d0ee0bf65424eaa630d5b3",
92+
urls = ["https://github.com/xingao267/bazel-toolchains/archive/628224f6cf48e81116d0ee0bf65424eaa630d5b3.tar.gz"],
93+
)
94+
95+
load("@bazel_toolchains//rules:environments.bzl", "clang_env")
96+
load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")
97+
98+
rbe_autoconfig(
99+
name = "rbe_ubuntu1604_angular",
100+
# The sha256 of marketplace.gcr.io/google/rbe-ubuntu16-04 container that is
101+
# used by rbe_autoconfig() to pair toolchain configs in the @bazel_toolchains repo.
102+
base_container_digest = "sha256:677c1317f14c6fd5eba2fd8ec645bfdc5119f64b3e5e944e13c89e0525cc8ad1",
103+
# Note that if you change the `digest`, you might also need to update the
104+
# `base_container_digest` to make sure marketplace.gcr.io/google/rbe-ubuntu16-04-webtest:<digest>
105+
# and marketplace.gcr.io/google/rbe-ubuntu16-04:<base_container_digest> have
106+
# the same Clang and JDK installed.
107+
# Clang is needed because of the dependency on @com_google_protobuf.
108+
# Java is needed for the Bazel's test executor Java tool.
109+
digest = "sha256:74a8e9dca4781d5f277a7bd8e7ea7ed0f5906c79c9cd996205b6d32f090c62f3",
110+
env = clang_env(),
111+
registry = "marketplace.gcr.io",
112+
repository = "google/rbe-ubuntu16-04-webtest",
113+
)

packages/angular_devkit/core/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ ts_library(
7070
jasmine_node_test(
7171
name = "core_test",
7272
srcs = [":core_test_lib"],
73+
# TODO: Audit tests to determine if tests can be run in RBE environments
74+
local = True,
7375
deps = [
7476
"@npm//jasmine",
7577
"@npm//source-map",

packages/schematics/update/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ ts_library(
7979
jasmine_node_test(
8080
name = "update_test",
8181
srcs = [":update_test_lib"],
82+
# TODO: Audit tests to determine if tests can be run in RBE environments
83+
local = True,
8284
deps = [
8385
"@npm//jasmine",
8486
"@npm//npm-registry-client",

tools/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ nodejs_binary(
2121
"--node_options=--preserve-symlinks",
2222
],
2323
)
24+
25+
platform(
26+
name = "rbe_ubuntu1604-angular",
27+
parents = ["@rbe_ubuntu1604_angular//config:platform"],
28+
remote_execution_properties = """
29+
{PARENT_REMOTE_EXECUTION_PROPERTIES}
30+
properties: {
31+
name: "dockerAddCapabilities"
32+
value: "SYS_ADMIN"
33+
}
34+
""",
35+
)
36+
2437
# @external_end

0 commit comments

Comments
 (0)