Avoid Toolchain download before cache download#456
Closed
matthewhughes-uw wants to merge 7 commits intoactions:mainfrom
Closed
Avoid Toolchain download before cache download#456matthewhughes-uw wants to merge 7 commits intoactions:mainfrom
matthewhughes-uw wants to merge 7 commits intoactions:mainfrom
Conversation
`go version` is run before downloading the cache, but if this is run with a version of `go` that triggers a Toolchain download[1], e.g. if the installed Go is 1.20.0 but `go.mod` has a toolchain directive `go1.20.1` then a toolchain is downloaded to e.g. `$GOMODCACHE/golang.org/toolchain@v0.0.1-go1.21.1.linux-amd64`, if this file already exists in the cache (e.g. this is the second run of this action we not cache invalidation) then the cache download will try and overwrite these files resulting in noisy errors like: /usr/bin/tar: ../../../go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.6.linux-amd64/lib/time/mkzip.go: Cannot open: File exists Instead, force `go` to use the local toolchain (i.e. the one the one that shipped with the go command being run) via setting the `GOTOOLCHAIN` environment variable[1]: > When GOTOOLCHAIN is set to local, the go command always runs the bundled Go toolchain. This addresses actions#424 [1] https://go.dev/doc/toolchain#select
matthewhughes-uw commented Feb 8, 2024
src/main.ts Outdated
Comment on lines +65 to +68
| // run `go version` with the bundled Go toolchain to avoid potentially | ||
| // downloading one into the cache | ||
| const goVersion = (cp.execSync(`${goPath} version`) || '', | ||
| {env: {...process.env, GOTOOLCHAIN: 'local'}}).toString(); |
Author
There was a problem hiding this comment.
Happy to hear any suggestions for testing this (i.e. test that a toolchain isn't downloaded)
EDIT: testing via https://github.com/matthewhughes-uw/setup-go-test, looks like I missed something
5 tasks
Also handle lookups on cache restore
Author
| The code is a bit messy right now, but I just want to get a PoC working, which it looks like it is:
|
Author
| #460 is a better solution to this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
go versionis run before downloading the cache, but if this is run with a version ofgothat triggers a Toolchain download[1], e.g. if the installed Go is 1.20.0 butgo.modhas a toolchain directivego1.20.1then a toolchain is downloaded to e.g.$GOMODCACHE/golang.org/toolchain@v0.0.1-go1.21.1.linux-amd64, if this file already exists in the cache (e.g. this is the second run of this action we not cache invalidation) then the cache download will try and overwrite these files resulting in noisy errors like:Instead, force
goto use the local toolchain (i.e. the one the one that shipped with the go command being run) via setting theGOTOOLCHAINenvironment variable[1]:[1] https://go.dev/doc/toolchain#select
Related issue:
This addresses #424
Check list: