This repository hosts the Bazel remote caching and execution system.
Background information on the status of caching and remote execution in bazel can be found in the bazel documentation.
File issues here for bugs or feature requests, and ask questions via build team slack in the #buildfarm channel.
All commandline options override corresponding config settings.
Bazel Buildfarm Server
bazel run //src/main/java/build/buildfarm:buildfarm-server <configfile> [<-p|--port> PORT]
configfilehas to be in Protocol Buffer text format, corresponding to a BuildFarmServerConfig definition.
For an example, see the examples directory, which contains the working example examples/server.config.example. For format details see here. Protocol Buffer structure at src/main/protobuf/build/buildfarm/v1test/buildfarm.proto
PORTto expose service endpoints on
Bazel Buildfarm Worker
bazel run //src/main/java/build/buildfarm:buildfarm-operationqueue-worker <configfile> [--root ROOT] [--cas_cache_directory CAS_CACHE_DIRECTORY]
configfilehas to be in Protocol Buffer text format, corresponding to a WorkerConfig definition.
For an example, see the examples directory, which contains the working example examples/worker.config.example. For format details see here. Protocol Buffer structure at src/main/protobuf/build/buildfarm/v1test/buildfarm.proto
ROOTbase directory path for all work being performed.
CAS_CACHE_DIRECTORYis (absolute or relative) directory path to cached files from CAS.
To use the example configured buildfarm with bazel (version 1.0 or higher), you can configure your
.bazelrc as follows:
$ cat .bazelrc build --remote_executor=grpc://localhost:8980
Then run your build as you would normally do.
You can use typical Java logging configuration to filter these results and observe the flow of executions through your running services.
logging.properties file has been provided at examples/debug.logging.properties for use as follows:
bazel run //src/main/java/build/buildfarm:buildfarm-server -- --jvm_flag=-Djava.util.logging.config.file=$PWD/examples/debug.logging.properties $PWD/examples/server.config.example
bazel run //src/main/java/build/buildfarm:buildfarm-operationqueue-worker -- --jvm_flag=-Djava.util.logging.config.file=$PWD/examples/debug.logging.properties $PWD/examples/worker.config.example
To attach a remote debugger, run the executable with the
--debug=<PORT> flag. For example:
bazel run //src/main/java/build/buildfarm:buildfarm-server -- --debug=5005 $PWD/examples/server.config.example
Setting up intelliJ
- Follow the instructions in https://github.com/bazelbuild/intellij to install the bazel plugin for intelliJ
- Import the project using
Most third-party dependencies (e.g. protobuf, gRPC, ...) are managed automatically via
rules_jvm_external. These dependencies are enumerated in
the WORKSPACE with a
Things that aren't supported by
rules_jvm_external are being imported as manually managed remote repos via
Buildfarm can be used as an external repository for composition into a deployment of your choice.
Add the following to your WORKSPACE to get access to buildfarm targets, filling in the commit and sha256 values:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") BUILDFARM_EXTERNAL_COMMIT = "<revision commit id>" BUILDFARM_EXTERNAL_SHA256 = "<sha256 digest of url below>" http_archive( name = "build_buildfarm", strip_prefix = "bazel-buildfarm-%s" % BUILDFARM_EXTERNAL_COMMIT, sha256 = BUILDFARM_EXTERNAL_SHA256, url = "https://github.com/bazelbuild/bazel-buildfarm/archive/%s.zip" % BUILDFARM_EXTERNAL_COMMIT, ) load("@build_buildfarm//:deps.bzl", "buildfarm_dependencies") buildfarm_dependencies() load("@build_buildfarm//:defs.bzl", "buildfarm_init") buildfarm_init()
Optionally, if you want to use the buildfarm docker container image targets, you can add this:
load("@build_buildfarm//:images.bzl", "buildfarm_images") buildfarm_images()