-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (59 loc) · 1.58 KB
/
Makefile
File metadata and controls
80 lines (59 loc) · 1.58 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
all: build tidy lint fmt test
#-------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------
env=CGO_ENABLED=1
SHELL := $(shell which bash)
FUZZ_TIME ?= 30
deps:
mkdir -p out
pre-commit: deps upgrade tidy fmt lint build test
test:
CGO_ENABLED=1 go test -v -cover -failfast -race ./...
fuzz:
@for f in $$(grep -rn 'func Fuzz' --include='*_test.go' -l .); do \
pkg=$$(dirname $$f); \
for fn in $$(grep -oP 'func \KFuzz\w+' $$f); do \
echo "fuzzing $$pkg::$$fn for $(FUZZ_TIME)s"; \
go test -fuzz=$$fn -fuzztime=$(FUZZ_TIME)s $$pkg || true; \
done; \
done
bench:
go test -bench=. -benchmem ./...
test-all: test fuzz
fmt:
golangci-lint fmt
lint:
golangci-lint run
build: test
$(env) go build ./...
release-dev:
$(env) goreleaser release --clean --snapshot
upgrade:
go get -u ./...
tidy: fmt
go mod tidy
release:
if [ -z "$(tag)" ]; then echo "tag is required"; exit 1; fi
git tag -a "$(tag)" -m "$(tag)"
git push origin "$(tag)"
clean:
rm -rf dist
rm -rf out
#-------------------------------------------------------------------------
# CI targets
#-------------------------------------------------------------------------
build-ci: lint
$(env) go build ./...
test-ci: deps build-ci
CGO_ENABLED=1 go test \
-cover \
-covermode=atomic \
-coverprofile=./out/coverage.txt \
-failfast \
-race ./...
make fuzz FUZZ_TIME=10
bench-ci: deps test-ci
go test -bench=. ./... | tee ./out/bench-output.txt
release-ci: bench-ci
$(env) goreleaser release --clean