From 4f5e1b9ddea216d3d8b15049cac9eec112d91db2 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Tue, 9 May 2023 17:38:29 -0600 Subject: [PATCH 1/2] Split e2e tests from unit tests: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it clear that there are 2 different types of tests. Also remove nix in CI for tests. The update to the make build target is to improve the output. current: ❯ make build CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 \ go build \ \ -o ./bin/tink-server-linux-amd64 \ ./cmd/tink-server CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 \ go build \ \ -o ./bin/tink-worker-linux-amd64 \ ./cmd/tink-worker CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 \ go build \ \ -o ./bin/tink-controller-linux-amd64 \ ./cmd/tink-controller CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 \ go build \ \ -o ./bin/virtual-worker-linux-amd64 \ ./cmd/virtual-worker new: ❯ make build CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/tink-server-linux-amd64 ./cmd/tink-server CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/tink-worker-linux-amd64 ./cmd/tink-worker CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/tink-controller-linux-amd64 ./cmd/tink-controller CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/virtual-worker-linux-amd64 ./cmd/virtual-worker Signed-off-by: Jacob Weinstock --- .github/workflows/ci.yaml | 11 ++++------- Makefile | 16 ++++++++-------- internal/e2e/e2e_test.go | 2 ++ internal/e2e/tink_suite_test.go | 2 ++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d0dfa387f..216484863 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,13 +27,10 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "${{ env.GO_VERSION }}" - - name: Install nix - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Install required nix packages - run: nix-shell --run 'true' - - run: make test + - name: Run unit tests + run: make test + - name: Run e2e tests + run: make e2e-test - name: Upload codecov run: bash <(curl -s https://codecov.io/bash) checks: diff --git a/Makefile b/Makefile index bf2b0a9f9..8244fc918 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ # Only use the recipes defined in these makefiles MAKEFLAGS += --no-builtin-rules +PATH := $(PATH):$(PWD)/bin + # Use bash instead of plain sh and treat the shell as one shell script invocation. SHELL := bash .SHELLFLAGS := -o pipefail -euc @@ -57,13 +59,7 @@ build: $(BINARIES) ## Build all tink binaries. Cross build by setting GOOS and G # See https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html. .PHONY: $(BINARIES) $(BINARIES): - CGO_ENABLED=0 \ - GOOS=$(GOOS) \ - GOARCH=$(GOARCH) \ - $(GO) build \ - $(LDFLAGS) \ - -o ./bin/$@-$(GOOS)-$(GOARCH) \ - ./cmd/$@ + CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build $(LDFLAGS) -o ./bin/$@-$(GOOS)-$(GOARCH) ./cmd/$@ # IMAGE_ARGS is resolved when its used in the `%-image` targets. Consequently, the $* automatic # variable isn't evaluated until the target is called. @@ -91,8 +87,12 @@ images: $(addsuffix -image,$(BINARIES)) ## Build all tink container images. All .PHONY: test test: ## Run tests + $(GO) test -coverprofile=coverage.txt ./... + +.PHONY: e2e-test +e2e-test: ## Run e2e tests $(SETUP_ENVTEST) use - source <($(SETUP_ENVTEST) use -p env) && $(GO) test -coverprofile=coverage.txt ./... + source <($(SETUP_ENVTEST) use -p env) && $(GO) test -v ./internal/e2e/... -tags=e2e .PHONY: generate-proto generate-proto: buf.gen.yaml buf.lock $(shell git ls-files '**/*.proto') _protoc diff --git a/internal/e2e/e2e_test.go b/internal/e2e/e2e_test.go index b95f3a19a..cad7676ff 100644 --- a/internal/e2e/e2e_test.go +++ b/internal/e2e/e2e_test.go @@ -1,3 +1,5 @@ +//go:build e2e + package e2e_test import ( diff --git a/internal/e2e/tink_suite_test.go b/internal/e2e/tink_suite_test.go index fd62bda50..c41008e46 100644 --- a/internal/e2e/tink_suite_test.go +++ b/internal/e2e/tink_suite_test.go @@ -1,3 +1,5 @@ +//go:build e2e + package e2e_test import ( From dda0db7cae890230bddfe98a3a554746ced8446e Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Tue, 9 May 2023 18:00:15 -0600 Subject: [PATCH 2/2] Remove -s from gofumpt: We're getting: "warning: -s is deprecated as it is always enabled" The buf.lock was updated after a make verify. Signed-off-by: Jacob Weinstock --- Makefile | 2 +- buf.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8244fc918..70feacc63 100644 --- a/Makefile +++ b/Makefile @@ -175,7 +175,7 @@ check-proto: generate-proto .PHONY: verify verify: lint check-generated ## Verify code style, is lint free, freshness ... - $(GOFUMPT) -s -d . + $(GOFUMPT) -d . .PHONY: lint lint: shellcheck hadolint golangci-lint yamllint ## Lint code diff --git a/buf.lock b/buf.lock index 539718790..c3e490630 100644 --- a/buf.lock +++ b/buf.lock @@ -4,4 +4,4 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 5ae7f88519b04fe1965da0f8a375a088 + commit: cc916c31859748a68fd229a3c8d7a2e8