Skip to content

ci: upgrade golangci-lint from v1.64 to v2.3.0#258

Merged
snakeice merged 5 commits into
mainfrom
ci/upgrade-golangci-lint-v2
Jul 16, 2026
Merged

ci: upgrade golangci-lint from v1.64 to v2.3.0#258
snakeice merged 5 commits into
mainfrom
ci/upgrade-golangci-lint-v2

Conversation

@snakeice

Copy link
Copy Markdown
Member

Problem

All open PRs have failing Lint CI jobs because golangci-lint-action@v9 is incompatible with golangci-lint v1.64:

invalid version string 'v1.64', golangci-lint v1 is not supported by golangci-lint-action >= v7

This is a pre-existing infrastructure issue on main that blocks all PRs.

Fix

  • .golangci.yml: Migrated from v1 to v2 config format
    • version: "2" header
    • linters-settingslinters.settings
    • linters.disable-all: truelinters.default: none
    • goimports moved from linters.enableformatters.enable
    • gosimple + stylecheck consolidated into staticcheck (v2 default)
    • issues.exclude-ruleslinters.exclusions.rules
  • .github/workflows/ci.yml: version: v1.64version: v2.3.0
  • go.mod: Updated tool dependency to golangci/golangci-lint/v2

Verification

  • go build ./...
  • go test ./... — 417 passed in 34 packages ✅
  • go vet ./...

Impact

Once merged, the Lint job in CI will pass for all open PRs (after rebase). The Security Scan (gosec) failures are separate and pre-existing.

snakeice added 5 commits July 15, 2026 23:39
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
@snakeice
snakeice merged commit 50b2054 into main Jul 16, 2026
6 checks passed
@snakeice
snakeice deleted the ci/upgrade-golangci-lint-v2 branch July 16, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant