-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (88 loc) · 2.51 KB
/
Makefile
File metadata and controls
108 lines (88 loc) · 2.51 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
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
SHELL := /bin/bash
.DEFAULT_GOAL := help
# Variables
VERSION?=$(shell git describe --exact-match --tags 2> /dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Allow to pass args to targets
cmd := $(firstword $(MAKECMDGOALS))
args := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
%::
@ true
# (c) https://askubuntu.com/a/1448109
##@ Build targets
deps: ## Download dependencies
@ go mod tidy
.PHONY: deps
fmt: ## Format source code
@ go fmt ./...
.PHONY: fmt
vet: ## Examine source code
@ go vet ./...
.PHONY: vet
build: export CGO_ENABLED=0
build: export GOEXPERIMENT=greenteagc
build: ## Build the application
@ go build \
-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT)" \
-o vui \
./cmd/vui
.PHONY: build
##@ Test targets
test: ## Run tests, e.g. make test, make test TestCoalesce
@ go test -v $(if $(args), -run '$(args)') ./...
.PHONY: test
coverage: ## Run tests with coverage
@ go test -coverprofile=coverage.out ./...
@ go tool cover -html=coverage.out -o coverage.html
.PHONY: coverage
##@ Sandbox targets
sbx-build: ## Build sandbox init image(s)
@ $(MAKE) -C sandbox build
.PHONY: sbx-build
sbx-up: ## Create sandbox, e.g. make sbx-up, make sbx-up vault
@ $(MAKE) -C sandbox up $(args)
.PHONY: sbx-up
sbx-logs: ## Show logs for sandbox, e.g. make sbx-logs, make sbx-logs vault
@ $(MAKE) -C sandbox logs $(args)
.PHONY: sbx-logs
sbx-ps: ## Show sandbox services
@ $(MAKE) -C sandbox ps
.PHONY: sbx-ps
sbx-run: build
sbx-run: ## Run vui in sandbox
@ $(MAKE) -C sandbox env
@ echo "# Run the application"
@ eval $$(cat ./sandbox/.env) && ./vui
.PHONY: sbx-run
sbx-down: ## Destroy sandbox
@ $(MAKE) -C sandbox down
@ $(MAKE) -C sandbox clean
.PHONY: sbx-down
##@ Other targets
clean: ## Clean temporary files
@ go clean
@ rm -f ./vui
@ rm -f *.log
@ rm -f coverage.* ./*.test
@ rm -rf ./dist/
.PHONY: clean
help: ## Show help message
@awk 'BEGIN { \
FS = ":.*##"; \
printf "Usage:\n make \033[36m<target>\033[0m\n" \
} \
/^[a-zA-Z0-9_-]+:.*?##/ { \
desc = $$2; \
if (match(desc, / e\.g\. /)) { \
before = substr(desc, 1, RSTART - 1); \
after = substr(desc, RSTART); \
printf " \033[36m%-20s\033[0m %s\033[32m%s\033[0m\n", $$1, before, after \
} else { \
printf " \033[36m%-20s\033[0m %s\n", $$1, desc \
} \
} \
/^##@/ { \
printf "\n\033[1m%s\033[0m\n", substr($$0, 5) \
}' $(MAKEFILE_LIST)
.PHONY: help