-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
295 lines (226 loc) · 7.62 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
BIN_DIR=./bin
SHELL := env DOCKER_REPO=$(DOCKER_REPO) $(SHELL)
DOCKER_REPO?=olegbalunenko
SHELL := env VERSION=$(VERSION) $(SHELL)
VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=scrum-report
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)
GOVERSION:=1.22
GOTOOLS_IMAGE_TAG?=v0.13.0
SHELL := env GOTOOLS_IMAGE_TAG=$(GOTOOLS_IMAGE_TAG) $(SHELL)
COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml
COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE)
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --remove-orphans --exit-code-from
COMPOSE_TOOLS_CMD_DOWN=$(COMPOSE_TOOLS_CMD_BASE) down --volumes --remove-orphans
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) build
TARGET_MAX_CHAR_NUM=20
## Show help
help:
${call colored, help is running...}
@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 + 3, RLENGTH); \
printf " %-$(TARGET_MAX_CHAR_NUM)s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Build project.
build: compile-app
.PHONY: build
teardown-tools:
$(COMPOSE_TOOLS_CMD_DOWN)
.PHONY: teardown-tools
## Compile app.
compile-app:
./scripts/build/app.sh
.PHONY: compile-app
## Test coverage report.
test-cover:
./scripts/tests/coverage.sh
.PHONY: test-cover
prepare-cover-report: test-cover
$(COMPOSE_TOOLS_CMD_UP) prepare-cover-report prepare-cover-report
.PHONY: prepare-cover-report
## Open coverage report.
open-cover-report: prepare-cover-report
./scripts/open-coverage-report.sh
.PHONY: open-cover-report
## Update readme coverage.
update-readme-cover: build prepare-cover-report
$(COMPOSE_TOOLS_CMD_UP) update-readme-coverage update-readme-coverage
.PHONY: update-readme-cover
## Run tests.
test:
$(COMPOSE_TOOLS_CMD_UP) run-tests run-tests
.PHONY: test
## Run regression tests.
test-regression: test
.PHONY: test-regression
## Sync vendor and install needed tools.
configure: sync-vendor install-tools
## Sync vendor with go.mod.
sync-vendor:
./scripts/sync-vendor.sh
.PHONY: sync-vendor
## Fix imports sorting.
imports:
$(COMPOSE_TOOLS_CMD_UP) fix-imports fix-imports
.PHONY: imports
## Format code with go fmt.
fmt:
$(COMPOSE_TOOLS_CMD_UP) fix-fmt fix-fmt
.PHONY: fmt
## Format code and sort imports.
format-project: fmt imports
.PHONY: format-project
## Installs vendored tools.
install-tools:
echo "Installing ${GOTOOLS_IMAGE_TAG}"
$(COMPOSE_TOOLS_CMD_PULL)
.PHONY: install-tools
## vet project
vet:
$(COMPOSE_TOOLS_CMD_UP) vet vet
.PHONY: vet
## Run full linting
lint-full:
$(COMPOSE_TOOLS_CMD_UP) lint-full lint-full
.PHONY: lint-full
## Run linting for build pipeline
lint-pipeline:
$(COMPOSE_TOOLS_CMD_UP) lint-pipeline lint-pipeline
.PHONY: lint-pipeline
## Run linting for sonar report
lint-sonar:
$(COMPOSE_TOOLS_CMD_UP) lint-sonar lint-sonar
.PHONY: lint-sonar
## recreate all generated code and documentation.
codegen:
$(COMPOSE_TOOLS_CMD_UP) go-generate go-generate
.PHONY: codegen
## recreate all generated code and swagger documentation and format code.
generate: codegen format-project vet
.PHONY: generate
## Release
release:
$(COMPOSE_TOOLS_CMD_UP) release release
.PHONY: release
## Release local snapshot
release-local-snapshot:
$(COMPOSE_TOOLS_CMD_UP) release-local-snapshot release-local-snapshot
.PHONY: release-local-snapshot
## Check goreleaser config.
check-releaser:
$(COMPOSE_TOOLS_CMD_UP) release-check-config release-check-config
.PHONY: check-releaser
## Issue new release.
new-version: vet test-regression build
./scripts/release/new-version.sh
.PHONY: new-release
######################################
############### DOCKER ###############
######################################
################ PROD #################
## Push all prod images to registry.
docker-push-prod-images:
./scripts/docker/push-all-images-to-registry.sh ${DOCKER_REPO}
.PHONY: docker-push-prod-images
## Build docker base images.
docker-build-base-prod: docker-build-base-go-prod
.PHONY: docker-build-base-prod
## Build docker base image for GO
docker-build-base-go-prod:
./scripts/docker/build/prod/go-base.sh
.PHONY: docker-build-base-go-prod
## Build all services docker prod images for deploying to gcloud.
docker-build-prod: docker-build-backend-prod
.PHONY: docker-build-prod
## Build all backend services docker prod images for deploying to gcloud.
docker-build-backend-prod: docker-build-scrum-report-prod
.PHONY: docker-build-backend-prod
## Build admin service prod docker image.
docker-build-scrum-report-prod:
./scripts/docker/build/prod/scrum-report.sh
.PHONY: docker-build-scrum-report-prod
## Docker compose up - deploys prod containers on docker locally.
docker-compose-up:
./scripts/docker/compose/prod/up.sh
.PHONY: docker-compose-up
## Docker compose down - remove all prod containers in docker locally.
docker-compose-down:
./scripts/docker/compose/prod/down.sh
.PHONY: docker-compose-down
## Docker compose stop - stops all prod containers in docker locally.
docker-compose-stop:
./scripts/docker/compose/prod/stop.sh
.PHONY: docker-compose-stop
## Build all prod images: base and services.
docker-prepare-images-prod: docker-build-base-prod docker-build-prod
.PHONY: docker-prepare-images-prod
## Prod local full deploy: build base images, build services images, deploy to docker compose
deploy-local-prod: docker-prepare-images-prod run-local-prod
.PHONY: deploy-local-prod
## Run locally: deploy to docker compose and expose tunnels.
run-local-prod: docker-compose-up
.PHONY: run-local-prod
## Stop the world and close tunnels.
stop-local-prod: docker-compose-stop
.PHONY: stop-local-prod
################## DEV ###################
## Build docker base images.
docker-build-base-dev: docker-build-base-go-dev
.PHONY: docker-build-base-dev
## Build docker base image for GO
docker-build-base-go-dev:
./scripts/docker/build/dev/go-base.sh
.PHONY: docker-build-base-go-dev
## Build docker dev image for running locally.
docker-build-dev: docker-build-scrum-report-dev
.PHONY: docker-build-dev
## Build admin service dev docker image.
docker-build-scrum-report-dev:
./scripts/docker/build/dev/scrum-report.sh
.PHONY: docker-build-scrum-report-dev
## Dev Docker-compose up with stubbed 3rd party dependencies.
dev-docker-compose-up:
./scripts/docker/compose/dev/up.sh
.PHONY: dev-docker-compose-up
## Docker compose down.
dev-docker-compose-down:
./scripts/docker/compose/dev/down.sh
.PHONY: dev-docker-compose-down
## Docker compose stop - stops all dev containers in docker locally.
dev-docker-compose-stop:
./scripts/docker/compose/dev/stop.sh
.PHONY: dev-docker-compose-stop
## Build all dev images: base and services.
docker-prepare-images-dev: docker-build-base-dev docker-build-dev
.PHONY: docker-prepare-images-dev
## Dev local full deploy: build base images, build services images, deploy to docker compose
deploy-local-dev: docker-prepare-images-dev run-local-dev
.PHONY: deploy-local-dev
## Run locally dev: deploy to docker compose and expose tunnels.
run-local-dev: dev-docker-compose-up
.PHONY: run-local-dev
## Stop the world and close tunnels.
stop-local-dev: dev-docker-compose-stop
.PHONY: stop-local-prod
## Open containers logs service url.
open-container-logs:
./scripts/browser-opener.sh -u 'http://localhost:9999/'
.PHONY: open-container-logs
## Opens url of web amin in browser.
open-scrum-report:
./scripts/browser-opener.sh -u 'http://localhost.charlesproxy.com:8080/'
.PHONY: open-scrum-report
bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version
.DEFAULT_GOAL := help