‹ BackHN Continuity

Thread

Scaling Golang CI by Replacing actions/setup-go

77 points · 26 comments · peterldowns

  1. JyB · · focus · HN ↗
    Have you considered submitting an upstream patch to the widely used actions/setup-go as well?
    1. peterldowns · · focus · HN ↗
      Good question — we'd be happy to submit a PR, but it's not clear to me that they'd be interested. Some background:

      - Our approach writes new cache entries all the time. This can get expensive, and is a pretty big change in behavior from how actions/setup-go works today.

      - actions/setup-go can basically be considered incredibly critical infrastructure for the public golang ecosystem. Any change in behavior is probably very risky and slow to happen. At this point I'd bet that we see no change, ever, in behavior.

      Additionally there are a few relevant issues/prs that have been ignored for years so I'm not optimistic about contributing upstream. Frankly what we've done is write a very small bit of glue code that is likely most effective as a reference for teams writing their own custom caching actions that fit their exact needs:

      - <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;pull&#x2F;426" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;pull&#x2F;426

      - <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;630" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;630

      - <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;395" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;395

      - <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;596" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;setup-go&#x2F;issues&#x2F;596

      That said we&#x27;d be happy if someone used our code and found it valuable! Lukas put a ton of effort into cleaning up my initial version, added the cache trimming, etc. We depend on this for all of our jobs and use it every day and think it&#x27;s quite good.

      1. qmuntal · · focus · HN ↗
        actions&#x2F;setup-go maintainer here! Great post, I like the ideas in there. We are always open to improvements, but it&#x27;s true that low-risk ones are preferred. Feel free to submit your ideas to the GitHub issue tracker. I&#x27;ll do some due diligence myself.
        1. peterldowns · · focus · HN ↗
          Thanks for reading :) Broken down by key idea:

          - Allowing actions&#x2F;setup-go users to specify a cache key prefix so that they can have more than one golang CI job, each with its own cache: this is 100% worth upstreaming. I believe there are existing requests and PRs about this. Up to you guys to implement however you see fit.

          - Allowing &quot;always update the cache&quot;: also a good idea to enable as an option, very important for non-open-source teams that are trying to maximize cache hit rate.

          - Allowing &quot;trim the cache&quot;: if you&#x27;re going to allow always updating the cache, probably a good idea.

          But the &quot;always update&quot; and &quot;trim&quot; cache changes combine to have a lot of risks regarding cache poisoning that might be bad for open source projects. Lukas may have a different opinion or more to say on this front.

        2. lukasschwab · · focus · HN ↗
          I&#x27;d echo Peter&#x27;s #1 recommendation:

          &gt; - Allowing actions&#x2F;setup-go users to specify a cache key prefix so that they can have more than one golang CI job, each with its own cache [...]

          I&#x27;d actually go further: this may be a sensible default behavior.

          &quot;Always update the cache&quot; can get expensive, but it&#x27;s a neat one; &quot;trim the cache&quot; is definitely necessary if you enable this in a moderately active repository in our experience.

          If you want really out-there ideas: rather than storing and loading the full cache monolithically, you could use a GitHub-specific GOCACHEPROG and Go-specific cache service to load only the active items. The pruning problem goes away because accretion is cheap. In theory, parallel jobs could actually share this joint cache. (This may not be a realistic initiative at GitHub.)

          If you can raise feedback with your colleagues —

          - The docs and settings for Actions Cache limits are really hard to navigate; at some pointed we desperately wanted to pay GitHub more money for more cache, but couldn&#x27;t figure out why we were capped.

          - Bulk-data endpoints for Actions performance would be a boon for optimization projects like this. I wind up either scraping `gh run` (slow) or setting up a GitHub App to collect perf data through webhooks (initially tedious, has to be continuously available).

          All this aside — actions&#x2F;setup-go is a pretty well-considered default and an essential part of writing Go on GitHub; ty for your work maintaining it!

          1. idkasam · · focus · HN ↗

            [dead]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.