-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
54 lines (46 loc) · 1.07 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
# Build variables
VERSION ?= $(shell git describe --tags --always)
# Go variables
GO ?= go
GOOS ?= $(shell $(GO) env GOOS)
GOARCH ?= $(shell $(GO) env GOARCH)
GOHOST ?= GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)
.PHONY: all
all: help
###############
##@ Development
.PHONY: test
test: ## Run tests
@ $(MAKE) --no-print-directory log-$@
$(GOHOST) test -timeout 60s -race -covermode atomic -coverprofile coverage.txt -v ./...
.PHONY: lint
lint: ## Run linters
@ $(MAKE) --no-print-directory log-$@
golangci-lint run
########
##@ Help
.PHONY: help
help: ## Display this help
@awk \
-v "col=\033[36m" -v "nocol=\033[0m" \
' \
BEGIN { \
FS = ":.*##" ; \
printf "Usage:\n make %s<target>%s\n", col, nocol \
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " %s%-12s%s %s\n", col, $$1, nocol, $$2 \
} \
/^##@/ { \
printf "\n%s%s%s\n", nocol, substr($$0, 5), nocol \
} \
' $(MAKEFILE_LIST)
log-%:
@grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | \
awk \
'BEGIN { \
FS = ":.*?## " \
}; \
{ \
printf "\033[36m==> %s\033[0m\n", $$2 \
}'