Skip to content
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

Consider $GO environment variable make precheck checks #20750

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

tklauser
Copy link
Member

@tklauser tklauser commented Aug 2, 2022

For backports it's usually convenient to be able to set the $GO
environment variable to the version used in the particular stable
branch, e.g. on v1.10 we'd set GO=go1.16.15. However, that setting is
currently not considered in all check scripts invoked by make precheck.

See individual commit messages for details.

@tklauser tklauser added release-note/misc This PR makes changes that have no direct user impact. sig/contributing Impacts contribution workflow, guidelines, and tools. needs-backport/1.10 labels Aug 2, 2022
@tklauser tklauser requested a review from a team as a code owner August 2, 2022 14:26
@tklauser tklauser requested a review from aditighag August 2, 2022 14:26
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.12.1 Aug 2, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.11.8 Aug 2, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.10.14 Aug 2, 2022
For backports it's usually convenient to be able to set the $GO
environment variable to the version used in the particular stable
branch, e.g. on v1.10 we'd set GO=go1.16.15. However, that setting is
currently not considered in contrib/scripts/check-fmt.sh. If there were
changes in how gofmt formats code between Go versions and the system's
Go version is newer than the $GO setting, using that gofmt binary might
lead to check-fmt failure.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
For backports it's usually convenient to be able to set the $GO
environment variable to the version used in the particular stable
branch, e.g. on v1.10 we'd set GO=go1.16.15. However, that setting is
currently not considered in tools/customvet. This can lead to unexpected
failures such as the followin when running `GO=go1.16.15 make precheck`
on v1.10 branch:

    contrib/scripts/custom-vet-check.sh
    main: internal error: package "sync" without types was imported from "github.com/cilium/cilium/pkg/cleanup"
    exit status 1

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser force-pushed the pr/tklauser/check-fmt-go-version branch from 3585c8b to bc314ee Compare August 2, 2022 14:59
@tklauser tklauser changed the title contrib/scripts: consider $GO in check-fmt.sh Consider $GO environment variable make precheck checks Aug 2, 2022
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have $GOROOT :/

@@ -3,13 +3,15 @@
set -e
set -o pipefail

_goroot=$(${GO:-go} env GOROOT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty elegant.. hmm.

So far I got away without GOROOT, personally I find it's a bit opinionated and a pain to deal with.. maybe we could set the default for _goroot to "" iff $GO is not set..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the Go toolchain will always return a non-empty value for "go env GOROOT", even if $GOROOT isn't set in the env. It'll derive it relative to the go binary invoked, unless it's overriden by some other means.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯 I totally thought I ran this and got errors out, but now that I try it today it's fine. -ENO☕ I guess!

@tklauser
Copy link
Member Author

tklauser commented Aug 2, 2022

I don't have $GOROOT :/

Me neither :) that's the beauty about "go env".

@joestringer joestringer merged commit 920094b into master Aug 3, 2022
@joestringer joestringer deleted the pr/tklauser/check-fmt-go-version branch August 3, 2022 21:25
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.10 in 1.11.8 Aug 9, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.10 in 1.10.14 Aug 9, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.12 in 1.12.1 Aug 10, 2022
@tklauser tklauser added backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. backport-done/1.10 backport-done/1.12 The backport for Cilium 1.12.x for this PR is done. and removed backport-pending/1.11 labels Aug 11, 2022
@tklauser tklauser moved this from Backport pending to v1.12 to Backport done to v1.12 in 1.12.1 Aug 11, 2022
@tklauser tklauser moved this from Backport pending to v1.10 to Backport done to v1.10 in 1.10.14 Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. backport-done/1.12 The backport for Cilium 1.12.x for this PR is done. release-note/misc This PR makes changes that have no direct user impact. sig/contributing Impacts contribution workflow, guidelines, and tools.
Projects
No open projects
1.10.14
Backport done to v1.10
1.12.1
Backport done to v1.12
Development

Successfully merging this pull request may close these issues.

None yet

4 participants