Skip to content

Commit

Permalink
Fix "make test" and "make lint" (#627)
Browse files Browse the repository at this point in the history
* Fix "make test" and "make lint"

Fixes #626

* Fix failing unit test

In logging, policy for fields was reversed in 972f219.
  • Loading branch information
olivierlemasle authored Aug 29, 2023
1 parent 48c13f0 commit 4679fb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
30 changes: 13 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")


Expand Down
3 changes: 2 additions & 1 deletion interceptors/logging/interceptors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4679fb1

Please sign in to comment.