-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[NET-5619] ci: Single source of truth for Go version in CI and Dockerfile #20058
Conversation
35f9114
to
01567a7
Compare
d02fcc3
to
9379260
Compare
Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21.
9379260
to
ea888cd
Compare
Just to note, backports will probably end up being semi-manual for this change; I've labeled the PR to reflect the intended backports for now. |
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.
This is a great quality of life change @zalimeni! This will make things much easier going forward. Thanks for the well thought out breakdown of the work and future considerations as well!
@@ -91,6 +97,7 @@ jobs: | |||
- name: Install Go | |||
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | |||
with: | |||
# Do not explicitly set Go version here, as it should depend on what Nomad declares. |
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.
👨🍳
Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21. c.f. hashicorp/consul#20058
Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21. c.f. hashicorp/consul#20058
Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21. c.f. hashicorp/consul#20058
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.
Awesome! It is these sorts of 'little' changes that just chip away at making all things easier.
Thanks so much for taking this on!
@zalimeni, a backport is missing for this PR [20058] for versions [1.15,1.16,1.17] please perform the backport manually and add the following snippet to your backport PR description:
|
While we defer to other projects w.r.t. how they are built, we should run our tests (and Consul code) using the current latest version we declare. Follow-up to #20058.
@zalimeni, a backport is missing for this PR [20058] for versions [1.15,1.16,1.17] please perform the backport manually and add the following snippet to your backport PR description:
|
@zalimeni, a backport is missing for this PR [20058] for versions [1.15,1.16,1.17] please perform the backport manually and add the following snippet to your backport PR description:
|
Unlike the Nomad tests (where Nomad is compiled from source and provides the tests), Vault is installed as a binary, and local Consul tests are run. Fixes incorrect version change introduced in #20058.
Unlike the Nomad tests (where Nomad is compiled from source and provides the tests), Vault is installed as a binary, and local Consul tests are run. Fixes incorrect version change introduced in #20058.
Unlike the Nomad tests (where Nomad is compiled from source and provides the tests), Vault is installed as a binary, and local Consul tests are run. Fixes incorrect version change introduced in #20058.
Description
To simplify Go version management and enable simpler conflict-less (CE + Ent) upgrades in the future, move all Go version management for CI, Docker builds, and related tooling to a single source of truth.
To do this, introduce a new
.go-version
file and reusable workflow to read it that all jobs usingsetup-go
can depend on. Having a separate reusable job allows multiple dependent jobs to use the version after it's determined once. It also enables us to centralize control over the version in our own CI config rather than depending on the behavior ofsetup-go
or other imported actions (see more below).Make all reusable workflows require a Go version as input s.t. we can ensure it is always provided.
Rationale
We have two needs for our CI when it comes to Go versions:
When we upgrade to Go 1.21, we'll have the new
toolchain
directive available in addition to thego
directive. More on how these work here; the salient point is that Go now attempts to install the correct toolchain for us when we update thego
ortoolchain
directive and the local version of Go does not satisfy those versions. It also means that thego
directive provides an enforced minimum version, not the suggested one.However, this presents some rough edges in CI:
setup-go
does not yet supporttoolchain
detection (see also Tar errors on cache restore after toolchain installation actions/setup-go#424)setup-go
and the one required locally; this sort of mistake would be easy to overlooksetup-go
, we rely onhashicorp/action-go-build
to produce binaries, which has a required input for the Go version that is not managed bysetup-go
; managing this separately fromsetup-go
runs the risk of error when changing Go versionsGiven these constraints, and the clarity provided by setting essential versions explicitly to avoid confusion or side-effect mistakes, this change proposes enforcing a consistently installed Go version throughout our workflows, still allowing for explicit overrides where we need a different version. It's easy to reverse if we want to go back to individual
go-version-file
declarations.Futures
My hope is that we can move to calling
go version
to retrieve thetoolchain
version provided in Go 1.21+, as well as introduce a versionedgo.work
in the near future (which will bring several benefits, including removing submodulereplace
s, explicitly setting Go version via a singletoolchain
directive). The current change allows us to control the version from a single source of truth in CI, which is beneficial regardless of Go-native toolchain management changes in the future.Testing & Reproduction steps
PR Checklist