hn.today

Scaling Golang CI by Replacing actions/setup-go

cloudx.ai61 points17 comments
Screenshot of Scaling Golang CI by Replacing actions/setup-go

This describes replacing GitHub’s actions/setup-go with a drop-in replacement, cloudx-io/setup-go, to dramatically speed up parallel Go CI jobs by better leveraging the Go toolchain’s caches. The team found that the default setup-go’s cache key is too coarse (OS, arch, Go version, go.mod hash), so successive runs restore an increasingly stale cache and parallel jobs race to write the same key. In their monorepo this caused most work to be redundant; backtesting showed ~86% of the default action’s work was unnecessary and switching to cloudx-io/setup-go cut a test job’s runtime by 69% (they reported a problematic regression from 76s median to 180s median that was resolved).

Technically, Go already stores module downloads in GOMODCACHE and build/test artifacts in GOCACHE using content-hashed keys, but GitHub’s actions/cache only saves an immutable blob when the requested key misses. cloudx-io/setup-go preserves the Go toolchain’s high hit rates across ephemeral runners by making job identity part of the Actions cache key (including a cache-key-prefix, ref name, go.sum hash and run id) so lint, build, and test jobs use separate caches and every run writes a fresh cache entry. The tradeoff is more cache writes and storage cost in exchange for reliable, parallelizable, much faster CI; the implementation is open source.

Read on cloudx.ai17 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.