Migrate to golangci-lint GitHub Action and update config#20
Conversation
- Add version: "2" to .golangci.yml config - Update Makefile to install golangci-lint/v2 module - Update GitHub workflow to use golangci-lint-action@v9 with v2.8 https://claude.ai/code/session_01LSdKuptpwd7SCKKpj7iPod
📝 WalkthroughWalkthroughUpgrades golangci-lint from v1 to v2 across CI, config, tooling and dependencies; updates Changes
Sequence Diagram(s)(Skipped — changes are configuration, dependency updates, and logging improvements that do not introduce a new multi-component control flow requiring a sequence diagram.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR attempts to migrate from a manual make lint command to the golangci-lint GitHub Action and modernize the configuration. However, the PR contains critical issues that will prevent it from working.
Changes:
- Replaced
make lintwithgolangci/golangci-lint-action@v9in the GitHub Actions workflow - Updated the Makefile to install golangci-lint using a v2 module path
- Rewrote the
.golangci.ymlconfiguration file using an undocumented "version 2" format
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| {{cookiecutter.app_name}}/.github/workflows/go.yml | Switches from make lint to golangci-lint GitHub Action with version v2.8 and 5-minute timeout |
| {{cookiecutter.app_name}}/Makefile | Updates golangci-lint installation to use /v2 module path with @latest |
| {{cookiecutter.app_name}}/.golangci.yml | Completely rewrites configuration using "version: 2" format with new structure for linters and formatters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @{{cookiecutter.app_name}}/.golangci.yml:
- Around line 25-28: The anchored regex patterns in the paths list ("-
third_party$", "- builtin$", "- examples$") only match the directory itself and
not files under those directories; update each pattern to match the directory
and its contents (for example replace "third_party$", "builtin$", "examples$"
with patterns like "third_party(/|$)", "builtin(/|$)", "examples(/|$)" or
"^(third_party|builtin|examples)(/|$)" so files inside those directories are
excluded as intended in .golangci.yml).
- Around line 18-21: The path exclusion patterns currently end with `$` which
only matches directory names themselves (e.g., `third_party`) and won't exclude
files under those dirs; update the patterns in the paths list (`third_party$`,
`builtin$`, `examples$`) to match the directory and its contents (for example
use patterns that allow a trailing slash or any subpath such as
`^third_party(/|$)`, `^builtin(/|$)`, `^examples(/|$)` or remove the `$` and add
a trailing slash) and apply the identical change to the
formatters.exclusions.paths section so files under those directories are
properly excluded by golangci-lint.
🧹 Nitpick comments (2)
{{cookiecutter.app_name}}/Makefile (1)
55-55: Consider pinning golangci-lint version for consistency with CI.The Makefile uses
@latestwhile the GitHub Actions workflow pinsv2.8. This could cause different lint results between local development and CI if@latestresolves to a newer version.Consider pinning the same version:
♻️ Suggested change
- github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest + github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0{{cookiecutter.app_name}}/.golangci.yml (1)
10-17: Consider keeping error-handling linters enabled for test files.Excluding
errcheck,ineffassign, andstaticcheckfrom test files disables important checks. Unchecked errors and unused assignments in tests can mask real issues and make tests unreliable.If specific test patterns are too noisy, consider more targeted exclusions rather than disabling these linters entirely for all tests.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@hooks/post_gen_project.py`:
- Around line 40-69: The exit-code checks after each Popen(...).wait() in
hooks/post_gen_project.py (the code variable used in the Go module and make
steps) only test if code > 0 and thus miss signal terminations which return
negative values; update each check (the four/five occurrences after Popen(["go",
"mod", "download", "all"]), Popen(["make", "install"]), Popen(["make",
"generate"]), Popen(["go", "mod", "tidy"]), and Popen(["make", "mock"])) to use
if code != 0 so any non-zero return (including negative signal terminations)
triggers the error print and sys.exit(code).
🧹 Nitpick comments (1)
{{cookiecutter.app_name}}/tools/tools.go (1)
8-12: Ensure tool deps survivego mod tidy.With the tools build tag,
go mod tidywithout-tags=toolscan drop tool dependencies. Please confirm your automation includes the tools tag (or equivalent) so golangci-lint/v2 remains pinned.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR modernizes the linting setup by migrating from a manual
make lintcommand to the official golangci-lint GitHub Action, and updates the golangci configuration to use the newer v2 format with more comprehensive linting rules.Key Changes
make lintwithgolangci/golangci-lint-action@v9for more reliable and maintainable CI/CD linting.golangci.ymlfrom v1 to v2 format with:@latestversion specifierImplementation Details
https://claude.ai/code/session_01LSdKuptpwd7SCKKpj7iPod
Summary by CodeRabbit
Chores
New Features
✏️ Tip: You can customize this high-level summary in your review settings.