This repository has been archived by the owner on May 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
168 lines (144 loc) · 4.3 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
VERSION=`git rev-parse --short HEAD`
DEV_ENV=export `less ./dev/.env | xargs`
TEST_COMPOSE=docker-compose -f dev/testenv.yml -p test
MON_COMPOSE=docker-compose -f dev/monitoring.yml -p monitoring
.PHONY: help
help: Makefile
@echo " Choose a command run in pinpoint:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
## all: Runs check
all: check
## check: Run simple checks
.PHONY: check
check:
go vet ./...
go test -run xxxx ./...
## deps: Install dependencies
.PHONY: deps
deps:
bash .scripts/protoc-gen-go.sh
go get -u github.com/maxbrunsfeld/counterfeiter
go get -u github.com/vburenin/ifacemaker
go get -u github.com/go-swagger/go-swagger/cmd/swagger
npm install -g redoc-cli
dep ensure
( cd client ; npm install )
( cd frontend ; npm install )
## test: Execute tests
.PHONY: test
test:
go test -race -cover ./...
( cd frontend ; npm run test -- --coverage )
( cd client ; npm run test )
## testenv: Set up test environment
.PHONY: testenv
testenv:
mkdir -p tmp/data
$(TEST_COMPOSE) up -d
## testenv-stop: Stop test environment
.PHONY: testenv-stop
testenv-stop:
$(TEST_COMPOSE) stop
## monitoring: Set up monitoring environment
.PHONY: monitoring
monitoring:
mkdir -p tmp/data
$(MON_COMPOSE) up -d
## monitoring-stop: Stop monitoring environment
.PHONY: monitoring-stop
monitoring-stop:
$(MON_COMPOSE) stop
## clean: Clean up stuff
.PHONY: clean
clean: testenv-stop monitoring-stop
$(TEST_COMPOSE) rm -f -s -v
$(MON_COMPOSE) rm -f -s -v
rm -rf tmp
## lint: Run linters and checks
.PHONY: lint
lint: SHELL:=bash
lint: check
diff -u <(echo -n) <(gofmt -d -s `find . -type f -name '*.go' -not -path "./vendor/*"`)
diff -u <(echo -n) <(golint `go list ./... | grep -v /vendor/`)
( cd frontend ; npm run lint )
( cd client ; npm run lint )
## gen: Regenerate all generated code
.PHONY: gen
gen: proto mocks
## proto: Generate protobuf code from definitions
.PHONY: proto
proto:
protoc -I protobuf pinpoint.proto --go_out=plugins=grpc:protobuf
make proto-pkg PKG=models
make proto-pkg PKG=request
make proto-pkg PKG=response
# generate mock
counterfeiter -o ./protobuf/fakes/pinpoint.pb.go \
./protobuf/pinpoint.pb.go CoreClient
## proto-pkg: Runs protoc definitions
.PHONY: proto-pkg
proto-pkg:
protoc -I protobuf $(PKG)/$(PKG).proto --go_out=plugins=grpc:$(GOPATH)/src
## mocks: Generate database interface and mock
.PHONY: mocks
mocks:
ifacemaker \
-f ./core/database/clubuser.go \
-f ./core/database/eventapplicant.go \
-s Database \
-i DBClient \
--pkg database \
-o ./core/database/database.i.go \
-c "Code generated by ifacemaker. DO NOT EDIT." \
-y "DBClient wraps the AWS DynamoDB database API"
counterfeiter -o ./core/database/mocks/database.i.go \
./core/database/database.i.go DBClient
## core: Runs core service
.PHONY: core
core:
go run core/main.go run --dev \
--tls.cert dev/certs/127.0.0.1.crt \
--tls.key dev/certs/127.0.0.1.key $(FLAGS)
## gateway: Runs API gateway
.PHONY: gateway
gateway:
go run gateway/main.go run --dev \
--core.cert dev/certs/127.0.0.1.crt $(FLAGS)
## gateway-tls: Runs gateway tls
.PHONY: gateway-tls
gateway-tls:
go run gateway/main.go run --dev \
--core.cert dev/certs/127.0.0.1.crt \
--tls.cert dev/certs/127.0.0.1.crt \
--tls.key dev/certs/127.0.0.1.key $(FLAGS)
## web: Runs web app
.PHONY: web
web:
( cd frontend ; npm start )
## pinpoint-core: Builds binary for pinpoint-core
.PHONY: pinpoint-core
pinpoint-core:
go build -o ./bin/pinpoint-core \
-ldflags "-X main.Version=$(VERSION)" \
./core $(FLAGS)
## pinpoint-gateway: Builds binary for pinpoint-gateway
.PHONY: pinpoint-gateway
pinpoint-gateway:
go build -o ./bin/pinpoint-gateway \
-ldflags "-X main.Version=$(VERSION)" \
./gateway $(FLAGS)
## swagger: Generates API code from swagger tool
.PHONY: swagger
swagger:
brew install openapi-generator
openapi-generator generate -i ./docs_src/api/swagger.yml -g go-server -o ./swag-gen
## docs-api: build API reference from Swagger definitions in /docs_src/api
.PHONY: docs-api
docs-api:
openapi-generator validate -i ./docs_src/api/swagger.yml
@echo [INFO] Generating API documentation
@redoc-cli bundle ./docs_src/api/swagger.yml -o ./docs/api/index.html
## run-docs-api: run doc server from ./docs_src for the API reference website only
.PHONY: run-docs-api
run-docs-api:
redoc-cli serve ./docs_src/api/swagger.yml -w