Skip to content

Migrate to golangci-lint GitHub Action and update config#20

Merged
ankurs merged 3 commits intomasterfrom
claude/migrate-golangci-lint-v2-NsUFb
Jan 28, 2026
Merged

Migrate to golangci-lint GitHub Action and update config#20
ankurs merged 3 commits intomasterfrom
claude/migrate-golangci-lint-v2-NsUFb

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Jan 28, 2026

Summary

This PR modernizes the linting setup by migrating from a manual make lint command 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

  • GitHub Actions Workflow: Replaced make lint with golangci/golangci-lint-action@v9 for more reliable and maintainable CI/CD linting
  • golangci-lint Configuration: Upgraded .golangci.yml from v1 to v2 format with:
    • Expanded linter presets (comments, common-false-positives, legacy, std-error-handling)
    • Additional linters enabled (errcheck, ineffassign, staticcheck)
    • Explicit exclusion rules for test files, generated code, third-party, builtin, and example directories
    • Separate formatter exclusion configuration
  • Makefile: Updated golangci-lint installation to use v2 with @latest version specifier
  • Timeout Configuration: Added 5-minute timeout to the linting action to prevent hanging builds

Implementation Details

  • The GitHub Action approach provides better integration with GitHub's infrastructure and automatic updates
  • The v2 config format is more explicit and maintainable with clearer separation of concerns (linters vs formatters)
  • Test files are properly excluded from certain linters (funlen, goconst, errcheck, ineffassign, staticcheck) to avoid false positives
  • Generated code and third-party dependencies are excluded from linting to focus on project code quality

https://claude.ai/code/session_01LSdKuptpwd7SCKKpj7iPod

Summary by CodeRabbit

  • Chores

    • CI linting upgraded to golangci-lint v2 with explicit timeout; Makefile/tools references updated accordingly
    • Lint config migrated to v2-style with finer-grained exclusions and per-test-file rules
    • go.mod refreshed with numerous dependency and tooling version updates
  • New Features

    • Project initialization now shows step-by-step progress with clearer error and success messages

✏️ Tip: You can customize this high-level summary in your review settings.

- 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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Upgrades golangci-lint from v1 to v2 across CI, config, tooling and dependencies; updates go.mod with many version bumps and replacements; adjusts Makefile/tools import paths; and makes hooks/post_gen_project.py proto-init logging more verbose with stepwise progress and explicit errors. (46 words)

Changes

Cohort / File(s) Summary
CI workflow
{{cookiecutter.app_name}}/.github/workflows/go.yml
Replaces make lint with golangci-lint-action@v9, pins linter to v2.8 and adds explicit timeout
GolangCI config
{{cookiecutter.app_name}}/.golangci.yml
Migrates config to v2 schema (version: "2"), adds linters.exclusions and formatter.exclusions, introduces per-test and path-based exclusion rules
Makefile & tooling import
{{cookiecutter.app_name}}/Makefile, {{cookiecutter.app_name}}/tools/tools.go
Switches install/import path for golangci-lint to v2 module path (.../v2/...)
Module dependencies
{{cookiecutter.app_name}}/go.mod
Large dependency updates and replacements: tooling/linters upgraded, many transitive version bumps, migration to v2+ module paths for several modules
Project hook
hooks/post_gen_project.py
init_proto() now emits step-by-step progress messages, explicit per-step error prints, uses code != 0 checks, and prints a final success message

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

  • fajran
  • vestor
  • kevinjom

Poem

🐇 I hopped through code with tiny paws,

Swapped lints and tuned the builds because,
Configs were lifted, modules new —
I nibbled bugs and left a queue. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: migrating to golangci-lint GitHub Action and updating the configuration to v2 format, which are the primary objectives reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 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 lint with golangci/golangci-lint-action@v9 in the GitHub Actions workflow
  • Updated the Makefile to install golangci-lint using a v2 module path
  • Rewrote the .golangci.yml configuration 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.

Comment thread {{cookiecutter.app_name}}/Makefile Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 @latest while the GitHub Actions workflow pins v2.8. This could cause different lint results between local development and CI if @latest resolves 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, and staticcheck from 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.

@go-coldbrew go-coldbrew deleted a comment from Copilot AI Jan 28, 2026
@go-coldbrew go-coldbrew deleted a comment from coderabbitai Bot Jan 28, 2026
@go-coldbrew go-coldbrew deleted a comment from coderabbitai Bot Jan 28, 2026
@ankurs ankurs requested a review from Copilot January 28, 2026 07:55
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 survive go mod tidy.

With the tools build tag, go mod tidy without -tags=tools can drop tool dependencies. Please confirm your automation includes the tools tag (or equivalent) so golangci-lint/v2 remains pinned.

Comment thread hooks/post_gen_project.py
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

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.

Comment thread {{cookiecutter.app_name}}/.github/workflows/go.yml
Comment thread {{cookiecutter.app_name}}/go.mod
@ankurs ankurs merged commit 314bfb6 into master Jan 28, 2026
4 checks passed
@ankurs ankurs deleted the claude/migrate-golangci-lint-v2-NsUFb branch January 28, 2026 08:20
@coderabbitai coderabbitai Bot mentioned this pull request Mar 23, 2026
3 tasks
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.

3 participants