-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
69 lines (62 loc) · 1.62 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
PATH:=$(GOPATH)/bin:$(PATH)
.PHONY: help
help:
@echo 'Available commands:'
@echo '* help - Show this message'
@echo '* check - Check if required tools are installed'
@echo '* setup - Install required tools and dependencies'
@echo '* hooks - Install git hooks'
@echo '* lint - Lint code'
@echo '* cover - Coverage report'
@echo '* test - Run tests'
.PHONY: check
check:
ifeq ("","$(shell which go)")
$(error go binary not in PATH)
endif
ifeq ("","$(GOPATH)")
$(error GOPATH not configured correctly)
endif
@test -f $(GOPATH)/bin/gometalinter || \
echo "gometalinter binary not in $(GOPATH)/bin. run 'make setup'"
@test -f $(GOPATH)/bin/dep || \
echo "dep binary not in $(GOPATH)/bin. run 'make setup'"
.PHONY: setup
setup:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
go get -u github.com/golang/dep/cmd/dep
dep ensure
.PHONY: hooks
hooks: .git/hooks/pre-commit
.git/hooks/pre-commit:
echo "#!/bin/sh\nmake lint" > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
.PHONY: lint
lint: check
@gometalinter \
--disable-all \
--enable=maligned \
--enable=deadcode \
--enable=goconst \
--enable=goimports \
--enable=golint \
--enable=gosec \
--enable=gosimple \
--enable=ineffassign \
--enable=interfacer \
--enable=misspell \
--enable=safesql \
--enable=staticcheck \
--enable=structcheck \
--enable=unparam \
--enable=varcheck \
--enable=vet \
--skip vendor \
./...
.PHONY: cover
cover: check
@go test -cover $$(go list ./... | grep -v /vendor/)
.PHONY: test
test: check
@go test -integration -v -race $$(go list ./... | grep -v /vendor/)