-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (60 loc) · 2.08 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
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
export GOX=$(GOBIN)/gox
# 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:
@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:
@$(LINTER) $(LINTERCMD) --deadline 10m --new-from-rev=HEAD~ ./...
test:
@$(GO) test -v -race ./...
# Check if golangci-lint not exists, then install it
install-metalinter:
@$(GO) get -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.41.1
install-gox:
@$(GO) get -v github.com/mitchellh/gox@v1.0.1
build-linux: install-gox
@$(GOX) --arch=amd64 --os=linux --output="dist/fortress_{{.OS}}_{{.Arch}}"
build-windows: install-gox
@$(GOX) --arch=amd64 --os=windows --output="dist/fortress_{{.OS}}_{{.Arch}}"
build-macOS: install-gox
@$(GOX) --arch=amd64 --os=darwin --output="dist/fortress_{{.OS}}_{{.Arch}}"
build-artifacts:
@$(MAKE) build-linux && $(MAKE) build-windows && $(MAKE) build-macOS