-
Notifications
You must be signed in to change notification settings - Fork 339
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
Conversation
There was a problem hiding this 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 | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing the -u
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to removing -u
Actually according to https://golang.org/doc/go1.14 :
Note that the condition is that the toplevel |
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>
* 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>
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 ourvendor
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 (notvendor
). Butgo tool cover ...
doesn't have such-mod
flag and under the hood callsgo list
that starts working in vendor mode and fails. As a workaround, we can runGO111MODULE=off go tool cover
but in that case, we should always checkout code on CI underGOPATH
.It is not possible to run
go test
being outside of the module sincego 1.13
. That's why I had to slightly modifymake test
targets. Instead of onego test ./... ./api/... ./pkg/plugins/resources/k8s/native/...
now we callgo 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