From 0c6393b3f41479336b766b3a49becc4743c7d0e1 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Thu, 7 Dec 2023 17:42:42 +0100 Subject: [PATCH] Update golanci-lint (#3632) Update golangci-lint from upstream Prometheus and fixup issues. Signed-off-by: SuperQ --- .github/workflows/golangci-lint.yml | 17 +++++++++++------ .golangci.yml | 16 +++++++++------- Makefile.common | 4 ++-- cmd/alertmanager/main.go | 4 ++-- ui/react-app/embed.go | 2 +- ui/react-app/embed.go.tmpl | 2 +- ui/react-app/ui.go | 2 +- ui/react-app/web.go | 2 +- 8 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index ee1e0ca3..ffa6b309 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,6 +1,8 @@ +--- +# This action is synced from https://github.com/prometheus/prometheus name: golangci-lint on: - pull_request: + push: paths: - "go.sum" - "go.mod" @@ -8,6 +10,7 @@ on: - "scripts/errcheck_excludes.txt" - ".github/workflows/golangci-lint.yml" - ".golangci.yml" + pull_request: jobs: golangci: @@ -15,13 +18,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 with: go-version: 1.21.x - - run: make build + - name: Install snmp_exporter/generator dependencies + run: sudo apt-get update && sudo apt-get -y install libsnmp-dev + if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@v3.4.0 + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: - version: v1.51.2 + version: v1.54.2 diff --git a/.golangci.yml b/.golangci.yml index 3ced4d92..5df6c359 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,12 +23,15 @@ issues: linters-settings: depguard: - list-type: blacklist - include-go-root: true - packages-with-error-message: - - sync/atomic: "Use go.uber.org/atomic instead of sync/atomic" - - github.com/stretchr/testify/assert: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert" - - github.com/go-kit/kit/log: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" + rules: + main: + deny: + - pkg: sync/atomic + desc: "Use go.uber.org/atomic instead of sync/atomic" + - pkg: github.com/stretchr/testify/assert + desc: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert" + - pkg: github.com/go-kit/kit/log + desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" errcheck: exclude-functions: # Don't flag lines such as "io.Copy(io.Discard, resp.Body)". @@ -52,7 +55,6 @@ linters-settings: arguments: ["disableStutteringCheck"] - name: blank-imports - name: context-as-argument - - name: dot-imports - name: error-return - name: error-strings - name: error-naming diff --git a/Makefile.common b/Makefile.common index e372d347..bc2a07d7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -55,13 +55,13 @@ ifneq ($(shell command -v gotestsum > /dev/null),) endif endif -PROMU_VERSION ?= 0.14.0 +PROMU_VERSION ?= 0.15.0 PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.51.2 +GOLANGCI_LINT_VERSION ?= v1.55.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 8c0df7a5..231e11dd 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -58,7 +58,7 @@ import ( "github.com/prometheus/alertmanager/timeinterval" "github.com/prometheus/alertmanager/types" "github.com/prometheus/alertmanager/ui" - reactApp "github.com/prometheus/alertmanager/ui/react-app" + reactapp "github.com/prometheus/alertmanager/ui/react-app" ) var ( @@ -500,7 +500,7 @@ func run() int { webReload := make(chan chan error) ui.Register(router, webReload, logger) - reactApp.Register(router, logger) + reactapp.Register(router, logger) mux := api.Register(router, *routePrefix) diff --git a/ui/react-app/embed.go b/ui/react-app/embed.go index abe4d857..afefcf38 100644 --- a/ui/react-app/embed.go +++ b/ui/react-app/embed.go @@ -13,7 +13,7 @@ // DO NOT EDIT: This file was autogenerated by `scripts/compress_assets.sh`. -package reactApp +package reactapp import "embed" diff --git a/ui/react-app/embed.go.tmpl b/ui/react-app/embed.go.tmpl index 8250a8ee..f7b686b9 100644 --- a/ui/react-app/embed.go.tmpl +++ b/ui/react-app/embed.go.tmpl @@ -13,7 +13,7 @@ // DO NOT EDIT: This file was autogenerated by `scripts/compress_assets.sh`. -package reactApp +package reactapp import "embed" diff --git a/ui/react-app/ui.go b/ui/react-app/ui.go index 133d0217..2e55a584 100644 --- a/ui/react-app/ui.go +++ b/ui/react-app/ui.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package reactApp +package reactapp import ( "net/http" diff --git a/ui/react-app/web.go b/ui/react-app/web.go index ee414af9..a0964260 100644 --- a/ui/react-app/web.go +++ b/ui/react-app/web.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package reactApp +package reactapp import ( "fmt"