github.com/jdolitsky/cnab-go@v0.7.1-beta1/Makefile (about) 1 ifeq ($(OS),Windows_NT) 2 TARGET = $(PROJECT).exe 3 SHELL = cmd.exe 4 CHECK = where.exe 5 else 6 TARGET = $(PROJECT) 7 SHELL ?= bash 8 CHECK ?= which 9 endif 10 11 .PHONY: build 12 build: 13 go build ./... 14 15 .PHONY: test 16 test: 17 go test ./... 18 19 .PHONY: integration-test 20 integration-test: 21 go test -tags integration ./... 22 23 .PHONY: lint 24 lint: 25 golangci-lint run --config ./golangci.yml 26 27 HAS_DEP := $(shell $(CHECK) dep) 28 HAS_GOLANGCI := $(shell $(CHECK) golangci-lint) 29 HAS_GOIMPORTS := $(shell $(CHECK) goimports) 30 GOLANGCI_VERSION := v1.16.0 31 32 HAS_GOCOV_XML := $(shell command -v gocov-xml;) 33 HAS_GOCOV := $(shell command -v gocov;) 34 HAS_GO_JUNIT_REPORT := $(shell command -v go-junit-report;) 35 36 37 .PHONY: bootstrap 38 bootstrap: 39 40 ifndef HAS_DEP 41 curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh 42 endif 43 ifndef HAS_GOLANGCI 44 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_VERSION) 45 endif 46 ifndef HAS_GOIMPORTS 47 go get -u golang.org/x/tools/cmd/goimports 48 endif 49 dep ensure -vendor-only -v 50 51 ifndef HAS_GOCOV_XML 52 go get github.com/AlekSi/gocov-xml 53 endif 54 ifndef HAS_GOCOV 55 go get -u github.com/axw/gocov/gocov 56 endif 57 ifndef HAS_GO_JUNIT_REPORT 58 go get github.com/jstemmer/go-junit-report 59 endif 60 61 .PHONY: coverage 62 coverage: 63 go test -v -coverprofile=coverage.txt -covermode count ./... 2>&1 | go-junit-report > report.xml 64 gocov convert coverage.txt > coverage.json 65 gocov-xml < coverage.json > coverage.xml 66 67 .PHONY: goimports 68 goimports: 69 find . -name "*.go" | fgrep -v vendor/ | xargs goimports -w -local github.com/$(ORG)/$(PROJECT)