Skip to content

Commit

Permalink
feat(bazel): use new rbe_autoconfig() and new container.
Browse files Browse the repository at this point in the history
After this PR is merged, maintainers no longer need to update .bazelrc
file, toolchain and platform related flags for RBE builds and tests
(unless there is a breaking change in Bazel related to those flags).

Maintainers just need to update the pin of @bazel-toolchains repo
regularly in the packages/bazel/package.bzl file according to
https://releases.bazel.build/bazel-toolchains.html to include the
latest checked-in toolchain configs. If rbe_autoconfig() cannot find
appropriate toolchain configs for the version of Bazel in the version of
@bazel_toolchains repo that is currently used by this project, it will pull
down the container and generate the configs on the fly as the beginning
of the build/test.
  • Loading branch information
xingao267 committed Mar 28, 2019
1 parent d46a7c8 commit 91fa7d1
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 268 deletions.
47 changes: 38 additions & 9 deletions .bazelrc
Expand Up @@ -115,23 +115,52 @@ build --define=compile=legacy
# --config=remote
###############################

# Load default settings for Remote Build Execution
# When updating, the URLs of bazel_toolchains in packages/bazel/package.bzl
# may also need to be updated (see https://github.com/angular/angular/pull/27935)
import %workspace%/third_party/github.com/bazelbuild/bazel-toolchains/bazelrc/bazel-0.24.0.bazelrc

# Increase the default number of jobs by 50% because our build has lots of
# parallelism
build:remote --jobs=150

# Point to our custom execution platform; see tools/BUILD.bazel
build:remote --extra_execution_platforms=//tools:rbe_ubuntu1604-angular
build:remote --host_platform=//tools:rbe_ubuntu1604-angular
build:remote --platforms=//tools:rbe_ubuntu1604-angular
# Toolchain and platform related flags
build:remote --host_javabase=@rbe_ubuntu1604_angular//java:jdk
build:remote --javabase=@rbe_ubuntu1604_angular//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 --crosstool_top=@rbe_ubuntu1604_angular//cc:toolchain
build:remote --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:remote --extra_toolchains=@rbe_ubuntu1604_angular//config:cc-toolchain
build:remote --extra_execution_platforms=//tools:platform
build:remote --host_platform=//tools:platform
build:remote --platforms=//tools:platform

# Set various strategies so that all actions execute remotely. Mixing remote
# and local execution will lead to errors unless the toolchain and remote
# machine exactly match the host machine.
build:remote --spawn_strategy=remote
build:remote --strategy=Javac=remote
build:remote --strategy=Closure=remote
build:remote --strategy=Genrule=remote
build:remote --define=EXECUTOR=remote

# Enable the remote cache so action results can be shared across machines,
# developers, and workspaces.
build:remote --remote_cache=remotebuildexecution.googleapis.com

# Enable remote execution so actions are performed on the remote systems.
build:remote --remote_executor=remotebuildexecution.googleapis.com

# Remote instance.
build:remote --remote_instance_name=projects/internal-200822/instances/default_instance

# Enable encryption.
build:remote --tls_enabled=true

# Set a higher timeout value, just in case.
build:remote --remote_timeout=3600

# Enable authentication. This will pick up application default credentials by
# default. You can use --auth_credentials=some_file.json to use a service
# account credential instead.
build:remote --auth_enabled=true

# Do not accept remote cache.
# We need to understand the security risks of using prior build artifacts.
build:remote --remote_accept_cached=false
Expand Down
9 changes: 8 additions & 1 deletion .circleci/config.yml
Expand Up @@ -167,7 +167,8 @@ jobs:
- *attach_workspace
- *init_environment
- *setup_circleci_bazel_config

# Enable remote/sibling docker which is needed by auto-selection of toolchain configs for RBE.
- setup_remote_docker
# Setup remote execution and run RBE-compatible tests.
- *setup_bazel_remote_execution
- run: yarn bazel test //... --build_tag_filters=-ivy-only --test_tag_filters=-ivy-only,-local
Expand All @@ -183,6 +184,8 @@ jobs:
- *attach_workspace
- *init_environment
- *setup_circleci_bazel_config
# Enable remote/sibling docker which is needed by auto-selection of toolchain configs for RBE.
- setup_remote_docker
- *setup_bazel_remote_execution

# We need to explicitly specify the --symlink_prefix option because otherwise we would
Expand Down Expand Up @@ -408,6 +411,8 @@ jobs:
- *attach_workspace
- *init_environment
- *setup_circleci_bazel_config
# Enable remote/sibling docker which is needed by auto-selection of toolchain configs for RBE.
- setup_remote_docker
- *setup_bazel_remote_execution

- run: scripts/build-packages-dist.sh
Expand All @@ -434,6 +439,8 @@ jobs:
- *attach_workspace
- *init_environment
- *setup_circleci_bazel_config
# Enable remote/sibling docker which is needed by auto-selection of toolchain configs for RBE.
- setup_remote_docker
- *setup_bazel_remote_execution

- run: scripts/build-ivy-npm-packages.sh
Expand Down
15 changes: 15 additions & 0 deletions WORKSPACE
Expand Up @@ -119,3 +119,18 @@ sass_repositories()
load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")

skydoc_repositories()

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

rbe_autoconfig(
name = "rbe_ubuntu1604_angular",
base_container_digest = "sha256:69c9f1652941d64a46f6f7358a44c1718f25caa5cb1ced4a58ccc5281cd183b5",
# Needed because CircleCI does not allow mounting from job space to remote containers.
# https://circleci.com/docs/2.0/building-docker-images/#mounting-folders
copy_resources = True,
digest = "sha256:ce383089ba3fc1f6f687fc1e492401e21594c91d9587a315e26e7d6c91aafc4f",
env = clang_env(),
registry = "marketplace.gcr.io",
repository = "google/rbe-ubuntu16-04-webtest",
)
7 changes: 3 additions & 4 deletions packages/bazel/package.bzl
Expand Up @@ -35,11 +35,10 @@ def rules_angular_dev_dependencies():
_maybe(
http_archive,
name = "bazel_toolchains",
sha256 = "67335b3563d9b67dc2550b8f27cc689b64fadac491e69ce78763d9ba894cc5cc",
strip_prefix = "bazel-toolchains-cddc376d428ada2927ad359211c3e356bd9c9fbb",
sha256 = "bcaa7239f4692054a7abcbcdb1f296f200cbe8a6c8c37bde485b3f3a0929a3c8",
strip_prefix = "bazel-toolchains-c6c7c4e850d9668d81aca2c7193b739755aa2fb5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
"https://github.com/xingao267/bazel-toolchains/archive/c6c7c4e850d9668d81aca2c7193b739755aa2fb5.tar.gz",
],
)

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 91fa7d1

Please sign in to comment.