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

Fix "make test" and "make lint" #627

Merged
merged 2 commits into from
Aug 29, 2023
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
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