Prerequisites
Before completing the steps on this page, ensure the following:- Your GitHub repository is part of the Bazel GitHub organization.
- You have configured Buildkite for your repository as described in Bazel Continuous Integration.
Setting up the Bazel CI for testing
-
In your
.bazelci/presubmit.ymlfile, do the following: a. Add a config namedrbe_ubuntu1604. b. In therbe_ubuntu1604config, add the build and test targets you want to test against remote execution. -
Add the
bazel-toolchainsGitHub repository to yourWORKSPACEfile, pinned to the latest release. Also add anrbe_autoconfigtarget with namebuildkite_config. This example creates toolchain configuration for remote execution with BuildKite CI forrbe_ubuntu1604.
-
Send a pull request with your changes to the
presubmit.ymlfile. (See example pull request.) -
To view build results, click Details for the RBE (Ubuntu
16.04) pull request check in GitHub, as shown in the figure below. This link
becomes available after the pull request has been merged and the CI tests
have run. (See
example results.)
-
(Optional) Set the bazel test (RBE (Ubuntu 16.04)) check as a test
required to pass before merging in your branch protection rule. The setting
is located in GitHub in Settings > Branches > Branch protection rules,
as shown in the following figure.
Troubleshooting failed builds and tests
If your build or tests fail, it’s likely due to the following:-
Required build or test tools are not installed in the default container.
Builds using the
rbe_ubuntu1604config run by default inside anrbe-ubuntu16-04container, which includes tools common to many Bazel builds. However, if your rules require tools not present in the default container, you must create a custom container based on therbe-ubuntu16-04container and include those tools as described later. - Build or test targets are using rules that are incompatible with remote execution. See Adapting Bazel Rules for Remote Execution for details about compatibility with remote execution.
Using a custom container in the rbe_ubuntu1604 CI config
Therbe-ubuntu16-04 container is publicly available at the following URL:
gcloud, docker, and git.
If you are building the container from source, you must also install the latest
version of Bazel.
Pulling the rbe-ubuntu16-04 from Container Registry
To pull therbe-ubuntu16-04 container from Container Registry, run the
following command:
Building the rbe-ubuntu16-04 container from source
To build therbe-ubuntu16-04 container from source, do the following:
-
Clone the
bazel-toolchainsrepository: - Set up toolchain container targets and build the container as explained in Toolchain Containers.
-
Pull the freshly built container:
sha256-checksum with the SHA256 checksum value for the
latest container.
-
If you built the container from source, run the following command:
Adding resources to the custom container
Use aDockerfile or
rules_docker to add resources or
alternate versions of the original resources to the rbe-ubuntu16-04 container.
If you are new to Docker, read the following:
For example, the following Dockerfile snippet installs <var>my_tool_package</var>:
Pushing the custom container to Container Registry
Once you have customized the container, build the container image and push it to Container Registry as follows:-
Build the container image:
-
Push the container image to Container Registry:
- Navigate to the following URL to verify the container has been pushed: https://console.cloud.google.com/gcr/images/project-id/GLOBAL/custom-container-name
- Take note of the SHA256 checksum of your custom container. You will need to provide it in your build platform definition later.
- Configure the container for public access as described in publicly accessible as explained in Serving images publicly. For more information, see Pushing and Pulling Images.
Specifying the build platform definition
You must include a Bazel platform configuration in your custom toolchain configuration, which allows Bazel to select a toolchain appropriate to the desired hardware/software platform. To generate automatically a valid platform, you can add to yourWORKSPACE an
rbe_autoconfig target with name buildkite_config which includes additional
attrs to select your custom container. For details on this setup, read
the up-to-date documentation for rbe_autoconfig.