-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
49 lines (36 loc) · 1.24 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
LDFLAGS =
# project info
PACKAGE := $(shell go list)
PACKAGES := $(shell go list ./...)
BINARY_NAME := $(shell basename $(PACKAGE))
# commit info
TAG := $(shell git describe --tags --abbrev=0)
# embed version info into binary
LDFLAGS += -X main.Tag=$(TAG)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: help tidy dep vet test build clean
default: help
all: test build
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "${YELLOW}%-16s${GREEN}%s${RESET}\n", $$1, $$2}' $(MAKEFILE_LIST)
tidy: ## Tidy up the go modules
@go mod tidy
dep: tidy ## Install dependencies
@go mod download
vet: dep ## Run go vet
@go vet ./...
quicktest: dep ## Run quicktest, without race detector
@go test -v ./... -short 2>&1 | tee test.log
@echo "Written logs in quicktest.log"
test: dep ## Run test
@go test -cpu=2 -race -v ./... -short 2>&1 | tee test.log
@echo "Written logs in test.log"
build: dep ## Build the binary file
@go build -o $(BINARY_NAME) -ldflags '-s -w $(LDFLAGS)'
clean: ## Remove previous build
@go clean ./...
@rm -f quicktest.log test.log $(BINARY_NAME)