forked from sdgmf/go-project-sample
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (63 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
apps = 'products' 'details' 'ratings' 'reviews'
.PHONY: run
run: proto wire
for app in $(apps) ;\
do \
go run ./cmd/$$app -f configs/$$app.yml & \
done
.PHONY: wire
wire:
wire ./...
.PHONY: test
test: mock
for app in $(apps) ;\
do \
go test -v ./internal/app/$$app/... -f `pwd`/configs/$$app.yml -covermode=count -coverprofile=dist/cover-$$app.out ;\
done
.PHONY: build
build:
for app in $(apps) ;\
do \
GOOS=linux GOARCH="amd64" go build -o dist/$$app-linux-amd64 ./cmd/$$app/; \
GOOS=darwin GOARCH="amd64" go build -o dist/$$app-darwin-amd64 ./cmd/$$app/; \
done
.PHONY: cover
cover: test
for app in $(apps) ;\
do \
go tool cover -html=dist/cover-$$app.out; \
done
.PHONY: mock
mock:
mockery --all
.PHONY: lint
lint:
golint ./...
.PHONY: proto
proto:
# protoc -I api/proto ./api/proto/* --go_out=plugins=grpc:api/proto
protoc -I api/proto ./api/proto/* --go_out=api/pb --go-grpc_out=api/pb
.PHONY: dash
dash: # create grafana dashboard
for app in $(apps) ;\
do \
jsonnet -J ./grafana/grafonnet-lib -o ./configs/grafana/dashboards/$$app.json --ext-str app=$$app ./scripts/grafana/dashboard.jsonnet ;\
done
.PHONY: pubdash
pubdash:
for app in $(apps) ;\
do \
jsonnet -J ./grafana/grafonnet-lib -o ./configs/grafana/dashboards-api/$$app-api.json --ext-str app=$$app ./scripts/grafana/dashboard-api.jsonnet ; \
curl -X DELETE --user admin:admin -H "Content-Type: application/json" 'http://localhost:3000/api/dashboards/db/$$app'; \
curl -x POST --user admin:admin -H "Content-Type: application/json" --data-binary "@./configs/grafana/dashboards-api/$$app-api.json" http://localhost:3000/api/dashboards/db ; \
done
.PHONY: rules
rules:
for app in $(apps) ;\
do \
jsonnet -o ./configs/prometheus/rules/$$app.yml --ext-str app=$$app ./scripts/prometheus/rules.jsonnet ; \
done
.PHONY: docker
docker-compose: build dash rules
docker-compose -f deployments/docker-compose.yml up --build -d
all: lint cover docker