-
Notifications
You must be signed in to change notification settings - Fork 805
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
Adopt Go toolchains for language-version-control #6063
Conversation
which seems pretty good. CI has a bunch of lines like
which could be handled more quietly by querying but maybe. or maybe there's a different, better option somewhere. not sure at the moment. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filessee 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Pull Request Test Coverage Report for Build 018fb74e-8f78-4b91-acc2-561eb11fc052Details
💛 - Coveralls |
Go 1.21 brought us "toolchains": We can now describe the version we want, and the Go CLI will automagically download, install, and use that version, with no extra effort. It should give us a MUCH more reliable way to ensure identical builds and formats and whatnot, and all us devs will auto-switch as we jump between git SHAs. So let's use that! This does a few things: - requires Go 1.21+ to be your `go` version to *work on* Cadence. - this does not force our *users* to use 1.21+, that's still 1.20, controlled by the `go 1.20` lines. just development in this workspace. - sets a `go.work` toolchain (if there's a `go.work` file, toolchains in individual `go.mod` files are ignored) - not all IDEs follow this. we could set it + lint it in the `go.mod` files too if it helps, it just won't have any effect on CLI `go` use so it may be misleading. - exports `GOTOOLCHAIN=...` inside the Makefile, so ALL makefile-driven builds by everyone use exactly the same version (you can override this with an explicit `GOTOOLCHAIN`) - updates our dockerfiles (it would just download [wrong version in docker image] and then auto-download the right one, which is a waste of time) - adds a lint script to ensure ^ all that stays up to date --- For future upgrades, upgrading the toolchain should be very simple: - change `go.work` to a new toolchain version - everything now uses the new language version, tools and binaries will rebuild, etc. - `make lint` or `make pr` or CI will tell you to change the Dockerfiles / other locations, if you don't `git grep -F 1.22.3` to find and update those first. And temporarily trying a different version to check a bug / performance / try the new version is: - `GOTOOLCHAIN=go1.23.4 make whatever` and it'll do exactly that (except for the version check in `make lint`) - you may want to `make clean` as well, to rebuild tools if that's relevant - they will not automatically rebuild with this env var changing. they *could*, if we used `.build/go1.23.4/etc` folders, if we want that.
Go 1.21 brought us "toolchains":
We can now describe the version we want, and the Go CLI will automagically download, install, and use that version, with no extra effort. It should give us a MUCH more reliable way to ensure identical builds and formats and whatnot, and all us devs will auto-switch as we jump between git SHAs.
So let's use that!
This does a few things:
go
version to work on Cadence.go 1.20
lines. just development in this workspace.go.work
toolchain (if there's ago.work
file, toolchains in individualgo.mod
files are ignored)go.mod
files too if it helps, it just won't have any effect on CLIgo
use so it may be misleading.GOTOOLCHAIN=...
inside the Makefile, so ALL makefile-driven builds by everyone use exactly the same version (you can override this with an explicitGOTOOLCHAIN
)For future upgrades, upgrading the toolchain should be very simple:
go.work
to a new toolchain versionmake lint
ormake pr
or CI will tell you to change the Dockerfiles / other locations, if you don'tgit grep -F 1.22.3
to find and update those first.And temporarily trying a different version to check a bug / performance / try the new version is:
GOTOOLCHAIN=go1.23.4 make whatever
and it'll do exactly that (except for the version check inmake lint
)make clean
as well, to rebuild tools if that's relevant.build/go1.23.4/etc
folders, if we want that.