From 2b802fee850b8cc4490b0685c6cac502a0af5ce2 Mon Sep 17 00:00:00 2001 From: ValClarkson Date: Thu, 5 Nov 2026 17:39:40 -0500 Subject: [PATCH] ci: pin golangci-lint and restore working exclusion rules golangci-lint v2.15.0 changed SA1019 wording so existing regexes matched nothing, and recvcheck started flagging Duration. Pin the linter and match both the old and new diagnostic text so PRs stop failing on a toolchain bump. Co-authored-by: Cursor --- .github/workflows/lint.yaml | 4 +++- .golangci.yaml | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fc7a3689b1..02ce03e04a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,7 +18,9 @@ jobs: - uses: golangci/golangci-lint-action@v9 with: - version: latest + # Pin so a golangci-lint / staticcheck release cannot change SA1019 + # wording and break exclusion regexes on every pull request. + version: v2.15.0 args: --timeout=5m # Count issues reported by disabled linters. The command always diff --git a/.golangci.yaml b/.golangci.yaml index fd241ae8c2..b66cd03d27 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -171,8 +171,17 @@ linters: path: internal/pki/pki.go text: methods of "(Certificate|PrivateKey)" + # json.Marshaler must stay on the value receiver so encoding/json uses it + # for non-addressable Duration values. Pointer UnmarshalJSON/AsDuration + # are required by json.Unmarshaler and the API. + - linters: [recvcheck] + path: pkg/apis/postgres-operator.crunchydata.com/.*/shared_types\.go + text: methods of "Duration" + + # Newer staticcheck names a deprecated symbol by import path; older + # versions used the alias in the offending file. Match either spelling. - linters: [staticcheck] - text: corev1.(Endpoints|EndpointSubset) is deprecated + text: (corev1|k8s\.io/api/core/v1)\.(Endpoints|EndpointSubset) is deprecated - linters: [staticcheck] path: internal/controller/ @@ -189,11 +198,11 @@ linters: text: >- client.Apply is deprecated - # k8s.io/apimachinery v0.36 deprecated direct access to managed.FieldsV1.Raw + # k8s.io/apimachinery v0.36 deprecated direct access to FieldsV1.Raw # in favor of GetRawBytes/SetRawBytes. Tests still use the old field. - linters: [staticcheck] path: internal/controller/postgrescluster/apply_test\.go - text: managed.FieldsV1.Raw is deprecated + text: (managed\.FieldsV1|\(k8s\.io/apimachinery/pkg/apis/meta/v1\.FieldsV1\))\.Raw is deprecated # controller-runtime v0.24 deprecated scheme.Builder, but the recommended # alternative requires restructuring our api packages. Allow current usage