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 point | RunsOn solution |
|---|---|
Long go build / go test on small runners | Launch very large runners (16–896 vCPUs) to finish faster |
| Go build & module caches are big | S3 Magic Cache: unlimited, fast restore/save |
| GitHub cache size limits | No 10GB cap; keep caches warm across runs |
| Expensive large runners | Spot instances for ~90% savings |
Quick start (2-line change)
Section titled “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 ./...Scale CPUs instead of splitting
Section titled “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
Section titled “Magic Cache for Go”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') }}Performance tips
Section titled “Performance tips”- Use
-raceon big CPU runners without blowing up runtimes. - For flaky cache cases, add
-count=1to 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-cacheComplete example workflow
Section titled “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@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.outSummary
Section titled “Summary”| Optimization | How to enable |
|---|---|
| Huge CPU counts | runner=32cpu-linux-x64 (or 64/128/896) |
| Unlimited, fast caching | extras=s3-cache + runs-on/action@v2 |
| ARM64 (cheaper) | runner=32cpu-linux-arm64 |
| Optional explicit cache | Cache ~/.cache/go-build and ~/go/pkg/mod |