@@ -36,6 +36,14 @@ INSTALL_GOLANGCI_LINT := $(findstring $(GOLANGCI_LINT_VERSION), $(GOLANGCI_LINT_
36
36
MOCKERY_VERSION := 2.32.4
37
37
MOCKERY_OUTPUT := $(shell $(INSTALL_PATH ) /mockery --version 2>/dev/null)
38
38
INSTALL_MOCKERY := $(findstring $(MOCKERY_VERSION ) ,$(MOCKERY_OUTPUT ) )
39
+ # gci
40
+ GCI_VERSION := 0.11.2
41
+ GCI_OUTPUT := $(shell $(INSTALL_PATH ) /gci --version 2>/dev/null)
42
+ INSTALL_GCI := $(findstring $(GCI_VERSION ) ,$(GCI_OUTPUT ) )
43
+ # gofumpt
44
+ GOFUMPT_VERSION := 0.5.0
45
+ GOFUMPT_OUTPUT := $(shell $(INSTALL_PATH ) /gofumpt --version 2>/dev/null)
46
+ INSTALL_GOFUMPT := $(findstring $(GOFUMPT_VERSION ) ,$(GOFUMPT_OUTPUT ) )
39
47
40
48
export GIT_BRANCH =master
41
49
@@ -97,18 +105,32 @@ else
97
105
@GO111MODULE=on env bash $(PWD)/scripts/gofmt.sh pkg/
98
106
endif
99
107
100
- lint : tools/bin/revive
101
- @echo " Running $@ check"
102
- @tools/bin/revive -formatter friendly -config tools/check/revive.toml ./...
108
+ lint-fix : getdeps
109
+ @mkdir -p $(INSTALL_PATH )
110
+ @if [ -z " $( INSTALL_GCI) " ]; then \
111
+ echo " Installing gci v$( GCI_VERSION) to ./bin/" && GOBIN=$(INSTALL_PATH ) go install github.com/daixiang0/gci@v$(GCI_VERSION ) ; \
112
+ else \
113
+ echo " gci v$( GCI_VERSION) already installed" ; \
114
+ fi
115
+ @if [ -z " $( INSTALL_GOFUMPT) " ]; then \
116
+ echo " Installing gofumpt v$( GOFUMPT_VERSION) to ./bin/" && GOBIN=$(INSTALL_PATH ) go install mvdan.cc/gofumpt@v$(GOFUMPT_VERSION ) ; \
117
+ else \
118
+ echo " gofumpt v$( GOFUMPT_VERSION) already installed" ; \
119
+ fi
120
+ @echo " Running gofumpt fix"
121
+ @$(INSTALL_PATH ) /gofumpt -l -w .
122
+ @echo " Running gci fix"
123
+ @$(INSTALL_PATH ) /gci write cmd/ --skip-generated -s standard -s default -s " prefix(github.com/milvus-io)" --custom-order
124
+ @$(INSTALL_PATH ) /gci write internal/ --skip-generated -s standard -s default -s " prefix(github.com/milvus-io)" --custom-order
125
+ @$(INSTALL_PATH ) /gci write pkg/ --skip-generated -s standard -s default -s " prefix(github.com/milvus-io)" --custom-order
126
+ @$(INSTALL_PATH ) /gci write tests/ --skip-generated -s standard -s default -s " prefix(github.com/milvus-io)" --custom-order
127
+ @echo " Running golangci-lint auto-fix"
128
+ @source $(PWD ) /scripts/setenv.sh && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --fix --timeout=30m --config $(PWD ) /.golangci.yml; cd pkg && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --fix --timeout=30m --config $(PWD ) /.golangci.yml
103
129
104
130
# TODO: Check code specifications by golangci-lint
105
131
static-check : getdeps
106
132
@echo " Running $@ check"
107
- @GO111MODULE=on $(INSTALL_PATH ) /golangci-lint cache clean
108
- @source $(PWD ) /scripts/setenv.sh && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config ./.golangci.yml ./internal/...
109
- @source $(PWD ) /scripts/setenv.sh && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config ./.golangci.yml ./cmd/...
110
- @source $(PWD ) /scripts/setenv.sh && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config ./.golangci.yml ./tests/integration/...
111
- @source $(PWD ) /scripts/setenv.sh && cd pkg && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config ../.golangci.yml ./...
133
+ @source $(PWD ) /scripts/setenv.sh && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config $(PWD ) /.golangci.yml; cd pkg && GO111MODULE=on $(INSTALL_PATH ) /golangci-lint run --timeout=30m --config $(PWD ) /.golangci.yml
112
134
113
135
verifiers : build-cpp getdeps cppcheck fmt static-check
114
136
0 commit comments