forked from gojek/kafqa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (64 loc) · 2.18 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
76
77
78
79
80
81
82
83
84
85
86
87
all: clean check-quality build testv golangci
ALL_PACKAGES=$(shell go list ./...)
SOURCE_DIRS=$(shell go list ./... | cut -d "/" -f4 | uniq)
clean:
rm -rf ./out
GO111MODULE=on go mod tidy -v
setup:
GO111MODULE=off go get -v golang.org/x/tools/cmd/goimports
GO111MODULE=off go get -v golang.org/x/lint/golint
setup_godog:
go get -v github.com/DATA-DOG/godog/cmd/godog
check-quality: setup lint fmt imports vet
build-linux:
GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o out/agent-lx ./cmd/agent
build-local:
@echo "Building './out/kafqa' './out/agent'..."
@mkdir -p ./out
@go build -o out/kafqa ./cmd/kafqa
@go build -o out/agent ./cmd/agent
build: build-linux build-local
testv:
GOMAXPROCS=1 go test -race -v ./...
test:
go test -race ./...
testcodecov:
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
fmt:
gofmt -l -s -w $(SOURCE_DIRS)
imports:
./scripts/lint.sh check_imports
fix_imports:
goimports -l -w .
golangci:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b bin/ v1.30.0
bin/golangci-lint run -v --deadline 5m0s
cyclo:
gocyclo -over 6 $(SOURCE_DIRS)
vet:
go vet ./...
test-coverage:
mkdir -p ./out
@echo "mode: count" > coverage-all.out
$(foreach pkg, $(ALL_PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
GO111MODULE=on go tool cover -html=coverage-all.out -o ./out/coverage.html
@echo "---"
cat ./out/coverage.html | grep "<option" | cut -d ">" -f2 | cut -d "<" -f1 | grep -v "mock" | grep -v "config" | grep -v "stub"
docker-rebuild:
docker-compose up -d --build
docker-force-rebuild:
docker-compose up -d --build --no-cache
docker-services-restart:
docker-compose stop kafka
docker-compose restart zookeeper
docker-compose start kafka
docker-compose restart statsd
run: build
./out/kafqa
lint:
@if [[ `golint $(ALL_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } | wc -l | tr -d ' '` -ne 0 ]]; then \
golint $(ALL_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; }; \
exit 2; \
fi;