[ci] Add local lint setup with pre-push hook to catch issues early
Developers can now catch lint issues before pushing, reducing CI failures and iteration time. The setup uses golangci-lint locally with the same configuration as CI.
Setup:
- Run
make setup-hooksonce after cloning - Pre-push hook automatically lints changed files
- Use
make lintto manually check changed files - Use
make lint-allto run full CI-equivalent lint
The Makefile auto-installs golangci-lint to ./bin/ using go install to match the Go version in go.mod, avoiding version compatibility issues.
Describe your changes
Issue ticket number and link
Stack
Checklist
- [ ] Is it a bug fix
- [ ] Is a typo/documentation fix
- [ ] Is a feature enhancement
- [ ] It is a refactor
- [x] Created tests that fail without the change (if possible)
By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.
Documentation
Select exactly one:
- [ ] I added/updated documentation for this change
- [x] Documentation is not needed for this change (explain why)
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
- Chores
- Implemented automated code quality checks using Git hooks to ensure consistent code standards before pushing changes
- Added linting configuration and streamlined development environment setup with automatic verification
- Documentation
- Updated contribution guide with instructions for setting up the local development environment with automatic code quality enforcement
✏️ Tip: You can customize this high-level summary in your review settings.
[!CAUTION]
Review failed
The head commit changed during the review from 13ed584929f58a921b81970490278a351d9d5f54 to 10d4ba1441def7f9e6bd7764d00445ce4db36722.
Walkthrough
A Git pre-push hook system is introduced to enforce linting checks before code is pushed. The .githooks/pre-push script executes linting via the Makefile, while new Makefile targets provide lint installation, targeted linting, full-codebase linting, and hook configuration capabilities. Documentation is updated with setup instructions.
Changes
| Cohort / File(s) | Summary |
|---|---|
Git Hooks & Linting Setup .githooks/pre-push, Makefile |
Added pre-push hook script that enforces linting. Makefile introduces GOLANGCI_LINT variable, lint target (changed files only, 2m timeout), lint-all target (full codebase, 12m timeout), lint-install target (lazy binary installation), and setup-hooks target (configures git hooks directory and makes hook executable). |
Documentation CONTRIBUTING.md |
Added step 6 under "Local NetBird setup" documenting the make setup-hooks command for automatic pre-push linting. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
- Review the shell script logic in
.githooks/pre-pushfor correct exit code handling and message output - Verify Makefile target dependencies and lazy-installation pattern for golangci-lint
- Confirm
setup-hookstarget correctly configures git hooks directory path and permissions
Poem
🐰 A hook, a lint, a gentle push,
No messy code shall pass the brush,
The rabbit checks before you send,
Quality assured from start to end! ✨
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly and specifically describes the main change: adding a local lint setup with a pre-push hook to catch issues early, which directly matches the changeset. |
| Description check | ✅ Passed | The description is substantially complete with good context about the changes and setup instructions, though the 'Describe your changes' section is empty. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
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 @coderabbitai help to get the list of available commands and usage tips.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code