forked from uber-go/tally
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (54 loc) · 1.75 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
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
PKGS ?= $(shell go list ./...)
PKG_FILES := $(shell find . -type f -name '*.go' |egrep -v '^./(thirdparty/|vendor/)')
LINT_IGNORE := (/m3/thrift/|/thirdparty/)
LICENSE_IGNORE := thirdparty
GO := GO111MODULE=on go
.PHONY: all
all: lint test
.PHONY: dependencies
dependencies:
@echo "Installing test dependencies..."
$(GO) get github.com/axw/gocov/gocov
$(GO) get github.com/mattn/goveralls
@echo "Installing golint..."
$(GO) get golang.org/x/lint/golint
.PHONY: lint
.SILENT: lint
lint:
rm -rf lint.log
echo "Checking formatting..."
gofmt -l -s $(PKG_FILES) 2>&1 | egrep -v '$(LINT_IGNORE)' | tee -a lint.log
echo "Checking lint..."
$(foreach dir,$(PKGS),golint $(dir) 2>&1 | egrep -v '$(LINT_IGNORE)' | tee -a lint.log;)
echo "Checking for unresolved FIXMEs..."
git grep -i fixme | grep -v -e vendor -e Makefile | egrep -v '$(LINT_IGNORE)' | tee -a lint.log
echo "Checking for license headers..."
./check_license.sh | grep -v '$(LICENSE_IGNORE)' | tee -a lint.log
if [ -s lint.log ]; then \
echo lint or fmt failed! errors: ;\
cat lint.log ;\
exit 1 ;\
fi
.PHONY: test
test:
$(GO) test -timeout 1m -race -v $(PKGS)
.PHONY: examples
.SILENT: examples
examples:
mkdir -p ./bin
$(GO) build -o ./bin/print_example ./example/
$(GO) build -o ./bin/m3_example ./m3/example/
$(GO) build -o ./bin/prometheus_example ./prometheus/example/
$(GO) build -o ./bin/statsd_example ./statsd/example/
.PHONY: cover
cover:
$(GO) test -timeout 1m -cover -coverprofile cover.out -race -v $(PKGS)
.PHONY: coveralls
coveralls:
goveralls -service=travis-ci || echo "Coveralls failed"
.PHONY: bench
.SILENT: bench
BENCH ?= .
bench:
$(foreach pkg,$(PKGS),go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) $(pkg);)