Skip to content

Pc 474#237

Open
f-leu wants to merge 5 commits intomainfrom
PC-474
Open

Pc 474#237
f-leu wants to merge 5 commits intomainfrom
PC-474

Conversation

@f-leu
Copy link
Contributor

@f-leu f-leu commented Jan 9, 2026

[Title]

📚 Description of Changes

Provide an overview of your changes and why they’re needed. Link to any related issues (e.g., "Fixes #123"). If your PR fixes a bug, resolves a feature request, or updates documentation, please explain how.

  • What Changed:
    (Describe the modifications, additions, or removals.)

  • Why This Change:
    (Explain the problem this PR addresses or the improvement it provides.)

  • Affected Components:
    (Which component does this change affect? - put x for all components)

  • Compose

  • K8s

  • Other (please specify)

❓ Motivation and Context

Why is this change required? What problem does it solve?

  • Context:
    (Provide background information or link to related discussions/issues.)

  • Relevant Tasks/Issues:
    (e.g., Fixes: #GitHub Issue)

🔍 Types of Changes

Indicate which type of changes your code introduces (check all that apply):

  • BUGFIX: Non-breaking fix for an issue.
  • NEW FEATURE: Non-breaking addition of functionality.
  • BREAKING CHANGE: Fix or feature that causes existing functionality to not work as expected.
  • ENHANCEMENT: Improvement to existing functionality.
  • CHORE: Changes that do not affect production (e.g., documentation, build tooling, CI).

🔬 QA / Verification Steps

Describe the steps a reviewer should take to verify your changes:

  1. (Step one: e.g., "Run make test to verify all tests pass.")
  2. (Step two: e.g., "Deploy to a Kind cluster with make create-kind && make deploy.")
  3. (Additional steps as needed.)

✅ Global Checklist

Please check all boxes that apply:

  • I have read and followed the CONTRIBUTING guidelines.
  • My code follows the code style of this project.
  • I have updated the documentation as needed.
  • I have added tests that cover my changes.
  • All new and existing tests have passed locally.
  • I have run this code in a local environment to verify functionality.
  • I have considered the security implications of this change.

Summary by CodeRabbit

  • New Features

    • Added repository-wide pre-commit hooks and an automated workflow to run them on pushes and pull requests.
  • Documentation

    • Streamlined contributor guide: clarified PR steps, added pre-commit setup, quick-run and troubleshooting sections, and replaced lengthy component-specific guidance with concise contributor directions.
  • Chores

    • Added pre-commit configuration (formatting, linting, whitespace, YAML/JSON checks, large-file detection), Makefile targets to install/run hooks, and updated ignore patterns for tooling/virtualenv.

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

@f-leu f-leu added the changelog:added New features label Jan 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Adds pre-commit infrastructure: repository pre-commit config, GitHub Actions workflow, Makefile targets and tooling, CONTRIBUTING updates, and .gitignore additions for local virtualenv/tools.

Changes

Cohort / File(s) Summary
Pre-commit config & ignores
\.pre-commit-config.yaml, \.gitignore
Adds .pre-commit-config.yaml with local Go hooks (gofmt, goimports, golangci-lint) and standard checks (trailing-whitespace, end-of-file-fixer, check-json, check-yaml, check-added-large-files). .gitignore adds .venv and .tools.
CI / GitHub Actions
.github/workflows/pre-commit.yml
New "pre-commit" workflow that runs on push/PR/merge_group/workflow_dispatch, sets up Python 3.12 and Go (from go.mod), installs pre-commit and Go tools, and runs pre-commit across the repo.
Local developer tooling
Makefile
Introduces PRE_COMMIT variable, virtualenv-based installation, and targets: pre-commit-install, pre-commit, pre-commit-tools, pre-commit-install-tool, pre-commit-setup to install/run pre-commit and required Go tools.
Contributor docs
.github/CONTRIBUTING.md
Adds a "Pre-Commit Hooks" section (setup, run, optional enablement, troubleshooting), reworks PR guidelines formatting, and condenses Documentation guidance.

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub Actions
    participant Repo as Repository
    participant Py as Python 3.12
    participant Go as Go (from go.mod)
    participant Tools as Go Tools
    participant PC as pre-commit

    GH->>Repo: checkout
    GH->>Py: setup Python 3.12
    GH->>Go: setup Go runtime (go.mod)
    GH->>Go: add Go bin to PATH
    GH->>PC: install pre-commit
    GH->>Tools: install goimports, golangci-lint
    GH->>PC: run pre-commit --all-files
    PC->>Repo: execute hooks (gofmt, goimports, golangci-lint, yaml/json checks, etc.)
    PC-->>GH: return results (pass/fail, diffs)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • dray92

Poem

🐰
I nibble code, I polish sticks,
Hooks hop in to fix the ticks,
Gofmt hums and linters sing,
CI and local bells all ring,
A tidy burrow for our spring!

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The pull request implements pre-commit hooks setup, but the linked issue #123 is about a 'cluster snapshot enum name fix,' which is unrelated to the actual changes. Link the correct issue(s) related to the pre-commit hooks implementation, or verify that #123 'cluster snapshot enum name fix' is the intended objective.
Title check ❓ Inconclusive The title 'Pc 474' is vague and generic, using only what appears to be a ticket reference without describing the actual changes made in the pull request. Revise the title to clearly describe the main change, such as 'Add pre-commit hooks configuration and workflow' or 'Set up pre-commit hooks for code formatting and linting'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes (pre-commit configuration, GitHub Actions workflow, Makefile targets, documentation updates, and .gitignore additions) are cohesive and related to implementing pre-commit hooks infrastructure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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

@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: 5

🤖 Fix all issues with AI agents
In @.github/workflows/pre-commit.yml:
- Around line 33-42: The workflow installs Go tools into the default GOPATH/bin
but pre-commit expects them under ./.tools/bin; update the "Install Go tools"
step to set GOBIN to ./.tools/bin (and create that directory) before running go
install so goimports and golangci-lint are placed at ./.tools/bin, and update
the "Add Go bin to PATH" step to append .tools/bin to GITHUB_PATH instead of (or
in addition to) $(go env GOPATH)/bin so the pre-commit hooks can find ./
.tools/bin/goimports and ./ .tools/bin/golangci-lint.

In @.pre-commit-config.yaml:
- Around line 22-32: CI shows that formatting hooks (trailing-whitespace and
end-of-file-fixer) modified files, so run the configured pre-commit hooks
locally (e.g., install hooks and run pre-commit run --all-files), stage and
commit the resulting changes, and push the updated commit(s) so the repository
contains the corrected formatting before re-running CI.

In @Makefile:
- Around line 165-190: The pre-commit target can fail when Go tools in
.tools/bin are missing; update the Makefile so the pre-commit target depends on
the pre-commit-tools target (or otherwise ensures .tools/bin is on PATH) and
invoke PRE_COMMIT with GOBIN/.tools/bin in PATH when running (e.g., make
pre-commit depend on pre-commit-tools and .venv/bin/pre-commit, and run
$(PRE_COMMIT) with PATH="$(PWD)/.tools/bin:$$PATH" so installed Go tools are
available); adjust related targets (.tools/bin, pre-commit-tools,
pre-commit-install-tool) accordingly to preserve installation behavior.
🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

1-3: Consider moving expensive hooks (e.g., golangci-lint) off the pre-commit stage.

If golangci-lint is slow, a pre-push (or manual) stage is usually less disruptive than blocking every commit.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b62a6f3 and 3ef302a.

📒 Files selected for processing (5)
  • .github/CONTRIBUTING.md
  • .github/workflows/pre-commit.yml
  • .gitignore
  • .pre-commit-config.yaml
  • Makefile
🧰 Additional context used
🪛 GitHub Actions: pre-commit
.github/workflows/pre-commit.yml

[error] 1-1: Executable './.tools/bin/goimports' not found. goimports hook failed.


[error] 1-1: Executable './.tools/bin/golangci-lint' not found. golangci-lint hook failed.


[warning] 1-1: Trailing whitespace and end-of-file fixes were applied by hooks (trailing-whitespace, end-of-file-fixer).

.pre-commit-config.yaml

[error] 1-1: Executable './.tools/bin/goimports' not found. goimports hook failed.


[error] 1-1: Executable './.tools/bin/golangci-lint' not found. golangci-lint hook failed.


[warning] 1-1: Trailing whitespace and end-of-file fixes were applied by hooks (trailing-whitespace, end-of-file-fixer).

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Docker Image
  • GitHub Check: Build Docker Image
  • GitHub Check: Analyze (go)
🔇 Additional comments (8)
.gitignore (1)

32-33: LGTM!

The .venv and .tools entries appropriately support the new pre-commit tooling and local development environment introduced in this PR.

.github/CONTRIBUTING.md (3)

18-18: LGTM!

The table of contents now includes the Pre-Commit Hooks section, maintaining consistent structure and navigation.


42-55: Clear improvement to PR workflow formatting.

Reformatting the steps with explicit numbering and bolded labels enhances readability and makes the workflow more scannable.


110-136: Verify that all Makefile targets referenced in the documentation are implemented.

The new section documents the following targets: make pre-commit-setup, make pre-commit, make pre-commit-install-tool, make pre-commit-tools, and make pre-commit-install. Ensure these targets exist in the Makefile and execute correctly before merging.

.github/workflows/pre-commit.yml (1)

44-45: Address trailing whitespace warning.

The pipeline output indicates that hooks applied trailing whitespace and end-of-file fixes. Verify the workflow file itself and other changed files for trailing whitespace, and commit these fixes to ensure a clean pipeline run.

Makefile (3)

63-63: Defaulting TARGET_NAMESPACES to empty: confirm downstream expectations.

If any consumers treat this as “unset vs empty string” differently (e.g., templating/validation), this could be behavior-changing.


383-383: No actionable concern here beyond whitespace/comment-only changes.

Also applies to: 425-425, 429-429, 743-750


710-724: Clarify why buf generate runs twice with the same output directory.

Line 722 generates from the DAKR proto descriptor binary while line 723 generates from zxporter's own protos (./internal/proto/mpa.proto, ./proto/api/v1/mpa.proto). Both output to the gen directory using the same buf.gen.yaml config, which risks conflicting or duplicate outputs. Either document the intentional separation of concerns, use distinct output directories, or consolidate into a single invocation if both proto sets can be processed together.

Comment on lines +22 to +32
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
args: ["--allow-multiple-documents"]
exclude: ^helm-chart/.*/templates/
- id: check-added-large-files
args: ["--maxkb=1024"]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

CI warning: formatting hooks are modifying files—run pre-commit locally and commit the results.

The job warning indicates trailing-whitespace / end-of-file-fixer applied changes; CI will keep failing until those edits are included in the PR commit(s).

🤖 Prompt for AI Agents
In @.pre-commit-config.yaml around lines 22 - 32, CI shows that formatting hooks
(trailing-whitespace and end-of-file-fixer) modified files, so run the
configured pre-commit hooks locally (e.g., install hooks and run pre-commit run
--all-files), stage and commit the resulting changes, and push the updated
commit(s) so the repository contains the corrected formatting before re-running
CI.

Copy link

@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 @.github/CONTRIBUTING.md:
- Line 135: Remove the leftover HTML TODO comment "<!-- todo? remove scope later
when all old lint errors are fixed -->" from the CONTRIBUTING.md content; simply
delete that line so the user-facing documentation no longer includes the
development note and leave surrounding text intact.
🧹 Nitpick comments (1)
Makefile (1)

167-169: Consider pinning the pre-commit version.

The installation upgrades pip but doesn't pin the pre-commit package version, which could lead to inconsistent behavior as new versions are released.

📌 Suggested improvement
 .venv/bin/pre-commit:
 	python3 -m venv .venv
-	.venv/bin/pip install --upgrade pip pre-commit
+	.venv/bin/pip install --upgrade pip
+	.venv/bin/pip install pre-commit==4.0.1

Note: You'll need to verify the desired pre-commit version.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef302a and 9481212.

📒 Files selected for processing (3)
  • .github/CONTRIBUTING.md
  • .pre-commit-config.yaml
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (1)
  • .pre-commit-config.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Docker Image
  • GitHub Check: Build Docker Image
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
.github/CONTRIBUTING.md (1)

110-134: LGTM! Clear and actionable pre-commit documentation.

The new Pre-Commit Hooks section is well-structured with clear setup instructions, manual run commands, optional installation, and troubleshooting steps. The documentation properly sets expectations that hooks are optional and aligns with the Makefile targets.

Makefile (1)

188-189: LGTM! Appropriate separation of setup and hook installation.

The pre-commit-setup target intentionally does not install hooks (no dependency on pre-commit-install), which aligns with the documented behavior that hooks are optional. This gives developers the flexibility to set up tools without automatically enabling pre-commit on every commit.

- Run: `make pre-commit-tools`.
- Run: `make pre-commit-install`.

<!-- todo? remove scope later when all old lint errors are fixed -->
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove leftover TODO comment.

The HTML comment <!-- todo? remove scope later when all old lint errors are fixed --> appears to be a development note that shouldn't be in the final user-facing documentation.

🧹 Proposed fix
-<!-- todo? remove scope later when all old lint errors are fixed -->
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- todo? remove scope later when all old lint errors are fixed -->
🤖 Prompt for AI Agents
In @.github/CONTRIBUTING.md at line 135, Remove the leftover HTML TODO comment
"<!-- todo? remove scope later when all old lint errors are fixed -->" from the
CONTRIBUTING.md content; simply delete that line so the user-facing
documentation no longer includes the development note and leave surrounding text
intact.

Copy link

@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 @Makefile:
- Around line 179-183: Update the goimports install in the pre-commit-tools
target: the line installing golang.org/x/tools/cmd/goimports@v0.30.0 should be
changed to a newer release (e.g., @v0.31.0) or to @latest to keep it current;
modify the go install invocation within the pre-commit-tools recipe so
GOBIN="$(PWD)/.tools/bin" go install golang.org/x/tools/cmd/goimports@v0.31.0
(or @latest) instead of @v0.30.0.
🧹 Nitpick comments (1)
Makefile (1)

185-189: Consider clarifying target naming and consolidation.

The pre-commit-install-tool target only depends on .venv/bin/pre-commit without adding functionality beyond what's already provided by that target. Additionally, pre-commit-setup might be slightly misleading as it doesn't install hooks (which are intentionally optional).

Consider:

  • Removing pre-commit-install-tool if it's not needed for external consumption
  • Adding a comment clarifying that pre-commit-setup installs the tool and dependencies but not the hooks
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9481212 and aaaa325.

📒 Files selected for processing (2)
  • .github/workflows/pre-commit.yml
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/pre-commit.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pre-commit
  • GitHub Check: Build Docker Image
  • GitHub Check: Build Docker Image
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
Makefile (3)

165-169: LGTM: Clean virtualenv setup.

The pre-commit variable and virtualenv target follow best practices for isolated Python tool installation.


171-177: LGTM: Well-structured pre-commit targets.

The dependency chain and PATH modification are correct. Making hook installation optional via a separate target is good design.


63-63: LGTM: Minor formatting improvements.

These whitespace and formatting adjustments improve readability without affecting functionality.

Also applies to: 383-383, 425-425, 429-429, 710-710, 722-722, 743-743

Comment on lines +179 to +183
.PHONY: pre-commit-tools
pre-commit-tools: ## Install Go tools needed by pre-commit.
@mkdir -p .tools/bin
GOBIN="$(PWD)/.tools/bin" go install golang.org/x/tools/cmd/goimports@v0.30.0
GOBIN="$(PWD)/.tools/bin" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

latest version golang.org/x/tools goimports 2025 2026

💡 Result:

goimports is distributed inside the golang.org/x/tools module and doesn’t have its own independent release tag — its version follows the golang.org/x/tools module release. To install the latest published version (resolves to the module’s latest tag or pseudo-version):

go install golang.org/x/tools/cmd/goimports@latest

(Documentation: pkg.go.dev). [1][2]

References:

  • golang.org/x/tools (pkg.go.dev) — goimports cmd and install instructions. [1]
  • golang/tools releases (GitHub) — module/release history (goimports is part of this repo). [2]

🌐 Web query:

golang.org/x/tools latest version 2025 2026 release

💡 Result:

Latest notable release: gopls (part of golang.org/x/tools) v0.21.0 — released Dec 17, 2025. [1][2]

References:

  • golang/tools GitHub releases (gopls/v0.21.0). [1]
  • go.dev gopls release pages / gopls release notes. [2]

🌐 Web query:

golang.org/x/tools module latest version v0.30.0 vs current releases

💡 Result:

v0.30.0 is not the latest — the golang.org/x/tools module has newer releases (e.g. v0.31.0 and later) and its downstream projects (like gopls) have continued releasing after v0.30.0. (pkg.go.dev)

Citations:


Update goimports to a more recent version.

The golangci-lint version correctly matches GOLANGCI_LINT_VERSION defined at line 545. However, goimports v0.30.0 is outdated; golang.org/x/tools has released v0.31.0 and later. Consider updating to a recent version or using @latest.

🤖 Prompt for AI Agents
In @Makefile around lines 179 - 183, Update the goimports install in the
pre-commit-tools target: the line installing
golang.org/x/tools/cmd/goimports@v0.30.0 should be changed to a newer release
(e.g., @v0.31.0) or to @latest to keep it current; modify the go install
invocation within the pre-commit-tools recipe so GOBIN="$(PWD)/.tools/bin" go
install golang.org/x/tools/cmd/goimports@v0.31.0 (or @latest) instead of
@v0.30.0.

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

Labels

changelog:added New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant