-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (61 loc) · 2.15 KB
/
Makefile
File metadata and controls
83 lines (61 loc) · 2.15 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.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=""
#####################
##@ CI
#####################
ci: log scan test ## Run CI checks
scan: ## run security scan
govulncheck ./...
gosec ./...
golangci-lint run ./...
go vet ./...
#####################
##@ Dev
#####################
install: tools-get tools-dev ## Install project tools
test: ## Run unit tests
go test -v --short -cover -failfast ./...
test-watch: ## Run unit tests in watch mode
gow test -v --short -cover -failfast ./...
#####################
##@ Tools
#####################
tools-get: ## Get project tools required
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
tools-dev: ## get dev tools
go install github.com/mitranim/gow@latest
#####################
##@ Help
#####################
# 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_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(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"