forked from pingcap/failpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (59 loc) · 2.49 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
66
67
68
69
70
71
72
73
74
75
### Makefile for failpoint-ctl
LDFLAGS += -X "github.com/pingcap/failpoint/failpoint-ctl/version.releaseVersion=$(shell git describe --tags --dirty="-dev" --always)"
LDFLAGS += -X "github.com/pingcap/failpoint/failpoint-ctl/version.buildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/failpoint/failpoint-ctl/version.gitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/failpoint/failpoint-ctl/version.gitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "github.com/pingcap/failpoint/failpoint-ctl/version.goVersion=$(shell go version)"
FAILPOINT_CTL_BIN := bin/failpoint-ctl
path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH):$(shell pwd)/tools/bin
GO := GO111MODULE=on go
GOBUILD := GO111MODULE=on CGO_ENABLED=0 $(GO) build
GOTEST := GO111MODULE=on GO_FAILPOINTS="failpoint-env1=return(10);failpoint-env2=return(true)" GO_FAILPOINTS_HTTP=":23389" CGO_ENABLED=1 $(GO) test -p 4
OVERALLS := CGO_ENABLED=1 GO111MODULE=on GO_FAILPOINTS="failpoint-env1=return(10);failpoint-env2=return(true)" GO_FAILPOINTS_HTTP=":23389" overalls
ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
RACE_FLAG =
ifeq ("$(WITH_RACE)", "1")
RACE_FLAG = -race
GOBUILD = GOPATH=$(GOPATH) CGO_ENABLED=1 $(GO) build
endif
.PHONY: build checksuccess test cover upload-cover gotest check-static
default: build checksuccess
build:
$(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS)' -o $(FAILPOINT_CTL_BIN) failpoint-ctl/main.go
checksuccess:
@if [ -f $(FAILPOINT_CTL_BIN) ]; \
then \
echo "failpoint-ctl build successfully :-) !" ; \
fi
test: gotest check-static
check-static: tools/bin/gometalinter
@ # TODO: enable megacheck.
@ # TODO: gometalinter has been DEPRECATED.
@ # https://github.com/alecthomas/gometalinter/issues/590
@ echo "----------- static check ---------------"
tools/bin/gometalinter --disable-all --deadline 120s \
--enable gofmt \
--enable misspell \
--enable ineffassign \
./...
@ # TODO --enable errcheck
@ # TODO --enable golint
gotest:
@ echo "----------- go test ---------------"
$(GOTEST) -v ./...
cover:
$(GO) get github.com/go-playground/overalls
$(OVERALLS) -project=github.com/pingcap/failpoint \
-covermode=count \
-ignore='.git,vendor,LICENSES' \
-concurrency=4
upload-cover: SHELL:=/bin/bash
upload-cover:
mv overalls.coverprofile coverage.txt
bash <(curl -s https://codecov.io/bash)
tools/bin/gometalinter:
cd tools; \
curl -L https://git.io/vp6lP | sh