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

make: check that Go major/minor version matches required version #19528

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

tklauser
Copy link
Member

Currently, when building Cilium with a Go major/minor version other than
the one specified in GO_VERSON, the build currently fails with:

package github.com/cilium/cilium/cilium: build constraints exclude all Go files

It's not obvious from the compiler error message that this is due to
mismatching Go version.

This change adds a check-go-version target which checks the Go
compiler version used for building Cilium (as specified in $(GO)
against the version pinned in the GO_VERSION file, i.e. the version
used to build Cilium in CI. This check is required to pass in the
precheck target which should surface mismatching Go versions in a more
user-friendly way.

Example with matching version:

$ go version
go version go1.18.1 linux/amd64
$ make check-go-version

Example with mismatching version:

$ go1.17.9 version
go version go1.17.9 linux/amd64
$ make GO=go1.17.9 check-go-version
Installed Go version 1.17 does not match requested Go version 1.18
make: *** [Makefile:602: check-go-version] Error 1

Currently, when building Cilium with a Go major/minor version other than
the one specified in `GO_VERSON`, the build currently fails with:

    package github.com/cilium/cilium/cilium: build constraints exclude all Go files

It's not obvious from the compiler error message that this is due to
mismatching Go version.

This change adds a `check-go-version` target which checks the Go
compiler version used for building Cilium (as specified in `$(GO)`
against the version pinned in the `GO_VERSION` file, i.e. the version
used to build Cilium in CI. This check is required to pass in the
`precheck` target which should surface mismatching Go versions in a more
user-friendly way.

Example with matching version:

    $ go version
    go version go1.18.1 linux/amd64
    $ make check-go-version

Example with mismatching version:

    $ go1.17.9 version
    go version go1.17.9 linux/amd64
    $ make GO=go1.17.9 check-go-version
    Installed Go version 1.17 does not match requested Go version 1.18
    make: *** [Makefile:602: check-go-version] Error 1

Suggested-by: Aditi Ghag <aditi@cilium.io>
Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser requested a review from a team as a code owner April 22, 2022 10:04
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 22, 2022
@tklauser tklauser added release-note/misc This PR makes changes that have no direct user impact. area/build Anything to do with the build, more general then area/CI labels Apr 22, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 22, 2022
@pchaigno pchaigno added the sig/contributing Impacts contribution workflow, guidelines, and tools. label Apr 22, 2022
Copy link
Member

@aditighag aditighag left a comment

Choose a reason for hiding this comment

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

Thank you! 🚀

@aditighag
Copy link
Member

@tklauser We don't seem to match the minor version though - https://github.com/cilium/cilium/blob/master/daemon/main.go#L6-L6.

@pchaigno pchaigno added ready-to-merge This PR has passed all tests and received consensus from code owners to merge. and removed ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Apr 22, 2022
@tklauser
Copy link
Member Author

@tklauser We don't seem to match the minor version though - https://github.com/cilium/cilium/blob/master/daemon/main.go#L6-L6.

I assume you meant the patch version? If yes, that's intentional. The //go:build goX.Y tags only use major/minor number and e.g. //go:build go1.18 will evaluate to true for all Go 1.18.z versions and all major/minor versions newer than Go 1.18. The documentation unfortunately isn't very clear on this: https://pkg.go.dev/cmd/go (Ctrl-F for go1.)

@aditighag aditighag added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 22, 2022
@tklauser tklauser merged commit ec187e8 into master Apr 22, 2022
@tklauser tklauser deleted the pr/precheck-go-version branch April 22, 2022 14:16
@aditighag
Copy link
Member

@tklauser Should we backport this to older versions?

@tklauser
Copy link
Member Author

@tklauser Should we backport this to older versions?

Yes, good point. Let's do that.

@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.11.5 Apr 22, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.10.11 Apr 22, 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.11 Apr 27, 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.11.5 Apr 27, 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.11.5 Apr 27, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.10 to Backport done to v1.10 in 1.10.11 Apr 28, 2022
@aanm aanm added backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. and removed backport-pending/1.11 labels Apr 29, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.10 to Backport done to v1.11 in 1.11.5 Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Anything to do with the build, more general then area/CI backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. 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.11
Backport done to v1.10
1.11.5
Backport done to v1.11
Development

Successfully merging this pull request may close these issues.

None yet

5 participants