Skip to content

fix(make): install golangci-lint via v2 module path so make lint works#600

Merged
CybotTM merged 1 commit intomainfrom
fix/makefile-golangci-lint-v2
May 6, 2026
Merged

fix(make): install golangci-lint via v2 module path so make lint works#600
CybotTM merged 1 commit intomainfrom
fix/makefile-golangci-lint-v2

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented May 6, 2026

Summary

Makefile's lint, lint-fix, and dev-setup targets pinned github.com/golangci/golangci-lint/cmd/golangci-lint@latest — the v1 module path. Since the v2 release, @latest from this path resolves to the last v1.x tag (v1.64.8). The project's .golangci.yml uses version: "2", so v1 errors out with:

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

CI was unaffected because netresearch/.github's go-check workflow installs golangci-lint via a path that already targets v2. Only make lint was broken locally.

Surfaced by a review comment on #597.

Changes

  • Makefile:57,64,211 — three install lines now pin github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest.
  • .envrc:59check_tool install hint mirrors the v2 path so users seeing the "missing" message install the correct version.

Verification

$ rm -rf build/.tools && make lint
golangci-lint has version 2.12.1 built with go1.26.2 …
0 issues.

Matches the v2.12.1 that CI runs (netresearch/.github's go-check installs via go: downloading github.com/golangci/golangci-lint/v2 v2.12.1 per the workflow logs).

Test plan

  • make lint from clean state installs v2 and runs cleanly
  • Commit signed off (DCO)
  • CI green

The Makefile pinned `github.com/golangci/golangci-lint/cmd/golangci-lint@latest`,
which is the v1 module path. Since the v2 release, `@latest` from this path
resolves to the last v1.x tag (v1.64.8). The project's `.golangci.yml` uses
`version: "2"`, so v1 errors out with:

  Error: you are using a configuration file for golangci-lint v2 with
  golangci-lint v1: please use golangci-lint v2

CI was unaffected because netresearch/.github's `go-check` workflow installs
golangci-lint via a path that already targets v2 — only `make lint` was
broken locally.

- Makefile lint, lint-fix, dev-setup targets: pin
  `github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest`.
- .envrc check_tool hint mirrors the same path so users seeing the
  "missing" message install the correct version.

Verified: `make lint` from a clean state installs v2.12.1 and reports
0 issues against the current `.golangci.yml`.

Surfaced by review feedback on PR #597.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
Copilot AI review requested due to automatic review settings May 6, 2026 09:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the ci label May 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes local developer linting by updating go install commands to use the github.com/golangci/golangci-lint/v2/... module path, aligning the installed binary with the repository’s .golangci.yml (version: "2") and the CI toolchain.

Changes:

  • Switch make lint, make lint-fix, and make dev-setup to install golangci-lint from the v2 module path.
  • Update .envrc’s check_tool install hint to match the v2 module path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Makefile Updates tool installation lines so make lint/lint-fix/dev-setup install golangci-lint v2 (compatible with .golangci.yml).
.envrc Updates the displayed install hint so developers install the correct golangci-lint v2 module.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.21%. Comparing base (d32bab8) to head (7092461).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #600      +/-   ##
==========================================
- Coverage   87.28%   87.21%   -0.07%     
==========================================
  Files          88       88              
  Lines       10631    10631              
==========================================
- Hits         9279     9272       -7     
- Misses       1112     1118       +6     
- Partials      240      241       +1     
Flag Coverage Δ
integration 87.19% <ø> (-0.07%) ⬇️
unittests 83.78% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CybotTM CybotTM added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit e7a7637 May 6, 2026
30 checks passed
@CybotTM CybotTM deleted the fix/makefile-golangci-lint-v2 branch May 6, 2026 10:01
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the golangci-lint installation path to use the v2 module in both .envrc and the Makefile. The review feedback recommends pinning the linter to a specific version (v2.12.1) rather than using @latest to ensure consistency between local development and CI environments. Additionally, the feedback suggests standardizing the GOTOOLCHAIN version and ensuring consistent environment variables across all Makefile targets.

Comment thread .envrc

echo -e "${BLUE}🛠️ Checking required tools...${NC}"
check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The installation hint uses @latest, which can lead to version drift between local development and the CI environment. Since the PR description mentions that CI runs v2.12.1, it is recommended to pin this version in the hint to ensure consistency across all environments.

check_tool "golangci-lint" "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1"
References
  1. Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.

Comment thread Makefile
lint:
@mkdir -p $(BUILD_PATH)/.tools
@GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using @latest for tool installation makes the build non-deterministic and can cause drift between local development and CI. Per the PR description, CI uses v2.12.1, so this version should be pinned here. Additionally, the GOTOOLCHAIN version go1.26.2 is hardcoded and differs from the 1.26 requirement defined in .envrc, which violates the rule of maintaining consistency across configuration files.

	@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
  1. Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.

Comment thread Makefile
lint-fix:
@mkdir -p $(BUILD_PATH)/.tools
@GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@GOTOOLCHAIN=go1.26.2 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pinning the linter version to v2.12.1 ensures that the lint-fix target uses the same version as the lint target and the CI environment, preventing unexpected behavior or formatting changes.

	@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
  1. Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.

Comment thread Makefile
@echo "🔧 Setting up development environment..."
@echo "📦 Installing required tools..."
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The dev-setup target should pin the linter version to v2.12.1 for consistency with the lint targets. Furthermore, this command lacks the GOTOOLCHAIN specification used in the lint targets (lines 57 and 64), which could result in the linter being compiled with a different Go version than intended for this project.

	@GOTOOLCHAIN=go1.26 GOBIN=$(BUILD_PATH)/.tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.1
References
  1. Maintain consistency of tool installation commands across all project configuration files, such as Makefiles and environment setup scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants