forked from gojek/kat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (45 loc) · 1.51 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
all: clean check-quality golangci test build
APP=kat
ALL_PACKAGES=$(shell go list ./...)
SOURCE_DIRS=$(shell go list ./... | cut -d "/" -f4 | uniq)
clean:
rm -f ./kat
GO111MODULE=on go mod tidy -v
setup:
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/lint/golint
go get -u github.com/fzipp/gocyclo
test:
go test ./...
testcodecov:
go test -coverprofile=coverage.txt -covermode=atomic ./...
build:
@echo "Building './kat'..."
go mod download
go build -o kat
check-quality: lint fmt imports vet
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;
fmt:
gofmt -l -s -w $(SOURCE_DIRS)
imports:
./scripts/lint.sh check_imports
fix_imports:
goimports -l -w .
vet:
go vet ./...
golangci:
GO111MODULE=off go get -v github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run -v --deadline 5m0s
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"