-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (55 loc) · 2.3 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
.PHONY: all test test_v generate lint vet fmt coverage check check-fast prepare race
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
PKGSDIRS=$(shell find -L . -type f -name "*.go")
all: prepare
travis: info vet lint check test_v coverage
coverage:
@echo "$(OK_COLOR)Generate coverage$(NO_COLOR)"
@./scripts/cover_multi.sh
# Golangci-lint generates too many errors and some of them
# are plain wrong (code detected as unused while being used)
# prepare: generate fmt vet lint check test race
prepare: generate test race
test_v:
@echo "$(OK_COLOR)Test packages$(NO_COLOR)"
@go test -cover -v ./...
test:
@echo "$(OK_COLOR)Test packages$(NO_COLOR)"
@go test -cover ./...
# Lint throws a ton of errors. I tend to lint my code a lot though.
lint:
@echo "$(OK_COLOR)Run lint$(NO_COLOR)"
@test -z "$$(golint -min_confidence 0.3 ./... | tee /dev/stderr)"
check:
@echo "$(OK_COLOR)Run golangci-lint$(NO_COLOR)"
@golangci-lint run --no-config --exclude-use-default=true --max-same-issues=10 --disable=gosimple --disable=golint --enable=megacheck --enable=interfacer --enable=goconst --enable=misspell --enable=unparam --enable=goimports --disable=errcheck --disable=ineffassign --disable=gocyclo --disable=gas
# Vet throws a ton of errors
vet:
@echo "$(OK_COLOR)Run vet$(NO_COLOR)"
@go vet ./...
race:
# Don't run race in subdirectories or in gen/flags.
# There are data races which will always fail, related to cobra/pflag.
# Maybe we should take them into account. I don't know.
@echo "$(OK_COLOR)Test for races$(NO_COLOR)"
@go test -race .
fmt:
@echo "$(OK_COLOR)Formatting$(NO_COLOR)"
@echo $(PKGSDIRS) | xargs -I '{p}' -n1 goimports -w {p}
info:
depscheck -totalonly -tests .
golocc --no-vendor ./...
generate:
@echo "$(OK_COLOR)Go generate$(NO_COLOR)"
@go generate
# Tools don't install some stuff. Dependency checks are done with other workflows.
# tools:
# @echo "$(OK_COLOR)Install tools$(NO_COLOR)"
# go get -u github.com/warmans/golocc
# go get -u github.com/divan/depscheck
# GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
# cd ${GOPATH}/src/github.com/golangci/golangci-lint/cmd/golangci-lint \
# && go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'"