-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (60 loc) · 1.63 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
PROJECT := github.com/cfhamlet/os-jsonbind
GOPATH := $(shell go env GOPATH)
GOIMPORTS := $(GOPATH)/bin/goimports
GOFUMPT := $(GOPATH)/bin/gofumpt
GOLINT := $(GOPATH)/bin/golangci-lint
SRC := $(shell find . -type f -name '*.go' -print)
PKG := ./...
TESTS := .
TESTFLAGS :=
GOFLAGS :=
LDFLAGS :=
.PHONY: all
all: test
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint
test: test-unit
test: test-bench
test: test-cover
.PHONY: test-lint
test-lint:$(GOLINT)
@echo
@echo "==> Running lint test <=="
GO111MODULE=on $(GOLINT) run $(TESTS)
.PHONY: test-unit
test-unit:
@echo
@echo "==> Running unit tests <=="
GO111MODULE=on go test -v $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
.PHONY: test-bench
test-bench:
@echo
@echo "==> Running benchmark tests <=="
GO111MODULE=on go test $(GOFLAGS) -bench $(TESTS) $(PKG)
.PHONY: test-cover
test-cover:
@echo
@echo "==> Running unit tests with coverage <=="
@sh ./scripts/coverage.sh
.PHONY: format
format: $(GOIMPORTS) $(GOFUMPT)
@echo
@echo "==> Formatting <=="
GO111MODULE=on go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w
GO111MODULE=on go list -f '{{.Dir}}' ./... | xargs $(GOFUMPT) -w
$(GOFUMPT):
@echo
@echo "==> Installing gofumpt <=="
(cd /; GO111MODULE=on go get -u mvdan.cc/gofumpt)
$(GOIMPORTS):
@echo
@echo "==> Installing goimports <=="
(cd /; GO111MODULE=on go get -u golang.org/x/tools/cmd/goimports)
$(GOLINT):
@echo
@echo "==> Installing golangci-lint <=="
(cd /; curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin latest)
.PHONY cloc:
cloc:
@ cloc .