-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
93 lines (67 loc) · 1.93 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
all: build tidy lint fmt test
#-------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------
env=CGO_ENABLED=1
op= op run --env-file="./.env" --
SHELL := $(shell which bash)
fuzzsh=https://raw.githubusercontent.com/devnw/workflows/refs/heads/main/fuzz.sh
pre-commit: update upgrade tidy fmt lint build test
test:
CGO_ENABLED=1 go test -v -cover -failfast -race ./...
fuzz:
curl -fsSL $(fuzzsh) | $(SHELL)
bench:
go test -bench=. -benchmem ./...
test-all: test fuzz
fmt:
nixfmt flake.nix
goimports -w .
gofmt -s -w .
lint:
golangci-lint run
gomod2nix:
gomod2nix generate
build: gomod2nix test
$(env) go build ./...
release-dev:
$(env) $(op) goreleaser release --clean --snapshot
upgrade:
pre-commit autoupdate
go get -u ./...
update:
git submodule update --recursive
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 coverage
#-------------------------------------------------------------------------
# CI targets
#-------------------------------------------------------------------------
build-ci: lint
$(env) go build ./...
test-ci: build-ci
CGO_ENABLED=1 go test \
-cover \
-covermode=atomic \
-coverprofile=coverage.txt \
-failfast \
-race ./...
make fuzz FUZZ_TIME=10
bench-ci: test-ci
go test -bench=. ./... | tee bench-output.txt
release-ci: bench-ci
$(env) $(op) goreleaser release --clean
#-------------------------------------------------------------------------
# Force targets
#-------------------------------------------------------------------------
FORCE:
#-------------------------------------------------------------------------
# Phony targets
#-------------------------------------------------------------------------
.PHONY: build test lint fuzz all clean FORCE