1
1
SOURCE_DIRS = handler leader predicate status
2
2
SOURCES := $(shell find . -name '* .go' -not -path "* /vendor/* " -not -path "* /.git/* ")
3
- PACKAGES := $(shell go list $(addprefix ./, $(addsuffix /... , $(shell ls -d * / | grep -v vendor) ) ) )
4
- # COVERAGE_SVC := travis-ci
5
3
.DEFAULT_GOAL := build
6
4
7
5
# ensure: ## Install or update project dependencies
@@ -10,7 +8,7 @@ PACKAGES := $(shell go list $(addprefix ./, $(addsuffix /... , $(shell l
10
8
build : $(SOURCES ) # # Build Test
11
9
go build -i -ldflags=" -s -w" ./...
12
10
13
- lint : # # Run golint
11
+ lint : golangci-lint # # Run golint
14
12
@golangci-lint run --disable-all \
15
13
--deadline 5m \
16
14
--enable=nakedret \
@@ -38,28 +36,27 @@ fmtcheck: ## Check go formatting
38
36
@gofmt -l $(SOURCES ) | grep " .*\.go" ; if [ " $$ ?" = " 0" ]; then exit 1; fi
39
37
40
38
test : # # Run unit tests
41
- @go test -cover $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS ) ) )
39
+ @go test -race -covermode atomic -coverprofile cover.out $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS ) ) )
42
40
43
41
vet : # # Run go vet
44
42
@go vet $(addprefix ./, $(SOURCE_DIRS ) )
45
43
46
- coverage-all.out : $(PACKAGES )
47
- @grep -q -F ' mode: count' coverage-all.out || sed -i ' 1i mode: count' coverage-all.out
48
-
49
- $(PACKAGES ) : $(SOURCES )
50
- @go test -coverprofile=coverage.out -covermode=count $@ && tail -n +2 coverage.out >> coverage-all.out;
51
-
52
- test-coverage-html : coverage-all.out # # Check out the test coverage locally
53
- @go tool cover -html=coverage-all.out
54
-
55
- ci-test-coverage : coverage-all.out # # CI test coverage, upload to coveralls
56
- @goveralls -coverprofile=coverage-all.out -service $(COVERAGE_SVC )
57
-
58
44
check : fmtcheck vet lint build test # # Pre-flight checks before creating PR
59
45
60
46
clean : # # Clean up your working environment
61
47
@rm -f coverage-all.out coverage.out
62
48
49
+ golangci-lint :
50
+ ifeq (, $(shell which golangci-lint) )
51
+ @{ \
52
+ set -e ;\
53
+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.27.0 ;\
54
+ }
55
+ GOLANGCI_LINT =$(shell go env GOPATH) /bin/golangci-lint
56
+ else
57
+ GOLANGCI_LINT =$(shell which golangci-lint)
58
+ endif
59
+
63
60
# generate: ## regenerate mocks
64
61
# go get github.com/vektra/mockery/.../
65
62
# @go generate ./...
@@ -72,4 +69,4 @@ help: ## Show this help screen
72
69
@grep -E ' ^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | \
73
70
awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
74
71
75
- .PHONY : ensure build lint fmt fmtcheck test vet check help test-coverage-html clean $( PACKAGES )
72
+ .PHONY : ensure build lint fmt fmtcheck test vet check help clean
0 commit comments