mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
Optimize linting (#2479)
This commit is contained in:
parent
d06df7438f
commit
213ba364d7
7 changed files with 34 additions and 20 deletions
|
|
@ -168,11 +168,6 @@ jobs:
|
|||
- run:
|
||||
name: Generate code
|
||||
command: make codegen
|
||||
- run:
|
||||
name: Lint code
|
||||
# use GOGC to limit memory usage in exchange for CPU usage, https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
|
||||
# we have 8GB RAM, 2CPUs https://circleci.com/docs/2.0/executor-types/#using-machine
|
||||
command: LINT_GOGC=20 LINT_CONCURRENCY=1 LINT_DEADLINE=4m0s make lint
|
||||
- run:
|
||||
name: Check nothing has changed
|
||||
command: |
|
||||
|
|
|
|||
|
|
@ -3,14 +3,20 @@ run:
|
|||
skip-files:
|
||||
- ".*\\.pb\\.go"
|
||||
skip-dirs:
|
||||
- pkg/client
|
||||
- vendor
|
||||
- pkg/client/
|
||||
- vendor/
|
||||
linters:
|
||||
enable:
|
||||
- vet
|
||||
- deadcode
|
||||
- goimports
|
||||
- varcheck
|
||||
- structcheck
|
||||
- ineffassign
|
||||
- unconvert
|
||||
- unparam
|
||||
linters-settings:
|
||||
goimports:
|
||||
local-prefixes: github.com/argoproj/argo-cd
|
||||
service:
|
||||
golangci-lint-version: 1.18.0
|
||||
|
|
|
|||
18
Makefile
18
Makefile
|
|
@ -23,11 +23,6 @@ IMAGE_TAG?=
|
|||
STATIC_BUILD?=true
|
||||
# build development images
|
||||
DEV_IMAGE?=false
|
||||
# lint is memory and CPU intensive, so we can limit on CI to mitigate OOM
|
||||
LINT_GOGC?=off
|
||||
LINT_CONCURRENCY?=8
|
||||
# Set timeout for linter
|
||||
LINT_DEADLINE?=1m0s
|
||||
|
||||
override LDFLAGS += \
|
||||
-X ${PACKAGE}.version=${VERSION} \
|
||||
|
|
@ -159,15 +154,14 @@ dep:
|
|||
dep-ensure:
|
||||
dep ensure -no-vendor
|
||||
|
||||
.PHONY: lint-local
|
||||
lint-local: build
|
||||
# golangci-lint does not do a good job of formatting imports
|
||||
goimports -local github.com/argoproj/argo-cd -w `find . ! -path './vendor/*' ! -path './pkg/client/*' ! -path '*.pb.go' ! -path '*.gw.go' -type f -name '*.go'`
|
||||
GOGC=$(LINT_GOGC) golangci-lint run --fix --verbose --concurrency $(LINT_CONCURRENCY) --deadline $(LINT_DEADLINE)
|
||||
.PHONY: install-lint-tools
|
||||
install-lint-tools:
|
||||
./hack/install.sh lint-tools
|
||||
|
||||
.PHONY: lint
|
||||
lint: dev-tools-image
|
||||
$(call run-in-dev-tool,make lint-local LINT_CONCURRENCY=$(LINT_CONCURRENCY) LINT_DEADLINE=$(LINT_DEADLINE) LINT_GOGC=$(LINT_GOGC))
|
||||
lint:
|
||||
golangci-lint --version
|
||||
golangci-lint run --fix --verbose
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ Ensure dependencies are up to date first:
|
|||
|
||||
```shell
|
||||
dep ensure
|
||||
make install-lint-tools
|
||||
```
|
||||
|
||||
Build `cli`, `image`, and `argocd-util` as default targets by running make:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ RUN GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0
|
|||
GO111MODULE=on go get github.com/gogo/protobuf/gogoproto@v1.2.1 && \
|
||||
GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.2 && \
|
||||
GO111MODULE=on go get github.com/golang/protobuf/protoc-gen-go@v1.3.1 && \
|
||||
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1 && \
|
||||
GO111MODULE=on go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.9.2 && \
|
||||
GO111MODULE=on go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.9.2 && \
|
||||
GO111MODULE=on go get github.com/jstemmer/go-junit-report@v0.0.0-20190106144839-af01ea7f8024 && \
|
||||
|
|
|
|||
11
hack/install.sh
Executable file
11
hack/install.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
set -eux -o pipefail
|
||||
|
||||
export DOWNLOADS=/tmp/dl
|
||||
export BIN=${BIN:-/usr/local/bin}
|
||||
|
||||
mkdir -p $DOWNLOADS
|
||||
|
||||
for product in $*; do
|
||||
"$(dirname $0)/installers/install-${product}.sh"
|
||||
done
|
||||
8
hack/installers/install-lint-tools.sh
Executable file
8
hack/installers/install-lint-tools.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
set -eux -o pipefail
|
||||
|
||||
mkdir -p $DOWNLOADS/lint-tools
|
||||
cd $DOWNLOADS/lint-tools
|
||||
|
||||
# later versions seem to need go1.13
|
||||
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0
|
||||
Loading…
Reference in a new issue