forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (38 loc) · 1.02 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
VENDOR := vendor
PKGS := $(shell go list ./... | grep -v /$(VENDOR)/)
SRC = $(shell find . -type f -name '*.go' -not -path "*/$(VENDOR)/*")
BIN_DIR := $(GOPATH)/bin
DEP := $(BIN_DIR)/dep
GOMETALINTER := $(BIN_DIR)/gometalinter
.PHONY: test
test: dep fmtcheck vet
go test $(PKGS)
$(DEP):
go get -u github.com/golang/dep/cmd/dep
.PHONY: dep
dep: $(DEP)
$(DEP) ensure
$(GOMETALINTER):
go get -u github.com/alecthomas/gometalinter
$(GOMETALINTER) --install &> /dev/null
.PHONY: lint
lint: $(GOMETALINTER)
$(GOMETALINTER) ./... --vendor
.PHONY: fmt
fmt:
@echo "Running gofmt on all sources..."
@gofmt -s -l -w $(SRC)
.PHONY: fmtcheck
fmtcheck:
@bash -c "diff -u <(echo -n) <(gofmt -d $(SRC))"
.PHONY: vet
vet:
go vet $(PKGS)
.PHONY: cover
cover:
$(shell [ -e coverage.out ] && rm coverage.out)
@echo "mode: count" > coverage-all.out
$(foreach pkg,$(PKGS),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o=coverage-all.html