-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (53 loc) · 1.66 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
export ROOT=$(realpath $(dir $(firstword $(MAKEFILE_LIST))))
export BIN=$(ROOT)/bin
export GOBIN?=$(BIN)
export GO=$(shell which go)
export BUILD=cd $(ROOT) && $(GO) install -v -ldflags "-s"
export CGO_ENABLED=1
# Linter configurations
export LINTER=$(GOBIN)/golangci-lint
export LINTERCMD=run --no-config -v \
--print-linter-name \
--skip-files ".*.gen.go" \
--skip-files ".*_test.go" \
--sort-results \
--disable-all \
--enable=structcheck \
--enable=deadcode \
--enable=gocyclo \
--enable=ineffassign \
--enable=revive \
--enable=goimports \
--enable=errcheck \
--enable=varcheck \
--enable=goconst \
--enable=megacheck \
--enable=misspell \
--enable=unused \
--enable=typecheck \
--enable=staticcheck \
--enable=govet \
--enable=gosimple
all:
$(BUILD) ./...
# lint runs vet plus a number of other checkers, it is more comprehensive, but louder
lint:
$(GO) get ./...
@LINTER_BIN=$$(command -v $(LINTER)) || { echo "golangci-lint command not found! Installing..." && $(MAKE) install-metalinter; };
@$(GO) list -f '{{.Dir}}' ./... | grep -v /vendor/ \
| xargs $(LINTER) $(LINTERCMD) ./...; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Lint found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for reviewal."; \
fi
# for ci jobs, runs lint against the changed packages in the commit
ci-lint:
$(GO) get ./...
$(LINTER) $(LINTERCMD) --deadline 10m --new-from-rev=HEAD~ ./...
# Check if golangci-lint not exists, then install it
install-metalinter:
$(GO) get -v github.com/golangci/golangci-lint/cmd/[email protected]
server:
$(GO) run server.go
test:
$(GO) test ./tests -v -race