-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
102 lines (87 loc) · 2.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# TODO: run golint, errcheck, staticcheck, unused, ineffassign
.PHONY: default
default: deps checkgofmt vet predeclared unused ineffassign predeclared errchack test
.PHONY: ci
ci: deps checkgofmt vet predeclared unused ineffassign predeclared errchack testcover
.PHONY: deps
deps:
go get -d -v -t ./...
.PHONY: updatedeps
updatedeps:
go get -d -v -t -u -f ./...
.PHONY: install
install:
go install ./...
.PHONY: checkgofmt
checkgofmt:
@if [ -n "$$(go version | awk '{ print $$3 }' | grep -v devel)" ]; then \
echo "gofmt -s -l ." ; \
if [ -n "$$(gofmt -s -l .)" ]; then \
for dir in $$(gofmt -s -l .); do \
gofmt -d -s $$dir; \
done; \
gofmt -s -l . ; \
echo "Run gofmt on the above files!"; \
exit 1; \
fi; \
fi
# workaround https://github.com/golang/protobuf/issues/214 until in master
.PHONY: vet
vet:
@echo go vet ./... --ignore test/golang
@for dir in $$(go list ./... | grep -v 'test/golang'); do \
go vet $$dir ; \
done
.PHONY: staticcheck
staticcheck:
@go get honnef.co/go/tools/cmd/staticcheck
staticcheck ./...
.PHONY: unused
unused:
@go get honnef.co/go/tools/cmd/unused
unused ./...
.PHONY: ineffassign
ineffassign:
@go get github.com/gordonklaus/ineffassign
ineffassign .
.PHONY: predeclared
predeclared:
@go get github.com/nishanths/predeclared
predeclared .
# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: golint
golint:
@go get github.com/golang/lint/golint
golint -min_confidence 0.9 -set_exit_status ./...
# Intentionally omitted from CI, but target here for ad-hoc reports.
.PHONY: errchack
errcheck:
@go get github.com/kisielk/errcheck
errcheck ./...
.PHONY: test
test:
go test -race ./...
.PHONY: generate
generate:
rm -f ./test/gogo/*pb.go
rm -f ./test/golang/*pb.go
go generate github.com/prasek/go-grpc-info/test/gogo
go generate github.com/prasek/go-grpc-info/test/golang
.PHONY: testcover
testcover:
@echo go test -covermode=atomic ./...
@echo "mode: atomic" > coverage.out
@for dir in $$(go list ./grpcinfo/...); do \
go test -race -coverprofile profile.out -covermode=atomic $$dir ; \
if [ -f profile.out ]; then \
tail -n +2 profile.out >> coverage.out && rm profile.out ; \
fi; \
done; \
go test -race -coverprofile profile.out -covermode=atomic -coverpkg ./grpcinfo ./test/gogo; \
if [ -f profile.out ]; then \
tail -n +2 profile.out >> coverage.out && rm profile.out ; \
fi; \
go test -race -coverprofile profile.out -covermode=atomic -coverpkg ./grpcinfo ./test/golang; \
if [ -f profile.out ]; then \
tail -n +2 profile.out >> coverage.out && rm profile.out ; \
fi; \