From 0f730c3a26ae85cea5770e2b4dca7e8ef9a211e0 Mon Sep 17 00:00:00 2001 From: Olivier Lemasle Date: Mon, 28 Aug 2023 23:28:44 +0200 Subject: [PATCH 1/2] Fix "make test" and "make lint" Fixes #626 --- Makefile | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 34d63e256..9ed35dc87 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include .bingo/Variables.mk SHELL=/usr/bin/env bash PROVIDER_MODULES ?= $(shell find $(PWD)/providers/ -name "go.mod" | grep -v ".bingo" | xargs dirname) -MODULES ?= $(PROVIDER_MODULES) $(PWD)/ $(PWD)/examples +MODULES ?= $(PROVIDER_MODULES) $(PWD) $(PWD)/examples GO_FILES_TO_FMT ?= $(shell find . -path -prune -o -name '*.go' -print) GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin @@ -48,14 +48,12 @@ fmt: $(GOIMPORTS) .PHONY: test test: @echo "Running tests for all modules: $(MODULES)" - for dir in $(MODULES) ; do \ - $(MAKE) test_module DIR=$${dir} ; \ - done + $(MAKE) $(MODULES:%=test_module_%) -.PHONY: test_module -test_module: - @echo "Running tests for dir: $(DIR)" - cd $(DIR) && go test -v -race ./... +.PHONY: test_module_% +$(MODULES:%=test_module_%): test_module_%: + @echo "Running tests for dir: $*" + cd $* && go test -v -race ./... .PHONY: deps deps: @@ -93,27 +91,25 @@ lint: $(BUF) $(COPYRIGHT) fmt docs @echo "Running lint for all modules: $(MODULES)" @$(call require_clean_work_tree,"before lint") - for dir in $(MODULES) ; do \ - $(MAKE) lint_module DIR=$${dir} ; \ - done + $(MAKE) $(MODULES:%=lint_module_%) @$(call require_clean_work_tree,"lint and format files") -.PHONY: lint_module +.PHONY: lint_module_% # PROTIP: # Add # --cpu-profile-path string Path to CPU profile output file # --mem-profile-path string Path to memory profile output file # to debug big allocations during linting. -lint_module: ## Runs various static analysis against our code. -lint_module: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL) +lint_module_%: ## Runs various static analysis against our code. +$(MODULES:%=lint_module_%): lint_module_%: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL) @echo ">> verifying modules being imported" - @cd $(DIR) && $(FAILLINT) -paths "fmt.{Print,Printf,Println},github.com/golang/protobuf=google.golang.org/protobuf" ./... + @cd $* && $(FAILLINT) -paths "fmt.{Print,Printf,Println},github.com/golang/protobuf=google.golang.org/protobuf" ./... @echo ">> examining all of the Go files" - @cd $(DIR) && go vet -stdmethods=false ./... + @cd $* && go vet -stdmethods=false ./... @echo ">> linting all of the Go files GOGC=${GOGC}" - @cd $(DIR) && $(GOLANGCI_LINT) run + @cd $* && $(GOLANGCI_LINT) run @$(call require_clean_work_tree,"golangci lint") From 718ad21292e86f82b60f654caa8f8c99f364db08 Mon Sep 17 00:00:00 2001 From: Olivier Lemasle Date: Tue, 29 Aug 2023 10:49:43 +0200 Subject: [PATCH 2/2] Fix failing unit test In logging, policy for fields was reversed in 972f219a. --- interceptors/logging/interceptors_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interceptors/logging/interceptors_test.go b/interceptors/logging/interceptors_test.go index 0b1ae9ba0..3dbc69354 100644 --- a/interceptors/logging/interceptors_test.go +++ b/interceptors/logging/interceptors_test.go @@ -173,7 +173,8 @@ type loggingClientServerSuite struct { } func customFields(_ context.Context) logging.Fields { - return logging.Fields{"custom-field", "yolo"} + // Add custom fields. The second one overrides the first one. + return logging.Fields{"custom-field", "foo", "custom-field", "yolo"} } func TestSuite(t *testing.T) {