/
Makefile
executable file
·132 lines (103 loc) · 2.63 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Go parameters
GOCMD =go
GOBUILD =$(GOCMD) build
GOINSTALL =$(GOCMD) install
GOCLEAN =$(GOCMD) clean
GOTEST =$(GOCMD) test
TEST_FLAGS ?=-v
BINARY_NAME =dispatch
BIN =$$PWD/bin
GOMODULES ?=on
# Finding root folder
TOP =$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BOTTOM =$(shell dirname $(TOP))
VCS_REF ?=$(shell git describe --tags --long --abbrev=8 --always HEAD)
GOFLAGS ?=-mod=vendor -gcflags='-e' -ldflags "-X main.build=${VCS_REF}"
##
## Build
##
define build
GOGC=off GO111MODULE=$(GOMODULES) GOBIN=$(BIN) CGO_ENABLED=0 \
$(GOINSTALL) -v $(GOFLAGS) $(1)
endef
build:
$(call build,./cmd/$(BINARY_NAME))
##
## Local Development
##
define run
sh -c '$(MAKE) build && \
export BASE_PATH=$(TOP) && \
./bin/$(1)'
endef
define run-help
sh -c 'BASE_PATH=$(TOP) $(MAKE) build && \
./bin/$(1) -h'
endef
define test
sh -c 'BASE_PATH=$(TOP) go test ./... -v -cover'
endef
define test-color
sh -c 'BASE_PATH=$(TOP) gotest ./... -v -cover'
endef
clean:
$(GOCLEAN) -modcache -testcache
rm -rf ./bin/$(BINARY_NAME)
run:
$(call run,$(BINARY_NAME))
run-help:
$(call run-help,$(BINARY_NAME))
test:
$(call test)
test-color:
$(call test-color)
##
## Proto Gen
##
proto: proto-clean
go generate ./internal/proto/...
proto-clean:
rm -f ./internal/proto/*.gen.go
rm -f ./internal/proto/*.gen.js
rm -f ./internal/proto/*.gen.ts
##
## Tools
##
tools:
export GO111MODULE=off && \
go get -u github.com/goware/modvendor
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/rakyll/gotest
##
## Dependency mgmt
##
dep:
@export GO111MODULE=on && \
go mod tidy && \
rm -rf ./vendor && go mod vendor && \
modvendor -copy="**/*.c **/*.h **/*.s **/*.proto"
dep-upgrade-all:
@GO111MODULE=on go get -u ./...
@$(MAKE) dep
##
## Docker deploy
##
deploy:
heroku container:push web --recursive
release:
heroku container:release web
##
## Compose
##
compose-up:
docker-compose up --build
compose-down:
docker-compose down
##
## Load test
load-create-task:
hey -m POST -c 100 -n 1000 -H "Content-Type: application/json" -d '{"req": {"operation": "Pickup","driverName": "fierce-bob","week": 1,"day": 2,"startHour": "17:00","duration": 2}}' "http://0.0.0.0:9000/rpc/Dispatch/CreateTask"
load-read-schedule:
hey -m POST -c 100 -n 1000 -H "Content-Type: application/json" -d '{"req": {"driverName": "fierce-bob","week": 1}}' "http://0.0.0.0:9000/rpc/Dispatch/ReadSchedule"
load-delete-task:
hey -m POST -c 100 -n 1000 -H "Content-Type: application/json" -d '{"req": {"driverName": "fierce-bob","week": 1,"day": 2,"startHour": "12:00"}}' "http://0.0.0.0:9000/rpc/Dispatch/DeleteTask"