Skip to content

Go

Go CI on GitHub Actions

Go builds are fast locally and inexplicably slow in CI.

8m → 2m
Test suite
3× faster
Race detector
97%
Cache hit rate

Go builds are fast locally and inexplicably slow in CI.

Why it happens

The Go build cache lives in ~/.cache/go-build and is empty on every fresh runner, so every package compiles from scratch.

What to change

  1. Cache ~/.cache/go-build and ~/go/pkg/mod keyed on go.sum
  2. Run go build ./... before go test so the build cache is populated once
  3. Use -count=1 deliberately — it disables the test result cache, so only use it when you mean it
  4. Shard large test suites with -run and a matrix rather than buying a bigger machine

Go on runnerhut

yaml
jobs:
test:
runs-on: runnerhut-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version: '1.24', cache: true }
- run: go build ./...
- run: go test -race ./...
A working starting point

The only runnerhut-specific line is `runs-on: runnerhut-8vcpu-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.