mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:19 -04:00
* 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-hooks` once after cloning - Pre-push hook automatically lints changed files (~90s) - Use `make lint` to manually check changed files - Use `make lint-all` to 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. --------- Co-authored-by: mlsmaycon <mlsmaycon@gmail.com>
28 lines
872 B
Makefile
28 lines
872 B
Makefile
.PHONY: lint lint-all lint-install setup-hooks
|
|
GOLANGCI_LINT := $(shell pwd)/bin/golangci-lint
|
|
|
|
# Install golangci-lint locally if needed
|
|
$(GOLANGCI_LINT):
|
|
@echo "Installing golangci-lint..."
|
|
@mkdir -p ./bin
|
|
@GOBIN=$(shell pwd)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
|
|
# Lint only changed files (fast, for pre-push)
|
|
lint: $(GOLANGCI_LINT)
|
|
@echo "Running lint on changed files..."
|
|
@$(GOLANGCI_LINT) run --new-from-rev=origin/main --timeout=2m
|
|
|
|
# Lint entire codebase (slow, matches CI)
|
|
lint-all: $(GOLANGCI_LINT)
|
|
@echo "Running lint on all files..."
|
|
@$(GOLANGCI_LINT) run --timeout=12m
|
|
|
|
# Just install the linter
|
|
lint-install: $(GOLANGCI_LINT)
|
|
|
|
# Setup git hooks for all developers
|
|
setup-hooks:
|
|
@git config core.hooksPath .githooks
|
|
@chmod +x .githooks/pre-push
|
|
@echo "✅ Git hooks configured! Pre-push will now run 'make lint'"
|