GeezerVison is showing github.com — Add option to restore cache only · Issue #316 · actions/setup-go
Add option to restore cache only #316DescriptionReacted by Greg Weber, Mitch Fierro, Enrico Minack, TheoAlloin, Alex Crawford, Otto Richter (fnetX), Bryce Lampe, Brian Conway, Nelz, Teppei Fukuda and 23 more Activitye-korolevskii commented on Jan 11, 2023 Hello @ForsakenHarmony! Thank you for the suggested idea!
We will consider adding this feature and will let you know as soon as we have any decision. gwatts commented on Jan 19, 2023 ForsakenHarmony commented on Feb 1, 2023 @gwatts yes, I'm doing that, doing it after each commit's CI is done actually, but it's an ugly workaround dsame commented on Apr 5, 2023 Reacted by Donald Silveira Reacted by hrmny, Enrico Minack, Otto Richter (fnetX) and Brian Conway lzap commented on May 17, 2023 We would love this feature too. Our CI pipeline consist of:
- build job (runs
go build)
- test job (runs
go test)
When cache is enabled (default in v4) and there is a change in go.sum both jobs run in parallel but because our build job is slower, test job wins and uploads the cache. Problem is, the test job does not build all code path - only those which are executed by unit tests. The next time cache is downloaded, build job will use the cache created by test job which is not 100% so this is leading to wasted CPU cycles.
We would like to configure test job to "download only", basically ability to disable the setup-go post hook uploading the cache. lzap commented on May 17, 2023 How do I use lookup-only with setup-go? dsame commented on Jul 10, 2023 Reacted by Mark Nevill Reacted by Lukáš Zapletal lzap commented on Jul 11, 2023 Unfortunately, I am having hard time figuring out how setup-go creates the cache key. The SHA sums for my case do not match for some reason: setup-go-Linux-go-1.19.6-2ecd730a3adf2d5167ee1676ce4793359350a5aef4bc40807996837393159830
It does not match:
$ sha256sum go.sum go.mod
8aeed24d8b1117586e0d269bbe1861de7bfcde3cbdf78e8dea77c6e0bea565cf go.sum
f1da5013a602ea3becd1c57d497592f7cdce5390d7ddc0ebab0d7b0b8475e33f go.mod
Are you saying that I need to completely disable go caching and write caching myself (both store and retrieve)? That is exactly what I don’t want to do and the primary reason why I 👍🏻 on this issue.
Frankly either a key prefix/suffix or some sort of "lookup-only" flag that would be passed into the cache action would be really cool. I don’t know TS/JS so crossing my fingers this gets picked up sometime. Not a big deal for our project right now, we disabled caching for some actions for now. dsame commented on Jul 12, 2023 Reacted by Mark Nevill, Bryce Lampe and pura-tainguyen lzap commented on Jul 12, 2023 Hey thanks for comment, I understand, however, let me argue that the behavior is not documented at the moment. I had hard time figuring out how hash is actually calculated, I had no idea that both files are concatenated and in this order. Maybe this issue could be turned into documentation change.
Still I think this could be useful feature for couple of reasons. A single option is much easier to write than additional 5 lines long extra action. It is not just that, please realize that we need this functionality when we have multiple parallel actions which "fight" each other for the initial cache save, so it is not just 5 lines, but 20 lines of copy-pasted YAML for my case (4 actions - build, unit tests, integration tests and linter).
It does not have to be restore cache attribute, this could be easily implemented as cache prefix/suffix attribute which would allow us to create separate caches for various actions which interfere witch each other.
Finally, when setup-go action authors decide to change the key pattern, it will break others pipelines and it will be pain to figure it out. A consistency is my last argument. And with that, I will, again, thank you for your comment and effort you put into this project. I will try to implement what you suggested now. lzap commented on Jul 12, 2023 Oh I just learned that it is not just 5 lines, what you pasted is not functional example. I need to figure out path to dependencies that is another action. Also the key does not match what I see. I guess I will keep cache disabled for tests in our case :-( v-aparnajyothi-y commented on Dec 17, 2025 Hello Everyone, Thanks everyone for your patience and contributions. This issue reported here has been addressed in #696. The documentation helps cache state restoration handling.
Please feel free to reach us in case of any further clarifications/concerns :) gavinsharp commented on Dec 17, 2025 @aparnajyothi-y documentation for how to implement custom caching yourself is not really addressing this request, which is an easy-to-use feature to achieve the same result without custom caching logic (which needs to be maintained as toolchains evolve) v-aparnajyothi-y commented on Dec 23, 2025 Hello @gavinsharp, thanks for following up and really appreciate the clear explanation.
You’re right that documenting custom caching doesn’t fully address the request for a simple, built-in restore-only feature. The intent of #696 was to provide guidance for what’s possible today, while keeping setup actions opinionated to ensure predictable and safe caching without requiring manual key management.
For teams with advanced or highly customized caching needs, actions/cache remains the recommended approach, as it provides full control for more complex setups.
Please don’t hesitate to reach out if there are any further questions or clarifications. :) v-aparnajyothi-y commented on Jan 5, 2026 Hello everyone, a gentle follow-up to check if there are any remaining questions, concerns, or clarifications needed around the approach documented in #696.
If there are additional use cases or gaps you’d like us to revisit, please feel free to share. We’re happy to continue the discussion and help where possible. fingon commented on Jan 5, 2026 To reiterate the earlier comments, documenting a workaround does not feel same as providing the feature that I (among others) need. At least I am not sticking that workflow blob to (number of) repos that need it, and having ~one-liner to do this would be much better.
I just live with suboptimal cache usage where it doesn't matter and burn some free GHA minutes. Where it actually costs me/us money, I have already done similar (but bit simpler as I don't need to e.g. care about Windows) hacks. v-aparnajyothi-y commented on Jan 29, 2026 Hello @fingon, Thanks for your input! Currently, #696 documents how to restore cache using existing workflows, but we understand it doesn’t provide a simple one-liner for “restore-only.”
We’re monitoring community interest and may revisit this in the future. For now, actions/cache remains the recommended approach for advanced or customized caching needs.
Please don’t hesitate to reach out if there are any further questions or clarifications. :) atoulme commented on Feb 13, 2026 What is the threshold for community interest? Reacted by Edward Muller and wizardist atoulme commented on May 26, 2026 Hello folks, this issue has 30 upvotes as of today. Is this enough to warrant revisiting?
I have a PR with a 5 line change to implement this. Reacted by Nelz, Markus Stenberg, Benjamin Rea and Taras atoulme commented on Jul 21, 2026 I have not heard back. Any chance we can get a response here?
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|