-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (38 loc) · 1.49 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
# Project information
VERSION? := $(shell git describe --tags)
BUILD := $(shell git rev-parse --short HEAD)
# Go build variables
GOBASE := $(shell pwd)
GOPATH := $(GOBASE)/vendor:$(GOBASE)
GOBIN := $(GOBASE)/bin
CMD := $(GOBASE)/cmd
# Linker flags
LDFLAGS=-v -ldflags "-w -s -X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
.PHONY: all build clean lint
all: build
dep: clean ## Confirm vendor directory with dependencies
@printf "\033[36m%-30s\033[0m\n" "Confirm dependencies"
@-go mod vendor
lint: ## Lint the files
@printf "\033[36m%-30s\033[0m\n" "Lint source code"
@golint internal/...
@golint cmd/...
build: dep test ## Build the binary files
@printf "\033[36m%-30s\033[0m\n" "Build binaries"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build $(LDFLAGS) -o $(GOBIN)/checker $(CMD)/checker
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build $(LDFLAGS) -o $(GOBIN)/cli $(CMD)/cli
test: ## Test the library
@printf "\033[36m%-30s\033[0m\n" "Perform covered tests"
@go test -race -timeout 10000ms
@go test ./... -coverprofile artifacts/cover.out
@go tool cover -html=artifacts/cover.out -o artifacts/cover.html
@go tool cover -func=artifacts/cover.out
clean: ## Remove previous build
@printf "\033[36m%-30s\033[0m\n" "Clean"
@-chmod -R 777 ./vendor
@-rm -rf ./bin
@-rm -rf ./vendor
@GO111MODULE=off go clean
@GO111MODULE=off go clean -modcache
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'