forked from cnabio/cnab-go
/
Makefile
65 lines (54 loc) · 1.44 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
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
SHELL = cmd.exe
CHECK = where.exe
else
TARGET = $(PROJECT)
SHELL ?= bash
CHECK ?= which
endif
.PHONY: build
build:
go build ./...
.PHONY: test
test:
go test ./...
.PHONY: integration-test
integration-test:
go test -tags integration ./...
.PHONY: lint
lint:
golangci-lint run --config ./golangci.yml
HAS_DEP := $(shell $(CHECK) dep)
HAS_GOLANGCI := $(shell $(CHECK) golangci-lint)
HAS_GOIMPORTS := $(shell $(CHECK) goimports)
GOLANGCI_VERSION := v1.16.0
HAS_GOCOV_XML := $(shell command -v gocov-xml;)
HAS_GOCOV := $(shell command -v gocov;)
HAS_GO_JUNIT_REPORT := $(shell command -v go-junit-report;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_DEP
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
endif
ifndef HAS_GOLANGCI
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_VERSION)
endif
ifndef HAS_GOIMPORTS
go get -u golang.org/x/tools/cmd/goimports
endif
dep ensure -vendor-only -v
ifndef HAS_GOCOV_XML
go get github.com/AlekSi/gocov-xml
endif
ifndef HAS_GOCOV
go get -u github.com/axw/gocov/gocov
endif
ifndef HAS_GO_JUNIT_REPORT
go get github.com/jstemmer/go-junit-report
endif
.PHONY: coverage
coverage:
go test -v -coverprofile=coverage.txt -covermode count ./... 2>&1 | go-junit-report > report.xml
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml