-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
77 lines (62 loc) · 1.89 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
PROJECT := github.com/cfhamlet/os-go-netloc-rule
BUILDTIME := $(shell date +'%Y-%m-%d %H:%M:%S')
GOPATH := $(shell go env GOPATH)
GOVERSION := $(shell go version)
GOIMPORTS := $(GOPATH)/bin/goimports
GOLINT := $(GOPATH)/bin/golangci-lint
PKG := ./...
TESTS := .
LDFLAGS :=
GOFLAGS :=
TESTFLAGS :=
SRC := $(shell find . -type f -name '*.go' -print)
GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_SHA := $(shell git rev-parse --short HEAD)
GIT_TAG := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_STATUS := $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint
test: test-unit
test: test-coverage
test: test-bench
.PHONY: test-lint
test-lint:$(GOLINT)
@echo
@echo "==> Running lint test <=="
GO111MODULE=on $(GOLINT) run
$(GOLINT):
@echo
@echo "==> Installing golangci-lint <=="
(cd /; curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.21.0)
.PHONY: format
format: $(GOIMPORTS)
@echo
@echo "==> Formatting <=="
GO111MODULE=on go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w
$(GOIMPORTS):
@echo
@echo "==> Installing goimports <=="
(cd /; GO111MODULE=on go get -u golang.org/x/tools/cmd/goimports)
.PHONY: test-unit
test-unit:
@echo
@echo "==> Running unit tests <=="
GO111MODULE=on go test -run $(TESTS) $(PKG) $(TESTFLAGS)
.PHONY: test-bench
test-bench:
@echo
@echo "==> Running benchmark tests <=="
GO111MODULE=on go test -bench $(TESTS) $(PKG)
.PHONY: test-coverage
test-coverage:
@echo
@echo "==> Running unit tests with coverage <=="
@ ./scripts/coverage.sh
.PHONY: info
info:
@echo "Version: ${VERSION}"
@echo "Go Version: ${GOVERSION}"
@echo "Git Tag: ${GIT_TAG}"
@echo "Git Commit: ${GIT_COMMIT}"
@echo "Git Status: ${GIT_STATUS}"