-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid Toolchain download before cache download #456
Avoid Toolchain download before cache download #456
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
src/main.ts
Outdated
// 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Also handle lookups on cache restore
The code is a bit messy right now, but I just want to get a PoC working, which it looks like it is:
|
#460 is a better solution to this |
Description:
go version
is run before downloading the cache, but if this is run with a version ofgo
that triggers a Toolchain download[1], e.g. if the installed Go is 1.20.0 butgo.mod
has a toolchain directivego1.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:Instead, force
go
to use the local toolchain (i.e. the one the one that shipped with the go command being run) via setting theGOTOOLCHAIN
environment variable[1]:[1] https://go.dev/doc/toolchain#select
Related issue:
This addresses #424
Check list: