-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (45 loc) · 1.71 KB
/
Makefile
File metadata and controls
61 lines (45 loc) · 1.71 KB
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
.DEFAULT_GOAL := help
PROJECT_ROOT:=$(shell git rev-parse --show-toplevel)
# Load env properties , db name, port, etc...
# nb: You can change the default config with `make ENV_CONTEXT=".env.uat" `
ENV_CONTEXT ?= .env.local
ENV_CONTEXT_PATH:=$(PROJECT_ROOT)/$(ENV_CONTEXT)
## Override any default values in the parent .env, with your own
-include $(ENV_CONTEXT_PATH)
COMMIT := $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
REPO := $(shell basename `git rev-parse --show-toplevel`)
DATE := $(shell date +%Y-%m-%d-%H-%M-%S)
APP_NAME := $(REPO)
GO_BUILD_FLAGS=-ldflags=""
BUILD_PATH ?= "cmd"
BINARY_PATH ?= "dist"
ci: log scan test ## Run CI checks
test: ## Run unit tests
go test --short -cover -failfast ./...
test-watch: ## Run unit tests in watch mode
gow test -v --short -cover -failfast ./...
scan: ## run security scan
govulncheck ./...
golangci-lint run ./...
tools-get: ## Get project tools required
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2
# HELP
# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
#####################
# Private Targets #
#####################
log: # log env vars
@echo "\n"
@echo "COMMIT $(COMMIT)"
@echo "BRANCH $(BRANCH)"
@echo "APP_NAME $(APP_NAME)"
@echo "REPO $(REPO)"
@echo "DATE $(DATE)"
@echo "ENVIRONMENT $(ENVIRONMENT)"
@echo "LOG_LEVEL $(LOG_LEVEL)"
@echo "\n"