-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (62 loc) · 1.56 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
78
79
80
81
82
83
.PHONY: all
all: setup lint test
.PHONY: test
test: setup
go test
sources = $(shell find . -name '*.go' -not -path './vendor/*')
.PHONY: goimports
goimports: setup
goimports -w $(sources)
.PHONY: lint
lint: setup
gometalinter ./... --enable=goimports --enable=gosimple \
--enable=unparam --enable=unused --disable=gotype --vendor -t
.PHONY: check
check: setup
gometalinter ./... --disable-all --enable=vet --enable=vetshadow \
--enable=goimports --vendor -t
.PHONY: cover
cover: setup
mkdir -p coverage
gocov test ./... | gocov-html > coverage/index.html
open coverage/index.html
.PHONY: ci
ci: setup check test
.PHONY: install
install: setup
go install
.PHONY: build
build: setup
go build
BIN_DIR := $(GOPATH)/bin
GOIMPORTS := $(BIN_DIR)/goimports
GOMETALINTER := $(BIN_DIR)/gometalinter
DEP := $(BIN_DIR)/dep
GOCOV := $(BIN_DIR)/gocov
GOCOV_HTML := $(BIN_DIR)/gocov-html
$(GOIMPORTS):
go get -u golang.org/x/tools/cmd/goimports
$(GOMETALINTER):
go get -u github.com/alecthomas/gometalinter
gometalinter --install &> /dev/null
$(DEP):
go get -u github.com/golang/dep/cmd/dep
$(GOCOV):
go get -u github.com/axw/gocov/gocov
$(GOCOV_HTML):
go get -u gopkg.in/matm/v1/gocov-html
tools: $(GOIMPORTS) $(GOMETALINTER) $(DEP) $(GOCOV) $(GOCOV_HTML)
vendor: $(DEP)
dep ensure
setup: tools vendor
updatedeps:
dep ensure -update
BINARY := hived
VERSION ?= latest
.PHONY: linux
linux: setup
mkdir -p $(CURDIR)/release
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.version=$(VERSION)" \
-o release/$(BINARY)-$(VERSION)-linux-amd64
.PHONY: release
release: linux