This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
89 lines (68 loc) · 1.92 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
all: build tidy lint fmt test
#-------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------
env=CGO_ENABLED=1
test:
CGO_ENABLED=1 go test -v -cover -failfast -race ./...
fuzz:
@fuzzTime=$${FUZZ_TIME:-10}; \
files=$$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' .); \
for file in $$files; do \
funcs=$$(grep -o 'func Fuzz\w*' $$file | sed 's/func //'); \
for func in $$funcs; do \
echo "Fuzzing $$func in $$file"; \
parentDir=$$(dirname $$file); \
go test $$parentDir -run=$$func -fuzz=$$func -fuzztime=$${fuzzTime}s; \
if [ $$? -ne 0 ]; then \
echo "Fuzzing $$func in $$file failed"; \
exit 1; \
fi; \
done; \
done
bench:
go test -bench=. -benchmem ./...
lint:
golangci-lint run
pre-commit run --all-files
gomod2nix:
gomod2nix generate
build: gomod2nix test
$(env) go build ./...
release-dev: build-ci
upgrade:
pre-commit autoupdate
go get -u ./...
update:
git submodule update --recursive
fmt:
gofmt -s -w .
tidy: fmt
go mod tidy
clean:
rm -rf dist
rm -rf coverage
#-------------------------------------------------------------------------
# CI targets
#-------------------------------------------------------------------------
test-ci:
CGO_ENABLED=1 go test \
-cover \
-covermode=atomic \
-coverprofile=coverage.txt \
-failfast \
-race ./...
make fuzz FUZZ_TIME=10
build-ci: test-ci
$(env) go build ./...
bench-ci: test-ci
go test -bench=. ./... | tee output.txt
release-ci: build-ci
#-------------------------------------------------------------------------
# Force targets
#-------------------------------------------------------------------------
FORCE:
#-------------------------------------------------------------------------
# Phony targets
#-------------------------------------------------------------------------
.PHONY: build test lint fuzz