Closed grosser closed 3 weeks ago
Welcome @grosser! It looks like this is your first PR to karmada-io/karmada π
Hi @grosser, do you have any documentation on how to use the .go-version
file?
I'm also curious about how it works. I couldn't find more information, except the asdf thing: https://github.com/asdf-community/asdf-golang?tab=readme-ov-file#version-selection
trying with go-version-file
that hopefully works π€
tools like go-env / asdf / mise can read this file to set the local go version
some of them can also read .go.mod
, but asdf and mise refuse to read from it because of some rabbithole
I can see that the .go-version
is working .
π need a CI approval
The karmada's maintainers will return from vacation tomorrow.
/lgtm
I think it's need to squash the commit
squashed into single commit
if single commit is a requirement, making the PR template say it would speed up PRs
and need another approval @liangyuanpeng
and need another approval @liangyuanpeng
Done.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 51.76%. Comparing base (
a0c0a98
) to head (5bdc159
). Report is 6 commits behind head on master.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hey guys, I just made a test on my forked repo, and seems actions/setup-go@v5
can read Go version from go.mod
file.
Here is the change:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6cec21009..3c91b0dbf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,9 +16,9 @@ jobs:
- name: checkout code
uses: actions/checkout@v3
- name: install Go
- uses: actions/setup-go@v3
+ uses: actions/setup-go@v5
with:
- go-version: 1.21.8
+ go-version-file: go.mod
- name: verify license
run: hack/verify-license.sh
- name: vendor
diff --git a/go.mod b/go.mod
index 13d6c12c9..3901dc429 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/karmada-io/karmada
-go 1.21
+go 1.21.1
require (
github.com/adhocore/gronx v1.6.3
I intentionally set the Go version to v1.21.1 instead of the current using version(v1.21.8), to test if it works. The test result shows it indeed works as expected. See the workflow logs here: https://github.com/RainbowMango/karmada/actions/runs/8585586406/job/23527142126#step:3:18
unify version that ci uses
I guess we can solve it by the test approach mentioned on above.
make life easier for anyone using a go version manager
Which go version manager are you using? can it read go version from the go.mod file?
I'm using mise
, which refuses to read the go.mod sadly (already opened issue, but they say "go.mod says what the minimum version is")
(same for asdf
)
go-env does read it though
using go.mod for this and having a .go-version file would also work fine
I'm using mise, which refuses to read the go.mod sadly (already opened issue, but they say "go.mod says what the minimum version is")
Which mise
? Can you share the issue link?
I haven't used mise
before, but I just tried it out. I still don't know how the auto-switching works, and what its benefit is. Can you help to explain it a little bit?
auto-switching switches the go version when cd-ing into a directory according to the directories .go-version
I'm ok with either ... just want someone with merge permission to tell me what they would be willing to merge and will make adjustments accordingly. Would also love to merge as is and create followup for adding to go.mod to move the discussion π€·
Thanks @grosser.
This PR consists of two parts actually as you mentioned in the PR description:
unify version that ci uses
Great thanks for bringing this discussion, really helpful!
This part is clear, that we can add the Go version to go.mod
and let CI
get the version from it.
make life easier for anyone using a go version manager
For this part, I'm evaluating all these go-version managers(mise, asdf, go-env) to figure out the following questions:
.go-version
file a standard way that can be consumed by common go-version managers? Otherwise, consider a situation, where a developer uses another go-version manager which requires a different file, shall we introduce another go-version
file?.go-version
file to somewhere inside the repo(not in the root of repo)? There are already too many scattered files in the root directory.It seems both mise
and asdf
provided the auto-switching feature:
They both support .tool-versions
, can we use this file?
auto-switching switches the go version when cd-ing into a directory according to the directories .go-version
This feature is awesome by the way. Just tried it out.
why would we need .tool-versions, this repo only uses go right ?
yeah, since .tool-versions
can be consumed by both asdf and mise users.
I mean take go.mod
as a single source of truth, and the .tool-versions
dedicated to those go-version managers.
I think @RainbowMango is mean we want to use go.mod
for the project and CI, then .tool-versions
to working for go-version managers.
There are two topic, the Part1 is go version for build & CI, Part2 is the file for people who using the go-version managers.
I can see common practice ( kubernetes/kind/etcd ) is that go mod
is set to the language version, and .go-version
uses the higher version for compilation and building.
But as @RainbowMango say, using go.mod
to unify go versions in CI may be a direction, so maybe we can try to using go.mod
for CI and .tool-versions
to working go version manager.
auto-switching switches the go version when cd-ing into a directory according to the directories .go-version
would you like to try with .tool-versions
? ( I don't have try them )
asdf also supports .go-version, so can we avoid 1 level of indirection by using that instead of .tool-versions ?
asdf also supports .go-version, so can we avoid 1 level of indirection by using that instead of .tool-versions ?
Thanks for the reminder. I didn't notice it. then I belive .go-version
is better than .tool-versions
.
By the way, the actions/setup-go
has been updated to v5
by #4756, you might need to rebase when making adjustments.
rebased + updated go.mod to have full version
... is this mergeable now or what still needs to change ?
plz restart the 1 failed ci job, seems unrelated ...
Done. This reminds me to hurry up the #4637, after that we can restart the test by /retest command.
still 2 checks pending ... any idea how to get them to pass ?
still 2 checks pending ... any idea how to get them to pass ?
All good now. Ready to move forward now. /approve @liangyuanpeng If you have any further comments, please continue...
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: RainbowMango
The full list of commands accepted by this bot can be found here.
The pull request process is described here
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Special notes for your reviewer:
Does this PR introduce a user-facing change?: