ci: upgrade golangci-lint from v1.64 to v2.3.0#258
Merged
Conversation
The golangci-lint-action@v9 requires golangci-lint v2+, but the CI was pinned to v1.64 causing all lint jobs to fail with: 'invalid version string v1.64, golangci-lint v1 is not supported by golangci-lint-action >= v7' Changes: - Migrate .golangci.yml from v1 to v2 config format (version: 2, linters.default, linters.settings, formatters.enable, linters.exclusions.rules) - Update CI workflow version from v1.64 to v2.3.0 - Update go.mod tool dependency to golangci-lint/v2 - Consolidate gosimple+stylecheck into staticcheck (v2 default) - Move goimports from linters.enable to formatters.enable
The go.mod tool directive still pointed to v1 path (github.com/golangci/golangci-lint/cmd/golangci-lint) instead of v2 (github.com/golangci/golangci-lint/v2/cmd/golangci-lint), causing the pre-commit golangci-lint workflow to compile v1.64.8 against Go 1.26 and fail. Also update .pre-commit-config.yaml from v1.64.5 to v2.12.2.
Disable noctx, perfsprint, revive temporarily and add path-based exclusions for pre-existing lint issues in the codebase. These will be fixed incrementally in follow-up PRs. - Disable noctx (exec.Command without context — CLI tool, not critical) - Disable perfsprint (string concat in loops — style preference) - Disable revive (missing doc comments — 22 pre-existing) - Disable staticcheck QF quickfix checks (style suggestions) - Disable gocritic deprecatedComment - Add path exclusions for pre-existing errcheck, gosec, goconst issues
Fix 65+ lint errors across 20+ files instead of disabling linters:
errcheck: wrap unchecked Close/Remove in defer func() { _ = ... }()
- internal/upgrade/github.go, upgrade.go, zip.go
- pkg/env/configuration.go, setup/migrations.go
- utils/librarypath/librarypath.go
noctx: replace exec.Command with exec.CommandContext(context.Background(), ...)
- internal/adapters/secondary/git/git_native.go (7 calls)
- internal/core/services/compiler/executor.go
- utils/dcc32/dcc32.go
- utils/librarypath/librarypath.go
- internal/core/services/scripts/runner.go
goconst: extract repeated string literals as constants
- config.go: cmdNameConfig
- git.go: gitModeNative
- root.go: appName, appDescription
revive: add doc comments to all exported symbols
- git.go, git_embedded.go, git_native.go (8 functions)
- progress.go (2 const blocks, all values)
- error_filesystem.go (12 methods)
- consts.go (package comment)
- msg.go (log level constants)
staticcheck QF: apply quickfixes
- QF1006: lift conditions into for loop (graph.go, compiler.go)
- QF1012: use fmt.Fprintf instead of WriteString(Sprintf) (executor.go)
perfsprint: replace string concat in loops with strings.Builder
- graph.go, compiler.go, executor.go, setup/paths.go, dcp/dcp.go
gocritic: fix deprecatedComment format (blank line before Deprecated:)
- ports/git.go, installer/core.go, installer/vsc.go (2)
gosec: add #nosec G122 to hash.go (controlled directory walk)
SA1019: suppress deprecated API usage with TODO for migration
- dependencies.go, dependency_manager.go
whitespace: remove unnecessary leading newline in graph.go
Verified: golangci-lint v2.12.2 reports 0 issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All open PRs have failing
LintCI jobs becausegolangci-lint-action@v9is incompatible withgolangci-lint v1.64:This is a pre-existing infrastructure issue on
mainthat blocks all PRs.Fix
.golangci.yml: Migrated from v1 to v2 config formatversion: "2"headerlinters-settings→linters.settingslinters.disable-all: true→linters.default: nonegoimportsmoved fromlinters.enable→formatters.enablegosimple+stylecheckconsolidated intostaticcheck(v2 default)issues.exclude-rules→linters.exclusions.rules.github/workflows/ci.yml:version: v1.64→version: v2.3.0go.mod: Updated tool dependency togolangci/golangci-lint/v2Verification
go build ./...✅go test ./...— 417 passed in 34 packages ✅go vet ./...✅Impact
Once merged, the
Lintjob in CI will pass for all open PRs (after rebase). TheSecurity Scan(gosec) failures are separate and pre-existing.