Skip to content

Bazel

Bazel CI on GitHub Actions

Bazel's whole value is caching, and CI throws the cache away every run.

24m → 8m
Cold build
24m → 90s
Warm build
96%
Action cache hit

Bazel's whole value is caching, and CI throws the cache away every run.

Why it happens

The local disk cache and repository cache are not persisted, so every action re-executes despite Bazel knowing better.

What to change

  1. Point --disk_cache at a persisted directory and cache it between runs
  2. Add a remote cache so every developer and every CI job share results
  3. Cache the repository cache so external dependencies are not re-fetched
  4. Use --jobs matched to the runner core count

Bazel on runnerhut

yaml
jobs:
build:
runs-on: runnerhut-16vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- run: |
bazel build //... \
--disk_cache=~/.cache/bazel \
--repository_cache=~/.cache/bazel-repo \
--jobs=16
A working starting point

The only runnerhut-specific line is `runs-on: runnerhut-16vcpu-ubuntu-2404`. Everything else is standard GitHub Actions — the same actions, the same secrets and the same permissions model you use today.

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.