self-host →

Accelerated Go CI for GitHub Actions

Speed up Go builds with massive CPU runners and unlimited S3-backed caching on RunsOn.

Go builds are CPU-heavy and cache-hungry. RunsOn gives you high CPU counts (up to 64 vCPUs out of the box, more via cpu=/family=) and S3-backed caching so you can slash runtimes and costs.

Pain pointRunsOn solution
Long go build / go test on small runnersLaunch very large runners (up to 64 vCPUs out of the box, more via cpu=/family=) to finish faster
Go build & module caches are bigS3 Magic Cache: unlimited, fast restore/save
GitHub cache size limitsNo 10GB cap; keep caches warm across runs
Expensive large runnersSpot instances for ~90% savings

Quick start (2-line change)

Once RunsOn is installed:

jobs:
test:
runs-on: runs-on=${{ github.run_id }}/runner=16cpu-linux-x64/extras=s3-cache
steps:
- uses: runs-on/action@v2
- uses: actions/checkout@v6
- uses: actions/setup-go@v5
with:
go-version: "1.25"
- run: go test ./...

setup-go caches $GOCACHE/$GOMODCACHE automatically (cache: true by default); with extras=s3-cache those cache reads/writes hit the S3 Magic Cache instead of GitHub’s backend.

Scale CPUs instead of splitting

Go is CPU-bound and not very memory-hungry. Use a single large runner instead of many matrix shards:

jobs:
test:
runs-on: runs-on=${{ github.run_id }}/runner=64cpu-linux-x64/extras=s3-cache
steps:
- uses: runs-on/action@v2
- uses: actions/checkout@v6
- uses: actions/setup-go@v5
with:
go-version: "1.25"
- name: Run tests (race)
run: go test -race ./...

Magic Cache for Go

With extras=s3-cache, Magic Cache swaps the GitHub Actions cache backend for a fast, unlimited S3 cache in your VPC. It accelerates anything that uses actions/cache — including actions/setup-go, which caches $GOCACHE (~/.cache/go-build) and $GOMODCACHE (~/go/pkg/mod) automatically (cache: true is the default). Magic Cache does not snapshot directories on its own; the caching still flows through actions/cache.

To cache Go paths explicitly (instead of relying on setup-go’s built-in cache):

- uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}

Performance tips

  • Use -race on big CPU runners without blowing up runtimes.
  • For flaky cache cases, add -count=1 to force rebuilds.
  • ARM64 runners are cheaper and Go binaries are usually fine on ARM:
runs-on: runs-on=${{ github.run_id }}/runner=32cpu-linux-arm64/extras=s3-cache

Complete example workflow

name: Go CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: runs-on=${{ github.run_id }}/runner=64cpu-linux-x64/extras=s3-cache
env:
GOMODCACHE: ~/go/pkg/mod
GOCACHE: ~/.cache/go-build
steps:
- uses: runs-on/action@v2
- uses: actions/checkout@v6
- uses: actions/setup-go@v5
with:
go-version: "1.25"
- uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Test (race + coverage)
run: go test -race -coverprofile=coverage.out ./...
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage.out

Summary

OptimizationHow to enable
Huge CPU countsrunner=64cpu-linux-x64 (predefined max), or cpu=96/family=c7i for more
Unlimited, fast cachingextras=s3-cache + runs-on/action@v2
ARM64 (cheaper)runner=32cpu-linux-arm64
Optional explicit cacheCache ~/.cache/go-build and ~/go/pkg/mod