From 289a5fb862a31b70773f6b2d27294c75f64c058c Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 24 Mar 2020 11:57:22 +0100 Subject: [PATCH] Chore: Fix golangci-lint timeout config, disable govet (#23015) * golangci-lint: Fix timeout config; disable govet * CircleCI: Use official golangci-lint binary --- .circleci/config.yml | 27 ++++++++++++++++++--------- scripts/go/configs/.golangci.yml | 5 +---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ce569b8d49a..54c4545212f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -711,22 +711,31 @@ jobs: lint-go: docker: - image: circleci/golang:1.13.4 - environment: - # we need CGO because of go-sqlite3 - CGO_ENABLED: 1 - # Reduce golangci-lint memory usage (default is 100) - GOGC: 20 working_directory: /go/src/github.com/grafana/grafana + environment: + # we need CGO because of go-sqlite3 + CGO_ENABLED: 1 + # Reduce golangci-lint memory usage (default is 100) + GOGC: 20 steps: - checkout + - run: + name: Install Go linters + command: | + pushd /tmp + curl -fLO https://github.com/golangci/golangci-lint/releases/download/v1.24.0/golangci-lint-1.24.0-linux-amd64.tar.gz + echo 241ca454102e909de04957ff8a5754c757cefa255758b3e1fba8a4533d19d179 \ + golangci-lint-1.24.0-linux-amd64.tar.gz | sha256sum --check --strict --status + tar -xf golangci-lint-1.24.0-linux-amd64.tar.gz + sudo mv golangci-lint-1.24.0-linux-amd64/golangci-lint /usr/local/bin/ + popd + make scripts/go/bin/revive scripts/go/bin/gosec - run: name: Lint Go command: | - # Build linters - make scripts/go/bin/golangci-lint scripts/go/bin/revive scripts/go/bin/gosec go vet ./pkg/... - # Avoid golangci-lint concurrency since it tends to run out of memory - ./scripts/go/bin/golangci-lint run --config scripts/go/configs/.golangci.yml -j 1 ./pkg/... + # Adjust golangci-lint concurrency since it can run out of memory + golangci-lint run -v -j 2 --config scripts/go/configs/.golangci.yml ./pkg/... ./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/... ./scripts/go/bin/revive -formatter stylish ./pkg/services/alerting/... ./scripts/go/bin/gosec -quiet -exclude=G104,G107,G108,G201,G202,G204,G301,G304,G401,G402,G501 \ diff --git a/scripts/go/configs/.golangci.yml b/scripts/go/configs/.golangci.yml index 7289d25aae1..71db8fea38f 100644 --- a/scripts/go/configs/.golangci.yml +++ b/scripts/go/configs/.golangci.yml @@ -1,7 +1,5 @@ -enable: - run: - deadline: 10m + timeout: 10m linters: disable-all: true @@ -9,7 +7,6 @@ linters: - deadcode - gofmt - gosimple - - govet - ineffassign - structcheck - typecheck