-
Notifications
You must be signed in to change notification settings - Fork 530
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
More specific handling/detection of Go toolchain versions #457
Comments
Hello @matthewhughes934 |
switch off of `go-version-file` in the Github Actions, because it doesn't work great with the new `go mod tidy` format that go 1.22 does. See: * [Improve toolchain handling actions/setup-go#460](actions/setup-go#460) * [More specific handling/detection of Go toolchain versions actions/setup-go#457](actions/setup-go#457)
switch off of `go-version-file` in the Github Actions, because it doesn't work great with the new `go mod tidy` format that go 1.22 does. See: * [Improve toolchain handling actions/setup-go#460](actions/setup-go#460) * [More specific handling/detection of Go toolchain versions actions/setup-go#457](actions/setup-go#457)
switch off of `go-version-file` in the Github Actions, because it doesn't work great with the new `go mod tidy` format that go 1.22 does. See: * [Improve toolchain handling actions/setup-go#460](actions/setup-go#460) * [More specific handling/detection of Go toolchain versions actions/setup-go#457](actions/setup-go#457)
Any updates on this @HarithaVattikuti ? |
Would love to see this getting more attention, especially since there's an associate PR. The |
I got some tests which switched to 1.23.0. As a workaround, setting the
|
Is it enough to only add env to setup-go steps? Will go download new toolchain in following steps? |
Argl, the next step did just that:
Okay, guess it needs to be everywhere. Edit: that works. My tests now fail nicely when there are some vendored libs which need 1.23. |
github actions supports setting env for whole job or jobs in same workflow |
@trim21 is right, this works for now as a workaround:
in .github/workflows/youraction.yml (Now back to what I should be doing, instead of fighting with build tools.) |
This PR makes the CI pipeline use Go 1.23 for building and testing. Only setting the `toolchain` in `go.mod` is not enough, because the [setup-go action does not support the `toolchain` directive yet](actions/setup-go#457), we have to set the Go version to 1.23 in all setup-go CI steps manually. We could also set the `go` version in `go.mod` to 1.23 since we do not have any dependents, but that would be misusing the `go` directive, since it is only intended to specify the minimum supported language version of the project.
I hope this action respects Here is a workaround to install the jobs:
test:
steps:
- uses: actions/checkout@v4
- id: toolchain
run: echo "version=$(sed -ne '/^toolchain /s/^toolchain go//p' go.mod)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.toolchain.outputs.version }} |
Description:
The goal is to just have an approach to manage toolchain installs, the following is a suggestion and open to discussion/changes:
GOTOOLCHAIN=local
in the environment, see docs)go-version-file
, and:The file has a
toolchain
directive: then use that since the docs sayThis is in comparison with the
go
version, which is the minimum version of Go required to install the module (the assumption being: we're working within the module, not install it)The file has no
toolchain
directive: then use the version from thego
directive (current behaviour)Justification:
At the moment this action does not consider toolchain versions. This leads to:
1.21.0
) but yourgo.mod
contains a toolchain directive for a newer version (e.g.1.22.0
) then, without any other configuration/environment setup, anygo
commands will be run usinggo 1.22.0
You can see this in this example repo, which is just a repo with a
go.mod
whosego
directive is1.21.0
and whose toolchain directive is1.22.0
and some actions that display the version of Go under some conditions, of interest is when we specify the action with version1.21.0
: we ask for1.21.0
but a toolchain install will result in1.22.0
being installed and runAre you willing to submit a PR?
Yep, but there should be some discussion around which approach to take before implementing anything
EDIT: I noticed that the official Go docker images also set
GOTOOLCHAIN=local
https://github.com/docker-library/golang/blob/dae3405a325073e8ad7c8c378ebdf2540d8565c4/Dockerfile-linux.template#L162C3-L163C1 with some discussion on the linked issue there: docker-library/golang#472The text was updated successfully, but these errors were encountered: