-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (32 loc) · 995 Bytes
/
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
PROJECT=github.com/openprovider/crypto
RELEASE?=v0.3.0
all: test lint
GO_PACKAGES=$(shell go list $(PROJECT)/...)
test:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -v -race -cover {{.Dir}}"{{end}}' $(GO_PACKAGES) | xargs -L 1 sh -c
bench:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -benchmem -bench . {{.Dir}}"{{end}}' $(GO_PACKAGES) | xargs -L 1 sh -c
fmt:
@echo "+ $@"
@go list -f '"gofmt -w -s -l {{.Dir}}"' ${GO_PACKAGES} | xargs -L 1 sh -c
lint: bootstrap
@echo "+ $@"
@golangci-lint run --enable-all ./...
cover:
@echo "+ $@"
@> coverage.txt
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}} && cat {{.Dir}}/.coverprofile >> coverage.txt"{{end}}' $(GO_PACKAGES) | xargs -L 1 sh -c
HAS_LINT := $(shell command -v golangci-lint;)
bootstrap:
ifndef HAS_LINT
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
endif
.PHONY: all \
test \
bench \
fmt \
lint \
cover \
bootstrap