-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (48 loc) · 1.21 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
.PHONY: init
# init tools
init:
@echo "Installing tools from tools/tools.go"
@cd tools && cat tools.go |grep _|awk -F '"' '{print $$2}' | xargs -tI % go install % && cd -
# update buf mod
update:
cd api && buf mod update
.PHONY: generate
# generate code
generate:
buf generate
cd api && buf generate --template buf.gen.tag.yaml
cd api && find . -type f -path '*.pb.go'|xargs -r rm
.PHONY: lint
# lint
lint:
buf lint
# breaking
breaking:
buf breaking --against https://github.com/douyu/proto/.git#branch=main,ref=HEAD~1,subdir=api
# test
test:
go test -v -cover ./...
# validate openapi docs
validate:
swagger validate gen/go/api/helloworld/v1/helloworld.swagger.json
# serve openapi docs
serve:
swagger serve gen/go/api/helloworld/v1/helloworld.swagger.json
.PHONY: all
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help