-
Notifications
You must be signed in to change notification settings - Fork 93
/
Makefile
52 lines (39 loc) · 1.2 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
ifdef GOBIN
PATH := $(GOBIN):$(PATH)
else
PATH := $(subst :,/bin:,$(GOPATH))/bin:$(PATH)
endif
GO := GO15VENDOREXPERIMENT=1 go
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
all: format build test
style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
test:
@echo ">> running tests"
@$(GO) test -v -cover=true -short $(pkgs)
format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
build:
@echo ">> building binaries"
@$(GO) build -v -o ./bin/cloudinsight-agent
run: build
./bin/cloudinsight-agent
generate-cover-data:
@echo ">> generating coverage profiles"
@echo "mode: count" > coverage-all.out
@$(foreach pkg,$(pkgs),\
go test -v -coverprofile=coverage.out -covermode=count $(pkg) || exit $$?;\
if [ -f coverage.out ]; then\
tail -n +2 coverage.out >> coverage-all.out;\
fi\
;)
test-cover-html: generate-cover-data
@$(GO) tool cover -html=coverage-all.out -o coverage.html
test-cover-func: generate-cover-data
@$(GO) tool cover -func=coverage-all.out
.PHONY: all style format build test vet run test-cover-html test-cover-func generate-cover-data