Skip to content

Commit

Permalink
chore: update go up to 1.14.2 (#718)
Browse files Browse the repository at this point in the history
* chore(*) update Go up to 1.14.2

* chore(*) add '-mod=mod'

* chore(*) revert proto version

* ci check

* ci check

* disable update

* chore(*): adjust Makefiles for the new Go version

* chore(*): add separate coverage targets

* chore(*): move '-mod=mod' to GO_TEST

* chore(*): circleci working_directory = /go/src/github.com/Kong/kuma

* chore(*): downgrade to 1.13.10 because of 'go tool cover'

* chore(*): eliminate updating protoc-gen-validate

* chore(*): fix go.mod files

* chore(*): restore proxy_template.pb.go

* chore(*): revert go to version 1.14

* chore(*): add GOFLAGS for 'go tool cover'

* chore(*): delete '-u' for 'go get'
  • Loading branch information
lobkovilya authored May 8, 2020
1 parent 08e608d commit e4d31d9
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 33 deletions.
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 @@ -12,7 +12,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 @@ -29,9 +29,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 @@ -103,14 +104,14 @@ 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

CI_KUBEBUILDER_VERSION ?= 2.0.0
CI_MINIKUBE_VERSION ?= v1.4.0
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 @@ -213,15 +214,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 @@ -235,24 +236,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}

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 @@ -453,4 +475,4 @@ run/kuma-dp: ## Dev: Run `kuma-dp` locally

include Makefile.kind.mk
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)

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 (
cloud.google.com/go v0.26.0 // 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

0 comments on commit e4d31d9

Please sign in to comment.