-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
161 lines (126 loc) · 3.66 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
BIN_DIR=./bin
SHELL := env VERSION=$(VERSION) $(SHELL)
VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=ge-tax-calc
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)
RELEASE_BRANCH?=master
SHELL := env RELEASE_BRANCH=$(RELEASE_BRANCH) $(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 --build --remove-orphans --exit-code-from
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) build
GOVERSION:=1.23
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: sync-vendor generate compile-app
.PHONY: build
## Compile app.
compile-app:
$(COMPOSE_TOOLS_CMD_UP) build build
.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
test-integration:
./scripts/tests/integration.sh
.PHONY: test-integration
## 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:
$(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
bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version
.DEFAULT_GOAL := help