-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (82 loc) · 1.94 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
103
104
105
106
107
108
109
# Makefile is used to capture non-intuitive commands or often forgotten tasks.
#
# Partly follows
# https://www.gnu.org/software/make/manual/html_node/Standard-Targets.html.
SRCS ?= $(shell find . -name '*.go')
GO ?= go
# go install golang.org/x/tools/cmd/godoc@latest
GODOC ?= godoc
# go install golang.org/x/tools/cmd/goimports@latest
GOIMPORTS ?= goimports
# https://golangci-lint.run/usage/install/#local-installation
#
# or simply:
# go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
GOLANGCI-LINT ?= golangci-lint
# go install github.com/google/addlicense@latest
ADDLICENSE ?= addlicense
ADDLICENSE_FLAGS ?= -c 'Alan Parra' -l mit -ignore '**/*.yml'
.PHONY: all
all: build
.PHONY: clean
clean:
rm -f cover.out generate
.PHONY: check
check: test
.PHONY: build
build:
$(GO) build ./...
.PHONY:
test:
$(GO) test ./...
.PHONY: gen
gen:
$(GO) generate ./...
.PHONY: lint
lint: lint/go lint/license
.PHONY: lint/go
lint/go:
$(GOLANGCI-LINT) run ./... ./internal/cmd/generate/...
.PHONY: lint/license
lint/license:
$(ADDLICENSE) $(ADDLICENSE_FLAGS) -check .
.PHONY: fix
fix: fix/go fix/license fix/mod
.PHONY: fix/go
fix/go:
$(GOIMPORTS) -w $(SRCS)
.PHONY: fix/license
fix/license:
$(ADDLICENSE) $(ADDLICENSE_FLAGS) .
.PHONY: fix/mod
fix/mod:
$(GO) mod tidy
cd ./internal/cmd/generate && $(GO) mod tidy
.PHONY: git/diff
git/diff:
@if [ -n "$$(git status --porcelain)" ]; then \
printf 'Local workspace has changes:\n\n' >&2; \
git status --porcelain >&2; echo; \
git diff >&2; \
exit 1; \
fi
.PHONY: cover
cover: cover/html
.PHONY: cover/html
cover/html:
$(GO) test ./... -coverprofile=cover.out
$(GO) tool cover -html=cover.out
.PHONY: cover/text
cover/text:
$(GO) test ./... -coverprofile=cover.out
$(GO) tool cover -func=cover.out | grep -Pv '\t0.0%$$'
.PHONY: docs
docs: docs/html
.PHONY: docs/html
docs/html:
$(GODOC) -http=':6060'
.PHONY: docs/text
docs/text:
$(GO) doc -all .
# Disable builtin rules.
.SUFFIXES: