-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
71 lines (57 loc) · 2.01 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
.DEFAULT_GOAL := help
IMAGE_NAME = maxpoletaev/kivi
GO_MODULE = github.com/maxpoletaev/kivi
PROTO_FILES = $(shell find . -type f -name '*.proto')
BINARIES = $(find cmd -type d -mindepth 1 -maxdepth 1)
PLATFORM = $(shell uname)
.PHONY: help
help: ## print help (this message)
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sed -n 's/^\(.*\): \(.*\)## \(.*\)/\1;\3/p' \
| column -t -s ';'
.PHONY: test
test: ## run go tests
@echo "--------- running: $@ ---------"
go test -v -race -timeout=30s -count=1 ./...
.PHONY: bench
bench: ## run benchmarks
@echo "--------- running: $@ ---------"
go test -bench=. -run=^$$ -benchmem ./...
.PHONY: godoc
godoc: ## start godoc server at :8000
@echo "--------- running: $@ ---------"
ifeq ($(PLATFORM),Darwin)
@(sleep 2; open http://localhost:8000/pkg/$(GO_MODULE)) &
endif
@echo "serving godoc at http://127.0.0.1:8000"
@godoc -http=127.0.0.1:8000
.PHONY: generate
generate: ## run go generate ./...
@echo "--------- running: $@ ---------"
go generate ./...
.PHONY: build
build: ## build the binaries
@echo "--------- running: $@ ---------"
go build -o bin/server ./cmd/server
.PHONY: image
image: ## build the docker image
@echo "--------- running: $@ ---------"
DOCKER_BUILDKIT=1 docker build -t kv -t $(IMAGE_NAME) .
.PHONY: proto-clean
proto-clean: ## clean generated protobuf code
@echo "--------- running: $@ ---------"
find . -name '*.pb.go' -not -path './vendor' -delete
.PHONY: proto-gen
proto-gen: ## generate protobuf/grpc models
@echo "--------- running: $@ ---------"
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative $(PROTO_FILES)
.PHONY: proto
proto: proto-clean proto-gen ## re-generate protobuf models
.PHONY: lint
lint: ## run linter
@echo "--------- running: $@ ---------"
golangci-lint run $(LINT_PACKAGE)
.PHONY: escape
escape: ## run escape analysis
@echo "--------- running: $@ ---------"
go test -run=^$$ -gcflags="-m" ./... 2>&1 | grep -Ev '(_test\.go|\$$GOROOT|<autogenerated>|^/var)'