-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (87 loc) · 2.41 KB
/
Makefile
File metadata and controls
111 lines (87 loc) · 2.41 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
GO ?= go
LINTER ?= golangci-lint
ALIGNER ?= betteralign
BENCHSTAT ?= benchstat
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 \
tools tools-ci tool-golangci-lint tool-betteralign tool-benchstat \
release-notes
check: verify tidy fmt vet lint-fix align-fix test
ci: download tools-ci verify tidy-check fmt-check vet lint align test
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
lint:
$(LINTER) run ./...
lint-fix:
$(LINTER) run --fix ./...
align:
$(ALIGNER) ./...
align-fix:
-$(ALIGNER) -apply ./...
$(ALIGNER) ./...
tools: tool-golangci-lint tool-betteralign tool-benchstat
tools-ci: tool-golangci-lint tool-betteralign
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-benchstat:
$(GO) install golang.org/x/perf/cmd/benchstat@latest
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