1- SOURCE_DIRS = handler leader predicate status
21SOURCES := $(shell find . -name '* .go' -not -path "* /vendor/* " -not -path "* /.git/* ")
32.DEFAULT_GOAL := build
43
5- # ensure: ## Install or update project dependencies
6- # @dep ensure
7-
84build : $(SOURCES ) # # Build Test
95 go build -i -ldflags=" -s -w" ./...
106
@@ -15,38 +11,37 @@ lint-fix: golangci-lint ## Run golangci lint to automatically perform fixes
1511 @$(GOLANGCI_LINT ) run --fix
1612
1713fmt : # # Run go fmt
18- @gofmt -d $( SOURCES )
14+ @go fmt ./...
1915
2016fmtcheck : # # Check go formatting
2117 @gofmt -l $(SOURCES ) | grep " .*\.go" ; if [ " $$ ?" = " 0" ]; then exit 1; fi
2218
2319test : # # Run unit tests
24- @go test -race -covermode atomic -coverprofile cover.out $( addprefix ./, $( addsuffix / ... , $( SOURCE_DIRS ) ) )
20+ @go test -race -covermode atomic -coverprofile cover.out ./ ...
2521
2622vet : # # Run go vet
27- @go vet $( addprefix ./, $( SOURCE_DIRS ) )
23+ @go vet ./...
2824
2925tidy : # # Tidy go dependencies
3026 @go mod tidy
3127
32- check-license : $(SOURCES )
28+ check-license : $(SOURCES ) # # Check license headers
3329 @./hack/check-license.sh " $( SOURCES) "
3430
3531check : tidy fmtcheck vet lint build test check-license # # Pre-flight checks before creating PR
3632 @git diff --exit-code
3733
3834clean : # # Clean up your working environment
39- @rm -f coverage-all.out coverage .out
35+ @rm -f cover .out
4036
37+ GOLANGCI_LINT =./bin/golangci-lint
38+ GOLANGCI_LINT_VER =1.30.0
4139golangci-lint :
42- ifeq ( , $(shell which golangci-lint ) )
40+ ifneq ( $( GOLANGCI_LINT_VER ) , $(shell $( GOLANGCI_LINT ) version 2>&1 | cut -d" " -f4 ) )
4341 @{ \
4442 set -e ;\
45- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.29.0 ;\
43+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b bin v$(GOLANGCI_LINT_VER) ;\
4644 }
47- GOLANGCI_LINT =$(shell go env GOPATH) /bin/golangci-lint
48- else
49- GOLANGCI_LINT =$(shell which golangci-lint)
5045endif
5146
5247# generate: ## regenerate mocks
@@ -61,4 +56,4 @@ help: ## Show this help screen
6156 @grep -E ' ^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | \
6257 awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
6358
64- .PHONY : ensure build lint fmt fmtcheck test vet check help clean
59+ .PHONY : build lint lint-fix fmt fmtcheck test vet tidy check-license check clean golangci-lint help
0 commit comments