-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
192 lines (147 loc) · 4.29 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
BIN_DIR=./bin
SHELL := env VERSION=$(VERSION) $(SHELL)
VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=instadiff-cli
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)
GOVERSION:=1.22
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_PULL=$(COMPOSE_TOOLS_CMD_BASE) build
TARGET_MAX_CHAR_NUM=20
GOTOOLS_IMAGE?=go-tools-local
SHELL := env GOTOOLS_IMAGE=$(GOTOOLS_IMAGE) $(SHELL)
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
define colored
@echo '${GREEN}$1${RESET}'
endef
## Show help
help:
${call colored, help is running...}
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@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 " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Compile app
compile-instadiff-cli: vet
./scripts/build/app.sh
.PHONY: compile-instadiff-cli
## Build the app.
build: sync-vendor compile-instadiff-cli
.PHONY: build
## 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
## vet project
vet:
./scripts/linting/run-vet.sh
.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
## Test all packages
test:
./scripts/tests/run.sh
.PHONY: test
test-regression: test
.PHONY: test-regression
## 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
## Tests sonar report generate.
test-sonar-report:
./scripts/tests/sonar-report.sh
.PHONY: test-sonar-report
## Installs vendored tools.
install-tools:
./scripts/install/vendored-tools.sh
.PHONY: install-tools
## Sync vendor of root project and tools.
sync-vendor:
./scripts/sync-vendor.sh
.PHONY: sync-vendor
## Docker compose up
docker-up:
${call colored, docker is running...}
docker-compose -f ./docker-compose.yml up -d
.PHONY: docker-up
## Docker compose down
docker-down:
${call colored, docker is running...}
docker-compose -f ./docker-compose.yml down
.PHONY: docker-down
## Fix imports sorting.
imports:
${call colored, fix-imports is running...}
$(COMPOSE_TOOLS_CMD_UP) fix-imports fix-imports
.PHONY: imports
## Format code.
fmt:
${call colored, fmt is running...}
$(COMPOSE_TOOLS_CMD_UP) fix-fmt fix-fmt
.PHONY: fmt
## Format code and sort imports.
format-project: fmt imports
.PHONY: format-project
## Open coverage report.
open-cover-report: test-cover prepare-cover-report
./scripts/open-coverage-report.sh
.PHONY: open-cover-report
## Update readme coverage badge.
update-readme-cover: test-cover
$(COMPOSE_TOOLS_CMD_UP) update-readme-coverage update-readme-coverage
.PHONY: update-readme-cover
## 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: test build
./scripts/release/new-version.sh
.PHONY: new-release
build-go-tools: install-tools
.PHONY: build-go-tools
bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version
.DEFAULT_GOAL := test