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

chore: update go up to 1.14.2 #718

Merged
merged 17 commits into from
May 8, 2020
Merged

chore: update go up to 1.14.2 #718

merged 17 commits into from
May 8, 2020

Conversation

lobkovilya
Copy link
Contributor

@lobkovilya lobkovilya commented May 5, 2020

Summary

A primary goal was to update Go up to 1.14, but there is an issue that doesn't allow us to do it. By default Go 1.14 check if vendor folder exists and runs build in vendoring mode. But our vendor folder is used for prometheus and isn't synced and the build fails. To avoid it we can pass flag -mod=mod to any Go command (test, build, fmt ...) and force to use modules (not vendor). But go tool cover ... doesn't have such -mod flag and under the hood calls go list that starts working in vendor mode and fails. As a workaround, we can run GO111MODULE=off go tool cover but in that case, we should always checkout code on CI under GOPATH.

It is not possible to run go test being outside of the module since go 1.13. That's why I had to slightly modify make test targets. Instead of one go test ./... ./api/... ./pkg/plugins/resources/k8s/native/... now we call go test 3 times for each go module. That leads to the creation of 3 separate coverage files. There is a special third party tool that allows us to merge them, but I don't know how urgent is it and are coverage files even used now.

upd: thanks to @jakubdyszkiewicz and GOFLAGS managed to update Go to 1.14.2

@lobkovilya lobkovilya requested a review from a team May 5, 2020 02:15
Copy link
Contributor

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

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

I am not a big fan of splitting the test targets as proposed. Can we have a "parametrised" target instead?

test/k8s: # Dev: Run tests for the module github.com/Kong/kuma/pkg/plugins/resources/k8s/native
GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../../../../../$(BUILD_COVERAGE_DIR)/coverage-k8s.out' \
make test -C ./pkg/plugins/resources/k8s/native

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm can we have a common target that gets arguments for PKG and COVERAGE to test and input the results to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you talking about something like this:

test/api: MODULE=./api COVERAGE_PROFILE=../$(BUILD_COVERAGE_DIR)/coverage-api.out
test/api: test/module

test/k8s: MODULE=./pkg/plugins/resources/k8s/native COVERAGE_PROFILE=../../../../../$(BUILD_COVERAGE_DIR)/coverage-k8s.out
test/k8s: test/module

test/module:
	GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='${COVERAGE_PROFILE}' make test -C ${MODULE}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes! At least we get a more structured testing pattern to follow. @jakubdyszkiewicz what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, as long as we've got a single make test target that tests everything (which I see we do) I'm ok with it

@@ -48,7 +48,7 @@ dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go g
go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION)

dev/install/protoc-gen-validate: ## Bootstrap: Install Protoc Gen Validate Plugin (protobuf validation code generator)
go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION)
go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why removing the -u?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, we install make dev/install/protoc-gen-go with the provided version (make target right above).
Then we run make dev/install/protoc-gen-validate with -u and it updates protoc-gen-go to the latest version, which is incompatible for us.

Maybe all dependencies should be installed without -u flag

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Well removing -u everywhere makes sense to me. Let's stick with the specific versions we know are working.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to removing -u

@lobkovilya lobkovilya changed the title chore: update go up to 1.13.10 chore: update go up to 1.14.2 May 5, 2020
@lobkovilya lobkovilya merged commit e4d31d9 into master May 8, 2020
@nickolaev
Copy link
Contributor

Actually according to https://golang.org/doc/go1.14 :

When the main module contains a top-level vendor directory and its go.mod file specifies go 1.14 or higher, the go command now defaults to -mod=vendor for operations that accept that flag.

Note that the condition is that the toplevel go.mod shall be pointing to 1.14. If you keep it at 1.13 the problem with -mod=mod does not exist. @lobkovilya maybe we can put this in one fo the next PRs.

nickolaev referenced this pull request Jun 5, 2020
Having a folder called `vendor` confises go 1.14. Rename it to `vendored`
and this solves many potential issues. Including the need to pass `-mod=mod`
in many cases.

https://github.com/Kong/kuma/pull/718#issuecomment-625894360

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
nickolaev referenced this pull request Jun 9, 2020
* chore(*) improve go mod handling in 1.14

Having a folder called `vendor` confuses go 1.14. Rename it to `vendored`
and this solves many potential issues. Including the need to pass `-mod=mod`
in many cases.

https://github.com/Kong/kuma/pull/718#issuecomment-625894360

* fix(ci) make sure to install git before `checkout`

* chore(ci) bump Xcode to 11.5 an Ubuntu to 18.04

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@lobkovilya lobkovilya deleted the chore/update-go-1.14.2 branch July 29, 2020 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants