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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ version: 2.1 # Adds support for executors, parameterized jobs, etc
reusable:

constants:
- &go_version "1.12.12"
- &go_version "1.14.2"

docker_images:
- &golang_image "golang:1.12.12"
- &circleci_golang_image "circleci/golang:1.12"
- &golang_image "golang:1.14.2"
- &circleci_golang_image "circleci/golang:1.14.2"

vm_images:
- &ubuntu_vm_image "ubuntu-1604:201903-01"
Expand Down
52 changes: 37 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
print/kubebuilder/test_assets \
run/kuma-dp

PKG_LIST := ./... ./api/... ./pkg/plugins/resources/k8s/native/...
PKG_LIST := ./...

BUILD_INFO_GIT_TAG ?= $(shell git describe --tags 2>/dev/null || echo unknown)
BUILD_INFO_GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
Expand All @@ -32,9 +32,10 @@ build_info_ld_flags := $(foreach entry,$(build_info_fields), -X github.com/Kong/
LD_FLAGS := -ldflags="-s -w $(build_info_ld_flags)"
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(LD_FLAGS)
GOFLAGS := -mod=mod
GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(GOFLAGS) $(LD_FLAGS)
GO_RUN := CGO_ENABLED=0 go run $(LD_FLAGS)
GO_TEST := go test $(LD_FLAGS)
GO_TEST := go test $(GOFLAGS) $(LD_FLAGS)

BUILD_DIR ?= build
BUILD_ARTIFACTS_DIR ?= $(BUILD_DIR)/artifacts-${GOOS}-${GOARCH}
Expand Down Expand Up @@ -116,7 +117,7 @@ else
endif

PROTOC_VERSION := 3.6.1
PROTOC_PGV_VERSION := v0.3.0-java
PROTOC_PGV_VERSION := v0.3.0-java.0.20200311152155-ab56c3dd1cf9
GOLANG_PROTOBUF_VERSION := v1.3.2
GOLANGCI_LINT_VERSION := v1.21.0

Expand All @@ -125,7 +126,7 @@ CI_KIND_VERSION ?= v0.7.0
CI_MINIKUBE_VERSION ?= v1.4.0
CI_KUBERNETES_VERSION ?= v1.15.3
CI_KUBECTL_VERSION ?= v1.14.0
CI_TOOLS_IMAGE ?= circleci/golang:1.12.12
CI_TOOLS_IMAGE ?= circleci/golang:1.14.2

CI_TOOLS_DIR ?= $(HOME)/bin
GOPATH_DIR := $(shell go env GOPATH | awk -F: '{print $$1}')
Expand Down Expand Up @@ -273,15 +274,15 @@ generate/gui: ## Generate go files with GUI static files to embed it into binary
fmt: fmt/go fmt/proto ## Dev: Run various format tools

fmt/go: ## Dev: Run go fmt
go fmt ./...
go fmt $(GOFLAGS) ./...
@# apparently, it's not possible to simply use `go fmt ./pkg/plugins/resources/k8s/native/...`
make fmt -C pkg/plugins/resources/k8s/native

fmt/proto: ## Dev: Run clang-format on .proto files
which $(CLANG_FORMAT_PATH) && find . -name '*.proto' | xargs -L 1 $(CLANG_FORMAT_PATH) -i || true

vet: ## Dev: Run go vet
go vet ./...
go vet $(GOFLAGS) ./...
@# for consistency with `fmt`
make vet -C pkg/plugins/resources/k8s/native

Expand All @@ -295,24 +296,45 @@ check: generate fmt vet docs golangci-lint imports ## Dev: Run code checks (go f
make generate manifests -C pkg/plugins/resources/k8s/native
git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators and code checks) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty

test: ## Dev: Run tests
test: ${COVERAGE_PROFILE} test/api test/k8s test/kuma coverage ## Dev: Run tests for all modules

${COVERAGE_PROFILE}:
mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")"

coverage: ${COVERAGE_PROFILE}
GOFLAGS='${GOFLAGS}' go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)"

test/kuma: # Dev: Run tests for the module github.com/Kong/kuma
$(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST)
go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)"

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.

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

test/kuma-cp: PKG_LIST=./app/kuma-cp/... ./pkg/config/app/kuma-cp/...
test/kuma-cp: test ## Dev: Run `kuma-cp` tests only
test/kuma-cp: test/kuma ## Dev: Run `kuma-cp` tests only

test/kuma-dp: PKG_LIST=./app/kuma-dp/... ./pkg/config/app/kuma-dp/...
test/kuma-dp: test ## Dev: Run `kuma-dp` tests only
test/kuma-dp: test/kuma ## Dev: Run `kuma-dp` tests only

test/kumactl: PKG_LIST=./app/kumactl/... ./pkg/config/app/kumactl/...
test/kumactl: test ## Dev: Run `kumactl` tests only
test/kumactl: test/kuma ## Dev: Run `kumactl` tests only

integration: ## Dev: Run integration tests
${COVERAGE_INTEGRATION_PROFILE}:
mkdir -p "$(shell dirname "$(COVERAGE_INTEGRATION_PROFILE)")"

integration: ${COVERAGE_INTEGRATION_PROFILE} ## Dev: Run integration tests
tools/test/run-integration-tests.sh '$(GO_TEST) -race -covermode=atomic -tags=integration -count=1 -coverpkg=./... -coverprofile=$(COVERAGE_INTEGRATION_PROFILE) $(PKG_LIST)'
go tool cover -html="$(COVERAGE_INTEGRATION_PROFILE)" -o "$(COVERAGE_INTEGRATION_REPORT_HTML)"
GOFLAGS='${GOFLAGS}' go tool cover -html="$(COVERAGE_INTEGRATION_PROFILE)" -o "$(COVERAGE_INTEGRATION_REPORT_HTML)"

build: build/kuma-cp build/kuma-dp build/kumactl build/kuma-prometheus-sd ## Dev: Build all binaries

Expand Down Expand Up @@ -529,4 +551,4 @@ run/kuma-dp: ## Dev: Run `kuma-dp` locally
$(GO_RUN) ./app/kuma-dp/main.go run --log-level=debug

include Makefile.dev.mk
include Makefile.e2e.mk
include Makefile.e2e.mk
6 changes: 3 additions & 3 deletions Makefile.dev.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ dev/install/protobuf-wellknown-types:: ## Bootstrap: Install Protobuf well-known
&& echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi

dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go generator)
go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION)
go get 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


dev/install/ginkgo: ## Bootstrap: Install Ginkgo (BDD testing framework)
# see https://github.com/onsi/ginkgo#set-me-up
Expand Down Expand Up @@ -131,4 +131,4 @@ dev/install/golangci-lint: ## Bootstrap: Install golangci-lint
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOLANGCI_LINT_DIR) $(GOLANGCI_LINT_VERSION)

dev/install/goimports: ## Bootstrap: Install goimports
go get -u golang.org/x/tools/cmd/goimports
go get golang.org/x/tools/cmd/goimports
15 changes: 9 additions & 6 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ install/protobuf-wellknown-types:
&& echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi

install/protoc-gen-go:
go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION)
go get github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION)

install/protoc-gen-validate:
go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION)
go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION)

install/data-plane-api:
go get -u github.com/envoyproxy/data-plane-api@$(DATAPLANE_API_LATEST_VERSION)
go get -u github.com/cncf/udpa@$(UDPA_LATEST_VERSION)
go get -u github.com/googleapis/googleapis@$(GOOGLEAPIS_LATEST_VERSION)
go get github.com/envoyproxy/data-plane-api@$(DATAPLANE_API_LATEST_VERSION)
go get github.com/cncf/udpa@$(UDPA_LATEST_VERSION)
go get github.com/googleapis/googleapis@$(GOOGLEAPIS_LATEST_VERSION)

clean: ## Remove generated files
find . -name '*.pb.go' -delete
Expand All @@ -135,8 +135,11 @@ protoc/system/v1alpha1:
build: ## Build generated files
go build ./...

GO_TEST ?= go test
GO_TEST_OPTS ?=

test: ## Run tests
go test ./...
$(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" ./...

check: generate build test ## Verify that auto-generated code is up-to-date
git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Kong/kuma/api

go 1.12
go 1.14

require (
github.com/cncf/udpa v0.0.0-20200313221541-5f7e5dd04533 // indirect
Expand Down
4 changes: 3 additions & 1 deletion api/mesh/v1alpha1/proxy_template.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Kong/kuma

go 1.12
go 1.14

require (
github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/resources/k8s/native/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.12.12 as builder
FROM golang:1.14.2 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
6 changes: 5 additions & 1 deletion pkg/plugins/resources/k8s/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ export TEST_ASSET_KUBECTL=$(KUBECTL_PATH)

all: manager

GO_TEST ?= go test
GO_TEST_OPTS ?=
COVERAGE_PROFILE ?= cover.out

# Run tests
test: generate fmt vet manifests
go test ./api/... ./controllers/... -coverprofile cover.out
$(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" ./api/... ./controllers/...

# Build manager binary
manager: generate fmt vet
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/resources/k8s/native/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Kong/kuma/pkg/plugins/resources/k8s/native

go 1.12
go 1.14

require (
github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000
Expand Down