-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
352 lines (318 loc) · 16.6 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
.DELETE_ON_ERROR: clean
EXECUTABLES = go zip shasum
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))
PROJECT_NAME ?= idp-scim-sync
PROJECT_NAMESPACE ?= slashdevops
PROJECT_MODULES_PATH := $(shell ls -d cmd/*)
PROJECT_MODULES_NAME := $(foreach dir_name, $(PROJECT_MODULES_PATH), $(shell basename $(dir_name)) )
PROJECT_DEPENDENCIES := $(shell go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all)
BUILD_DIR := ./build
DIST_DIR := ./dist
DIST_ASSEST_DIR := $(DIST_DIR)/assets
PROJECT_COVERAGE_FILE ?= $(BUILD_DIR)/coverage.txt
PROJECT_COVERAGE_MODE ?= atomic
PROJECT_COVERAGE_TAGS ?= unit
GIT_VERSION ?= $(shell git rev-parse --abbrev-ref HEAD | cut -d "/" -f 2)
GIT_REVISION ?= $(shell git rev-parse HEAD | tr -d '\040\011\012\015\n')
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD | tr -d '\040\011\012\015\n')
GIT_USER ?= $(shell git config --get user.name | tr -d '\040\011\012\015\n')
BUILD_DATE ?= $(shell date +'%Y-%m-%dT%H:%M:%S')
GO_LDFLAGS_OPTIONS ?= -s -w
define EXTRA_GO_LDFLAGS_OPTIONS
-X '"'github.com/$(PROJECT_NAMESPACE)/$(PROJECT_NAME)/internal/version.Version=$(GIT_VERSION)'"' \
-X '"'github.com/$(PROJECT_NAMESPACE)/$(PROJECT_NAME)/internal/version.Revision=$(GIT_REVISION)'"' \
-X '"'github.com/$(PROJECT_NAMESPACE)/$(PROJECT_NAME)/internal/version.Branch=$(GIT_BRANCH)'"' \
-X '"'github.com/$(PROJECT_NAMESPACE)/$(PROJECT_NAME)/internal/version.BuildUser=$(GIT_USER)'"' \
-X '"'github.com/$(PROJECT_NAMESPACE)/$(PROJECT_NAME)/internal/version.BuildDate=$(BUILD_DATE)'"'
endef
GO_LDFLAGS := -ldflags "$(GO_LDFLAGS_OPTIONS) $(EXTRA_GO_LDFLAGS_OPTIONS)"
GO_CGO_ENABLED ?= 0
GO_OPTS ?= -v
GO_OS ?= darwin linux windows
GO_ARCH ?= arm64 amd64
# avoid mocks in tests
GO_FILES := $(shell go list ./... | grep -v /mocks/)
GO_GRAPH_FILE := $(BUILD_DIR)/go-mod-graph.txt
CONTAINER_OS ?= linux
CONTAINER_ARCH ?= arm64v8 amd64
CONTAINER_NAMESPACE ?= $(PROJECT_NAMESPACE)
CONTAINER_IMAGE_NAME ?= $(PROJECT_NAME)
DOCKER_CONTAINER_REPO ?= docker.io
GITHUB_CONTAINER_REPO ?= ghcr.io
AWS_ECR_CONTAINER_REPO ?= public.ecr.aws/l2n7y5s7
AWS_SAM_LAMBDA_BINARY_NAME ?= bootstrap
AWS_SAM_PROJECT_APP_NAME ?= idpscim
AWS_SAM_OS ?= linux
AWS_SAM_ARCH ?= arm64
######## Functions ########
# this is a funtion that will execute a command and print a message
# MAKE_DEBUG=true make <target> will print the command
# MAKE_STOP_ON_ERRORS=true make any fail will stop the execution if the command fails, this is useful for CI
# NOTE: if the dommand has a > it will print the output into the original redirect of the command
define exec_cmd
$(if $(filter $(MAKE_DEBUG),true),\
$1 \
, \
$(if $(filter $(MAKE_STOP_ON_ERRORS),true),\
@$1 > /dev/null 2>&1 && printf " 🤞 ${1} ✅\n" || (printf " ${1} ❌ 🖕\n"; exit 1) \
, \
$(if $(findstring >, $1),\
@$1 2>/dev/null && printf " 🤞 ${1} ✅\n" || printf " ${1} ❌ 🖕\n" \
, \
@$1 > /dev/null 2>&1 && printf ' 🤞 ${1} ✅\n' || printf ' ${1} ❌ 🖕\n' \
) \
) \
)
endef # don't remove the whiteline before endef
###############################################################################
######## Targets ##############################################################
##@ Default command
.PHONY: all
all: clean test build ## Clean, test and build the application. Execute by default when make is called without arguments
###############################################################################
##@ Golang commands
.PHONY: go-fmt
go-fmt: ## Format go code
@printf "👉 Formatting go code...\n"
$(call exec_cmd, go fmt ./... )
.PHONY: go-vet
go-vet: ## Vet go code
@printf "👉 Vet go code...\n"
$(call exec_cmd, go vet ./... )
.PHONY: go-generate
go-generate: ## Generate go code
@printf "👉 Generating go code...\n"
$(call exec_cmd, go generate ./... )
.PHONY: go-mod-tidy
go-mod-tidy: ## Clean go.mod and go.sum
@printf "👉 Cleaning go.mod and go.sum...\n"
$(call exec_cmd, go mod tidy)
.PHONY: go-mod-update
go-mod-update: go-mod-tidy ## Update go.mod and go.sum
@printf "👉 Updating go.mod and go.sum...\n"
$(foreach DEP, $(PROJECT_DEPENDENCIES), \
$(call exec_cmd, go get -u $(DEP)) \
)
.PHONY: go-mod-vendor
go-mod-vendor: ## Create mod vendor
@printf "👉 Creating mod vendor...\n"
$(call exec_cmd, go mod vendor)
.PHONY: go-mod-verify
go-mod-verify: ## Verify go.mod and go.sum
@printf "👉 Verifying go.mod and go.sum...\n"
$(call exec_cmd, go mod verify)
.PHONY: go-mod-download
go-mod-download: ## Download go dependencies
@printf "👉 Downloading go dependencies...\n"
$(call exec_cmd, go mod download)
.PHONY: go-mod-graph
go-mod-graph: ## Create a file with the go dependencies graph in build dir
@printf "👉 Printing go dependencies graph...\n"
$(call exec_cmd, go mod graph > $(GO_GRAPH_FILE))
# this target is needed to create the dist folder and the coverage file
$(PROJECT_COVERAGE_FILE):
@printf "👉 Creating coverage file...\n"
$(call exec_cmd, mkdir -p $(BUILD_DIR) )
$(call exec_cmd, touch $(PROJECT_COVERAGE_FILE) )
.PHONY: go-test-coverage
go-test-coverage: test ## Shows in you browser the test coverage report per package
@printf "👉 Running got tool coverage...\n"
$(call exec_cmd, go tool cover -html=$(PROJECT_COVERAGE_FILE))
###############################################################################
##@ Test commands
.PHONY: test
test: $(PROJECT_COVERAGE_FILE) go-mod-tidy go-fmt go-vet go-generate ## Run tests
@printf "👉 Running tests...\n"
$(call exec_cmd, go test \
-v -race \
-coverprofile=$(PROJECT_COVERAGE_FILE) \
-covermode=$(PROJECT_COVERAGE_MODE) \
-tags=$(PROJECT_COVERAGE_TAGS) \
./... \
)
###############################################################################
##@ Build commands
.PHONY: build
build: go-generate go-fmt go-vet test ## Build the application
@printf "👉 Building applications...\n"
$(foreach proj_mod, $(PROJECT_MODULES_NAME), \
$(call exec_cmd, CGO_ENABLED=$(GO_CGO_ENABLED) go build $(GO_LDFLAGS) $(GO_OPTS) -o $(BUILD_DIR)/$(proj_mod) ./cmd/$(proj_mod)/ ) \
$(call exec_cmd, chmod +x $(BUILD_DIR)/$(proj_mod) ) \
)
.PHONY: build-dist
build-dist: ## Build the application for all platforms defined in GO_OS and GO_ARCH in this Makefile
@printf "👉 Building application for different platforms...\n"
$(foreach GOOS, $(GO_OS), \
$(foreach GOARCH, $(GO_ARCH), \
$(foreach proj_mod, $(PROJECT_MODULES_NAME), \
$(call exec_cmd, GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=$(GO_CGO_ENABLED) go build $(GO_LDFLAGS) $(GO_OPTS) -o $(DIST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH) ./cmd/$(proj_mod)/ ) \
$(call exec_cmd, chmod +x $(DIST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH)) \
)\
)\
)
.PHONY: build-dist-zip
build-dist-zip: ## Build the application for all platforms defined in GO_OS and GO_ARCH in this Makefile and create a zip file for each binary
@printf "👉 Creating zip files for distribution...\n"
$(call exec_cmd, mkdir -p $(DIST_ASSEST_DIR))
$(foreach GOOS, $(GO_OS), \
$(foreach GOARCH, $(GO_ARCH), \
$(foreach proj_mod, $(PROJECT_MODULES_NAME), \
$(call exec_cmd, zip --junk-paths -r $(DIST_ASSEST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH).zip $(DIST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH) ) \
$(call exec_cmd, shasum -a 256 $(DIST_ASSEST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH).zip | cut -d ' ' -f 1 > $(DIST_ASSEST_DIR)/$(proj_mod)-$(GOOS)-$(GOARCH).sha256 ) \
) \
) \
)
###############################################################################
# This target is used by AWS SAM build command
# and was added to build the binary using custom flags
# Ref:
# + https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/building-custom-runtimes.html
# + https://jiangsc.me/2021/01/24/Lessons-Learnt-On-Deploying-GO-Lambda-Application-on-AWS/
# NOTES:
# + The ARTIFACTS_DIR environment variable is injected by AWS SAM build command
##@ AWS Lambda commands
.PHONY: build-LambdaFunction
build-LambdaFunction: ## Build the application for AWS Lambda, this target is used by AWS SAM build command
@printf "👉 Called from sam build command ...\n"
@printf " 👉 ARTIFACTS_DIR injected from sam build command: %s\n" $(ARTIFACTS_DIR)
$(call exec_cmd, GOOS=$(AWS_SAM_OS) GOARCH=$(AWS_SAM_ARCH) CGO_ENABLED=$(GO_CGO_ENABLED) go build $(GO_LDFLAGS) $(GO_OPTS) -tags lambda.norpc -o $(ARTIFACTS_DIR)/$(AWS_SAM_LAMBDA_BINARY_NAME) ./cmd/$(AWS_SAM_PROJECT_APP_NAME)/ )
###############################################################################
##@ Container commands
.PHONY: container-build
container-build: build-dist ## Build the container image
@printf "👉 Building container image...\n"
$(foreach OS, $(CONTAINER_OS), \
$(foreach ARCH, $(CONTAINER_ARCH), \
$(if $(findstring v, $(ARCH)), $(eval BIN_ARCH = arm64), $(eval BIN_ARCH = $(ARCH)) ) \
$(call exec_cmd, docker build \
--build-arg ARCH=$(ARCH) \
--build-arg BIN_ARCH=$(BIN_ARCH) \
--build-arg OS=$(OS) \
--build-arg PROJECT_NAME=$(AWS_SAM_PROJECT_APP_NAME) \
--tag $(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH) \
--tag $(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH) \
--tag $(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH) \
--tag $(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH) \
--tag $(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH) \
--tag $(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH) \
./. \
) \
) \
)
.PHONY: container-publish-docker
container-publish-docker: ## Publish the container image to docker hub
@printf "👉 Publishing container image to docker hub...\n"
$(foreach OS, $(CONTAINER_OS), \
$(foreach ARCH, $(CONTAINER_ARCH), \
$(if $(findstring v, $(ARCH)), $(eval BIN_ARCH = arm64), $(eval BIN_ARCH = $(ARCH)) ) \
\
$(call exec_cmd, docker push "$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" ) \
$(call exec_cmd, docker push "$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" ) \
\
$(call exec_cmd, docker manifest create --amend \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest create --amend \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest push "$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" ) \
$(call exec_cmd, docker manifest push "$(DOCKER_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" ) \
) \
)
.PHONY: container-publish-github
container-publish-github: ## Publish the container image to github container registry
@printf "👉 Publishing container image to github container registry...\n"
$(foreach OS, $(CONTAINER_OS), \
$(foreach ARCH, $(CONTAINER_ARCH), \
$(if $(findstring v, $(ARCH)), $(eval BIN_ARCH = arm64), $(eval BIN_ARCH = $(ARCH)) ) \
\
$(call exec_cmd, docker push "$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" ) \
$(call exec_cmd, docker push "$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" ) \
\
$(call exec_cmd, docker manifest create --amend \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest create --amend \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest push "$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" ) \
$(call exec_cmd, docker manifest push "$(GITHUB_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" ) \
) \
)
.PHONY: container-publish-aws-ecr
container-publish-aws-ecr: ## Publish the container image to AWS ECR
@printf "👉 Publishing container image to AWS ECR...\n"
$(foreach OS, $(CONTAINER_OS), \
$(foreach ARCH, $(CONTAINER_ARCH), \
$(if $(findstring v, $(ARCH)), $(eval BIN_ARCH = arm64), $(eval BIN_ARCH = $(ARCH)) ) \
\
$(call exec_cmd, docker push "$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" ) \
$(call exec_cmd, docker push "$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" ) \
\
$(call exec_cmd, docker manifest create --amend \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest create --amend \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
) \
$(call exec_cmd, docker manifest annotate \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" \
"$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest-$(OS)-$(ARCH)" \
--os $(OS) --arch $(BIN_ARCH) $(if $(findstring v, $(ARCH)), --variant "v8", ) \
) \
\
$(call exec_cmd, docker manifest push "$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):latest" ) \
$(call exec_cmd, docker manifest push "$(AWS_ECR_CONTAINER_REPO)/$(CONTAINER_NAMESPACE)/$(CONTAINER_IMAGE_NAME):$(GIT_VERSION)" ) \
) \
)
###############################################################################
##@ Support Commands
.PHONY: clean
clean: ## Clean the environment
@printf "👉 Cleaning environment...\n"
$(call exec_cmd, go clean -n -x -i)
$(call exec_cmd, rm -rf $(BUILD_DIR) $(DIST_DIR) .aws-sam ./build.toml ./packaged.yaml )
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; \
printf "Usage: make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ \
{ printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 } /^##@/ \
{ printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' \
$(MAKEFILE_LIST)