forked from datarhei/gosrt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (56 loc) · 1.62 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
COMMIT := $(shell if [ -d .git ]; then git rev-parse HEAD; else echo "unknown"; fi)
SHORTCOMMIT := $(shell echo $(COMMIT) | head -c 7)
all: build
## test: Run all tests
test:
go test -race -coverprofile=/dev/null -covermode=atomic -v ./...
## fuzz: Run fuzz tests
fuzz:
go test -fuzz=Fuzz -run=^Fuzz ./packet -fuzztime 30s
## vet: Analyze code for potential errors
vet:
go vet ./...
## fmt: Format code
fmt:
go fmt ./...
## update: Update dependencies
update:
go get -u -t
@-$(MAKE) tidy
@-$(MAKE) vendor
## tidy: Tidy up go.mod
tidy:
go mod tidy
## vendor: Update vendored packages
vendor:
go mod vendor
## lint: Static analysis with staticcheck
lint:
staticcheck ./...
## client: Build import binary
client:
cd contrib/client && CGO_ENABLED=0 go build -o client -ldflags="-s -w" -a
## server: Build import binary
server:
cd contrib/server && CGO_ENABLED=0 go build -o server -ldflags="-s -w" -a
## coverage: Generate code coverage analysis
coverage:
go test -race -coverprofile=cover.out -timeout 60s -v ./...
go tool cover -html=cover.out -o cover.html
## commit: Prepare code for commit (vet, fmt, test)
commit: vet fmt lint test
@echo "No errors found. Ready for a commit."
## docker: Build standard Docker image
docker:
docker build -t gosrt:$(SHORTCOMMIT) .
## logtopics: Extract all logging topics
logtopics:
grep -ERho 'log\("([^"]+)' *.go | sed -E -e 's/log\("//' | sort -u
.PHONY: help test fuzz vet fmt vendor commit coverage lint client server update logtopics
## help: Show all commands
help: Makefile
@echo
@echo " Choose a command:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo