forked from cloudflare/pint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (40 loc) · 1.06 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
PINT_BIN := pint
PINT_GO_DIRS := cmd internal
PINT_SRC := $(shell find $(PINT_GO_DIRS) -type f -name '*.go')
GOBIN := $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
COVER_DIR = .cover
COVER_PROFILE = $(COVER_DIR)/coverage.out
.PHONY: build
build: $(PINT_BIN)
$(PINT_BIN): $(PINT_SRC) go.mod go.sum
go build ./cmd/pint
$(GOBIN)/golangci-lint: tools/golangci-lint/go.mod tools/golangci-lint/go.sum
go install -modfile=tools/golangci-lint/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint
.PHONY: lint
lint: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run -E golint,staticcheck,misspell
.PHONY: test
test:
mkdir -p $(COVER_DIR)
echo 'mode: atomic' > $(COVER_PROFILE)
go test \
-covermode=atomic \
-coverprofile=$(COVER_PROFILE) \
-coverpkg=./... \
-race \
-count=5 \
-timeout=5m \
./...
.PHONY: cover
cover: test
go tool cover -func=$(COVER_PROFILE)
.PHONY: coverhtml
coverhtml: test
ifndef CI
go tool cover -html=$(COVER_PROFILE)
else
go tool cover -html=$(COVER_PROFILE) -o=.cover/all.html
endif