Skip to content

Accelerated Go CI for GitHub Actions

Go builds are CPU-heavy and cache-hungry. RunsOn gives you huge CPU counts (up to 896 vCPUs) 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 (16–896 vCPUs) 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

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 ./...

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 ./...

With extras=s3-cache, the S3-backed Magic Cache accelerates:

  • Go build cache: $GOCACHE (default ~/.cache/go-build)
  • Module cache: $GOMODCACHE (default ~/go/pkg/mod)

Optional explicit cache (Magic Cache will still speed it up):

- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
  • 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
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@v4
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
OptimizationHow to enable
Huge CPU countsrunner=32cpu-linux-x64 (or 64/128/896)
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