-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (103 loc) · 3.07 KB
/
Makefile
File metadata and controls
133 lines (103 loc) · 3.07 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
GO ?= go
LINTER ?= golangci-lint
ALIGNER ?= betteralign
VULNCHECK ?= govulncheck
BENCHSTAT ?= benchstat
LINTKIT ?= lintkit
BENCH_COUNT ?= 6
BENCH_REF ?= bench_baseline.txt
.PHONY: test test-race test-short bench bench-fast bench-reset verify vet check ci \
fmt fmt-check lint lint-fix align align-fix tidy tidy-check download deps-update \
tools tools-ci tool-golangci-lint tool-betteralign tool-govulncheck tool-benchstat \
tool-lintkit diag-doc diag-doc-check release-notes
check: verify vulncheck tidy fmt vet lint-fix align-fix test diag-doc
ci: download tools-ci verify vulncheck tidy-check fmt-check vet lint align test diag-doc-check
fmt:
gofmt -w .
fmt-check:
@files=$$(gofmt -l .); \
if [ -n "$$files" ]; then \
echo "$$files" 1>&2; \
echo "gofmt: files need formatting" 1>&2; \
exit 1; \
fi
vet:
$(GO) vet ./...
test:
$(GO) test ./...
test-race:
$(GO) test -race ./...
test-short:
$(GO) test -short ./...
bench:
@tmp=$$(mktemp); \
$(GO) test ./... -run=^$$ -bench 'Benchmark' -benchmem -count=$(BENCH_COUNT) | tee "$$tmp"; \
if [ -f "$(BENCH_REF)" ]; then \
$(BENCHSTAT) "$(BENCH_REF)" "$$tmp"; \
else \
cp "$$tmp" "$(BENCH_REF)" && echo "Baseline saved to $(BENCH_REF)"; \
fi; \
rm -f "$$tmp"
bench-fast:
$(GO) test ./... -run=^$$ -bench 'Benchmark' -benchmem
bench-reset:
rm -f "$(BENCH_REF)"
verify:
$(GO) mod verify
tidy-check:
@$(GO) mod tidy
@git diff --stat --exit-code -- go.mod go.sum || ( \
echo "go mod tidy: repository is not tidy"; \
exit 1; \
)
tidy:
$(GO) mod tidy
download:
$(GO) mod download
deps-update:
$(GO) get -u ./...
$(GO) mod tidy
lint:
$(LINTER) run ./...
lint-fix:
$(LINTER) run --fix ./...
align:
$(ALIGNER) ./...
align-fix:
$(ALIGNER) -apply ./...
vulncheck:
$(VULNCHECK) ./...
tools: tool-golangci-lint tool-betteralign tool-govulncheck tool-benchstat tool-lintkit
tools-ci: tool-golangci-lint tool-betteralign tool-govulncheck tool-lintkit
tool-golangci-lint:
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
tool-betteralign:
$(GO) install github.com/dkorunic/betteralign/cmd/betteralign@latest
tool-govulncheck:
$(GO) install golang.org/x/vuln/cmd/govulncheck@latest
tool-benchstat:
$(GO) install golang.org/x/perf/cmd/benchstat@latest
tool-lintkit:
$(GO) install github.com/woozymasta/lintkit/cmd/lintkit@latest
diag-doc:
$(LINTKIT) snapshot --scope csv -f yaml rules.yaml
$(LINTKIT) doc -t table -w 76 rules.yaml RULES.md
diag-doc-check:
$(LINTKIT) snapshot --scope csv -cf yaml rules.yaml
$(LINTKIT) doc -ct table -w 76 rules.yaml RULES.md
release-notes:
@awk '\
/^<!--/,/^-->/ { next } \
/^## \[[0-9]+\.[0-9]+\.[0-9]+\]/ { if (found) exit; found=1; next } \
found { \
if (/^## \[/) { exit } \
if (/^$$/) { flush(); print; next } \
if (/^\* / || /^- /) { flush(); buf=$$0; next } \
if (/^###/ || /^\[/) { flush(); print; next } \
sub(/^[ \t]+/, ""); sub(/[ \t]+$$/, ""); \
if (buf != "") { buf = buf " " $$0 } else { buf = $$0 } \
next \
} \
function flush() { if (buf != "") { print buf; buf = "" } } \
END { flush() } \
' CHANGELOG.md