Bazel integration

Bazel is a popular build system optimized for polyglot, large monorepos.

Namespace provides high-performance Bazel caching with very low network latency between runners and the cache storage. This allows your Bazel workflows to reuse build artifacts across runs, irrespective of your chosen granularity, significantly reducing build times.

Bazel caching is particularly effective for:

  • Build steps that are time-consuming to execute but produce relatively small outputs
  • Projects where compilation is typically slow, such as Rust and C++ codebases
  • Workflows that can benefit from cross-invocation artifact reuse

Getting started

To use Bazel caching, you can produce a ready-to-use configuration using the CLI:

Configure cache access

$ nsc bazel cache setup --bazelrc /etc/bazel.bazelrc

This command generates short-term credentials, and sets up a bazelrc configuration file.

Use the Bazel cache

$ bazel --bazelrc=/etc/bazel.bazelrc test //..

You can pass multiple configuration files by setting --bazelrc repeatedly, allowing you to combine your existing configuration with Namespace cache access.

GitHub Actions Example

jobs:
build:
runs-on: namespace-profile-default
steps:
- name: Setup Bazel cache
run: |
nsc bazel cache setup --bazelrc /etc/bazel.bazelrc
- name: Bazel test
run: |
bazel --bazelrc=/etc/bazel.bazelrc test //..

The bazelrc path can be customized if you need to use a specific configuration file. See Bazel's documentation for granularity control options.

How it works

The Bazel caching solution employs a tiered caching approach, where the hot cache lives as close to the consumer (e.g. your CI job runner) as possible. The cold caching tier is backed by our high-performance artifact storage and enables Bazel to retain a vast amount of cached artifacts.

Access to the Bazel cache is granted through short-lived secure credentials.

Usage

Namespace accounts Bazel cache usage in two categories:

  • Bazel cache at rest
  • Active Bazel cache usage

For detailed billing information for each item as well as included amounts in your plans, visit the pricing page.

What's next?

Namespace is highly invested in accelerating Bazel builds through a deeper framework integration. Next up is the ability to horizontally scale your Bazel builds through remote execution on Namespace compute. Reach out to sign up for early access.