Skip to content

Commit

Permalink
build: use platform from shared dev-infra package for remote execution
Browse files Browse the repository at this point in the history
Uses the new shared RBE platform from the dev-infra package.

We introduced a shared Bazel platform for remote execution builds
using Google cloud. Previously we used `bazel_toolchains` for
providing the platform w/ additional CPP and Java toolchains

`bazel_toolchains` no longer provides default toolchains with the
latest version, but provides a tool (linux and windows only) for
generating toolchain/platforms, which then need to be checked
into the repository. This is quite inconvenient and cumbersome
(especially with no macOS support), so we just provided our own
platform and CPP toolchain within `//dev-infra`. This is more
simple than all the effort we'd need to make the toolchain
generation tool work (while it would also increase the amount
of checked-in sources significantly; with more unused toolchains
for CPP or Java)

See: angular/angular#41767.
  • Loading branch information
trik committed Jun 8, 2021
1 parent 9162eeb commit 7fb2f7a
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 332 deletions.
22 changes: 8 additions & 14 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ build:remote --project_id=internal-200822
# Needed due to: https://github.com/bazelbuild/bazel/issues/7254
build:remote --define=EXECUTOR=remote

# For remote execution, we use the `ubuntu16_04_clang` toolchain configurations. These only
# support `k8` or `armeabi-v7a`. Since we run on remotely with `k8` containers, we need to
# ensure that the proper CPU is configured so that the correct toolchain can be used.
# https://github.com/bazelbuild/bazel-toolchains/blob/master/configs/ubuntu16_04_clang/10.0.0/bazel_2.1.0/cc/BUILD#L50
# Since remote builds run within Google Cloud `k8`-based containers, we set the
# host and target CPU accordingly.
build:remote --cpu=k8
build:remote --host_cpu=k8

Expand All @@ -98,16 +96,12 @@ build:remote --remote_executor=remotebuildexecution.googleapis.com
build:remote --auth_enabled=true

# Setup the toolchain and platform for the remote build execution. The platform
# is automatically configured by the "rbe_autoconfig" rule in the project workpsace.
build:remote --crosstool_top=@rbe_default//cc:toolchain
build:remote --host_javabase=@rbe_default//java:jdk
build:remote --javabase=@rbe_default//java:jdk
build:remote --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build:remote --extra_execution_platforms=//tools:rbe_platform
build:remote --host_platform=//tools:rbe_platform
build:remote --platforms=//tools:rbe_platform
build:remote --extra_toolchains=@rbe_default//config:cc-toolchain
# is provided by the shared dev-infra package and targets k8 remote containers.
build:remote --crosstool_top=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain_suite
build:remote --extra_toolchains=@npm//@angular/dev-infra-private/bazel/remote-execution/cpp:cc_toolchain
build:remote --extra_execution_platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
build:remote --host_platform=@npm//@angular/dev-infra-private/bazel/remote-execution:platform
build:remote --platforms=@npm//@angular/dev-infra-private/bazel/remote-execution:platform

################################
# --config=build-results #
Expand Down
36 changes: 0 additions & 36 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,42 +69,6 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")

sass_repositories()

# Bring in bazel_toolchains for RBE setup configuration.
http_archive(
name = "bazel_toolchains",
# Patch `bazel-toolchains` to always consider the host platform as Linux. This is necessary
# because the RBE configurations are incorrectly based on the host platform and this breaks
# cross-platform remote execution. e.g. using RBE on macOS.
# See: https://github.com/bazelbuild/bazel-toolchains/issues/895
patches = ["//tools:rbe_cross_platform_workaround.patch"],
sha256 = "1adf5db506a7e3c465a26988514cfc3971af6d5b3c2218925cd6e71ee443fc3f",
strip_prefix = "bazel-toolchains-4.0.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz",
],
)

load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")

bazel_toolchains_repositories()

load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig")

rbe_autoconfig(
name = "rbe_default",
# Need to specify a base container digest in order to ensure that we can use the checked-in
# platform configurations for the "ubuntu16_04" image. Otherwise the autoconfig rule would
# need to pull the image and run it in order determine the toolchain configuration.
# See: https://github.com/bazelbuild/bazel-toolchains/blob/master/configs/ubuntu16_04_clang/versions.bzl#L9
base_container_digest = "sha256:f6568d8168b14aafd1b707019927a63c2d37113a03bcee188218f99bd0327ea1",
digest = "sha256:dddaaddbe07a61c2517f9b08c4977fc23c4968fcb6c0b8b5971e955d2de7a961",
registry = "marketplace.gcr.io",
# We can't use the default "ubuntu16_04" RBE image provided by the autoconfig because we need
# a specific Linux kernel that comes with "libx11" in order to run headless browser tests.
repository = "google/rbe-ubuntu16-04-webtest",
)

# Load pinned rules_webtesting browser versions for tests.
#
# TODO(wagnermaciel): deduplicate browsers - this will load another version of chromium in the
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@angular-devkit/schematics": "^12.0.0-rc.0",
"@angular/bazel": "^12.0.0-rc.0",
"@angular/compiler-cli": "^12.0.0-rc.0",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#3953ba9eea35a2660b6068523bafb92634042be9",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#2e0271af93b020a811323fbc274afcf588dbc91e",
"@angular/platform-browser-dynamic": "^12.0.0-rc.0",
"@angular/platform-server": "^12.0.0-rc.0",
"@angular/router": "^12.0.0-rc.0",
Expand Down
15 changes: 0 additions & 15 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@ exports_files([
"monaco-lib-tmpl.js",
"system-config-tmpl.js",
"system-rxjs-operators.js",
"rbe_cross_platform_workaround.patch",
])

# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
# "SYS_ADMIN" capability in order to run browsers with sandbox enabled.
platform(
name = "rbe_platform",
parents = ["@rbe_default//config:platform"],
remote_execution_properties = """
{PARENT_REMOTE_EXECUTION_PROPERTIES}
properties: {
name: "dockerAddCapabilities"
value: "SYS_ADMIN"
}
""",
)

config_setting(
name = "view_engine_mode",
values = {
Expand Down
26 changes: 0 additions & 26 deletions tools/rbe_cross_platform_workaround.patch

This file was deleted.

0 comments on commit 7fb2f7a

Please sign in to comment.