Skip to content
Documentation

Docs / Adapter commands / Bazel REAPI

Bazel REAPI adapter

Use Bazel’s REAPI cache from local builds, or send Bazel actions to one Linux worker with --remote.

Command
boringcache bazel-reapi
Protocol
REAPI gRPC cache and optional Linux remote execution
Action
mode: bazel-reapi

How the adapter works

Native client configuration

Choose bazel for HTTP or bazel-reapi for gRPC. Both download top-level outputs by default. Set download-outputs to all, toplevel, or minimal; remote-max-connections sets the connection limit. HTTP and REAPI cache entries use different namespaces; selecting the same tag does not migrate entries between protocols.

Shared cache lifecycle

In cache mode, the adapter selects the cache tag, starts a loopback REAPI endpoint, runs Bazel, and drains cache writes before shutdown. Bazel runs cache misses locally.

Read and write policy

Read-only runs do not publish cache entries. Trusted writable runs may publish. Unknown or misplaced adapter options fail before cache startup.

Set up Bazel REAPI

Commit this configuration and run boringcache bazel-reapi. Omit command when the Action should prepare caching for several later commands. Choose bazel for HTTP or bazel-reapi for gRPC. Both download top-level outputs by default. Set download-outputs to all, toplevel, or minimal; remote-max-connections sets the connection limit. HTTP and REAPI cache entries use different namespaces; selecting the same tag does not migrate entries between protocols.

workspace = "my-org/my-project"

[adapters.bazel-reapi]
tag = "bazel-reapi-build"
command = ["bazel", "build", "//..."]

[adapters.bazel-reapi.options]
download-outputs = "toplevel"
remote-max-connections = 64

Before the first run

  • Install the project's Bazel version on the caller.
  • Use an empty REAPI instance name.
  • Remote execution requires BoringCache CLI 1.50.0 or later on a Linux or macOS caller. The Linux worker needs util-linux setpriv and the project’s Linux execution tools.

Remote execution

One Linux remote

Add a named remote in .boringcache.toml. Use a dedicated, trusted Linux worker. The SSH user needs root access or passwordless sudo. The executor runs one session at a time on the worker. Actions share its memory and disk without aggregate quotas. BoringCache starts the execution and cache endpoint and forwards it over SSH. Bazel analyzes the build and schedules actions on the caller.

One Linux remote
[remotes.linux]
provider = "ssh"
host = "builder.example.com"

Select a Linux execution platform

Register a Linux execution platform and a toolchain that can run on the worker. Set the platform’s execution properties to OSFamily=linux and ISA=arm-a64 for ARM64 or ISA=x86-64 for AMD64. The worker needs any tools the toolchain does not supply as action inputs. On macOS, select a Linux toolchain for the remote actions.

The command below assumes your Bazel configuration defines linux-reapi and selects that execution platform and toolchain. Use --dry-run --json on the BoringCache command to review the remote selection before starting a worker.

Select a Linux execution platform
boringcache bazel-reapi --remote linux -- bazel build --config=linux-reapi //...

Cache access and output downloads

A read-only build can send inputs and execute actions. New results stay in the invocation’s storage. Writable builds can publish reusable remote action results to the shared cache. Bazel downloads top-level outputs by default.

Omit --remote to use the cache with local execution. The GitHub Action’s bazel-reapi mode configures the cache. Invoke the CLI with --remote when your job needs remote execution. Remote Runs show cache requests. Use --native-tool-evidence-json PATH on the caller to collect remote action records.

Bazel actions

What is recorded

With Bazel 7.4 or later, the CLI adds --execution_log_compact_file after bazel build, bazel test, bazel run and bazel coverage. Bazel writes a compressed record of each action it ran or served from a cache to a temporary file, and the CLI reads it after the command and removes it. The flag does not change action keys, and Bazel keeps its analysis cache between builds.

For builds using local execution, the run page and run API list each recorded action: its target and mnemonic, where it ran, whether the remote cache or a disk cache served it, its exit code, and when it started and how long it took. Command lines, environment variables and input files are not recorded.

Cache requests record their result, size and duration for both local and remote execution.

Commands without actions

A command that passes its own --execution_log_json_file, --execution_log_binary_file or --execution_log_compact_file keeps its log, and the CLI records no actions. The same applies when any line of a bazelrc file the command loads contains an execution log option, including a line for a config the command does not use, because Bazel accepts only one execution log. Before it adds the flag, the CLI runs bazel --version with the command's environment; when Bazel is older than 7.4 or reports no version within 10 seconds, the command runs unchanged and the CLI records no actions. Commands that run no actions, such as bazel query, and commands run through another program record only the cache requests.

Building inside Docker? Follow the Docker REAPI tool-cache setup to select this tool, its cache tag, and its read/write policy.

Use the same adapter in GitHub Actions

A committed adapter command runs in this Action step. Without one, the Action prepares caching for later tool commands and removes its temporary configuration after stopping the client and cache service.

.github/workflows/ci.yml
- uses: boringcache/one@6b680206950cc926444c045302370653fae538f1 # v1.50.0
  with:
    trust-policy: auto
    mode: bazel-reapi

Approve the repository through Connect CI and grant the job contents: read and id-token: write. The Action uses that Machine connection. Pull requests restore by default; trusted jobs may publish. See the authentication example in the GitHub Actions reference for scoped credentials when OIDC is unavailable.

GitHub Actions reference

Benchmarks

Native client cold and warm cache qualification is separate from an OSS project benchmark. No project speedup is claimed for this managed adapter.

Tool reference

Check the tool's own reference when you need cache-key rules, build settings, or version-specific behavior.

All adapter commands

Compare every supported command, protocol, and Action mode in one place.

Adapter command index →

Need help or found something unclear? Open an issue or browse the CLI repo.