Skip to content

Commit 9495083

Browse files
committed
Migrate golangci-lint to v2.9.0 for Go 1.26 CI support
- Bump go-version 1.22 -> 1.26 in golangci-lint.yml and build-test.yml, and golangci-lint-action pin + version to v2.9.0 (golangci-lint v1.58 can't lint a module with a go 1.26 directive). - Migrate .golangci.yml from the v1 to v2 config schema, preserving the original lint policy (gosimple+staticcheck -> staticcheck with SA*/S* checks only, gofmt/goimports -> formatters section). - Exclude a handful of revive rules (exported, package-comments, unexported-return, var-naming) that golangci-lint v2.9.0's newer bundled revive now enables by default but weren't part of this branch's original lint policy under v1.58, plus the standard redefines-builtin-id exclusions already used on the other streams.
1 parent 8d803ae commit 9495083

3 files changed

Lines changed: 66 additions & 20 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Go
1818
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # pin@5.0.0
1919
with:
20-
go-version: '1.22'
20+
go-version: '1.26'
2121
- name: Test source headers are present
2222
run: make test-source-headers
2323
- name: Run unit tests

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
- name: Setup Go
1616
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # pin@5.0.0
1717
with:
18-
go-version: "1.22"
18+
go-version: "1.26"
19+
check-latest: true
1920
- name: golangci-lint
20-
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 #pin@4.0.0
21+
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #pin@6.1.1
2122
with:
22-
version: v1.58
23+
version: v2.9.0

.golangci.yml

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,70 @@
1-
run:
2-
timeout: 10m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
enable:
75
- dupl
8-
- gofmt
9-
- goimports
10-
- gosimple
116
- govet
127
- ineffassign
138
- misspell
149
- nakedret
1510
- revive
16-
- unused
1711
- staticcheck
18-
19-
linters-settings:
20-
gofmt:
21-
simplify: true
22-
goimports:
23-
local-prefixes: helm.sh/helm/v3
24-
dupl:
25-
threshold: 400
12+
- unused
13+
settings:
14+
dupl:
15+
threshold: 400
16+
staticcheck:
17+
# v1 config here separately enabled `gosimple` (S* checks) and `staticcheck` (SA*
18+
# checks) only — no `stylecheck` (ST*) or quickfix (QF*) groups. v2 merges all of
19+
# these into one `staticcheck` linter, so pin `checks` to just S*/SA* to preserve
20+
# the original lint policy instead of picking up ST*/QF* findings on old code.
21+
checks:
22+
- "SA*"
23+
- "S*"
24+
exclusions:
25+
rules:
26+
# golangci-lint v2.9.0 bundles a newer revive with a broader default rule set than
27+
# this branch's original v1.58 setup, which now also enables `exported`,
28+
# `package-comments`, `unexported-return`, and additional `var-naming` checks
29+
# (see the identical migration on HELM-820/821). Not part of this CVE fix's scope —
30+
# exclude rather than retrofitting doc comments/API changes onto unrelated code.
31+
- linters:
32+
- revive
33+
text: '^exported:'
34+
- linters:
35+
- revive
36+
text: '^package-comments:'
37+
- linters:
38+
- revive
39+
text: '^unexported-return:'
40+
- linters:
41+
- revive
42+
text: '^var-naming:'
43+
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
44+
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
45+
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
46+
- linters:
47+
- revive
48+
text: 'redefines-builtin-id: redefinition of the built-in function append'
49+
- linters:
50+
- revive
51+
text: 'redefines-builtin-id: redefinition of the built-in function clear'
52+
- linters:
53+
- revive
54+
text: 'redefines-builtin-id: redefinition of the built-in function max'
55+
- linters:
56+
- revive
57+
text: 'redefines-builtin-id: redefinition of the built-in function min'
58+
- linters:
59+
- revive
60+
text: 'redefines-builtin-id: redefinition of the built-in function new'
61+
formatters:
62+
enable:
63+
- gofmt
64+
- goimports
65+
settings:
66+
gofmt:
67+
simplify: true
68+
goimports:
69+
local-prefixes:
70+
- helm.sh/helm/v3

0 commit comments

Comments
 (0)