Skip to content

Conversation

@syedazeez337
Copy link

@syedazeez337 syedazeez337 commented Jan 7, 2026

Summary

  • Add a git pre-commit hook configuration (via pre-commit) that runs essential make targets locally before committing
  • Configured hooks: make lint, make test, make generate, make manifests, make gen-check
  • Update Developer Guide with pre-commit installation and usage instructions

Test plan

  • Verified all pre-commit hooks execute successfully
  • Tested pre-commit run --all-files passes
  • Documentation added to Developer Guide

Fixes #7878

@syedazeez337 syedazeez337 requested a review from a team as a code owner January 7, 2026 12:59
@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 6938870
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6965f71377f6100009d3d59a
😎 Deploy Preview https://deploy-preview-7882--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.77%. Comparing base (9262042) to head (6ad3068).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7882      +/-   ##
==========================================
+ Coverage   72.72%   72.77%   +0.04%     
==========================================
  Files         235      235              
  Lines       35100    35177      +77     
==========================================
+ Hits        25528    25600      +72     
- Misses       7755     7760       +5     
  Partials     1817     1817              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


This will configure Git to run the following checks before each commit:

* `make lint`
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could we also run make lint.fix-golint

@zhaohuabing
Copy link
Member

zhaohuabing commented Jan 8, 2026

Would it be simpler to just add a precommit make target?

zhaohuabing
zhaohuabing previously approved these changes Jan 8, 2026
Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

cnvergence
cnvergence previously approved these changes Jan 8, 2026
@arkodg
Copy link
Contributor

arkodg commented Jan 11, 2026

thanks @syedazeez337 this looks good, can you share how much time this hook/make cmd takes ? want to make sure its not too long to start to annoy developers


.PHONY: precommit
precommit: ## Run all necessary steps to prepare for a commit.
precommit: lint.fix-golint lint test generate manifests gen-check
Copy link
Contributor

Choose a reason for hiding this comment

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

lets not run lint.fix-golint and change code, we can find an alt way to highlight this command to the user

hooks:
- id: make-precommit
name: make precommit
entry: bash -c 'GITHUB_ACTION= make precommit'
Copy link
Contributor

Choose a reason for hiding this comment

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

why is GITHUB_ACTION= needed

@syedazeez337
Copy link
Author

Hi @arkodg
this is the time breakdown

  • lint: ~1m 11s
  • test: ~40s
  • generate: ~27s
  • manifests: ~2s
  • gen-check: ~55s
  • Total: ~3 minutes 15 seconds

@syedazeez337 syedazeez337 dismissed stale reviews from cnvergence and zhaohuabing via 6fc32a8 January 11, 2026 06:03
@arkodg
Copy link
Contributor

arkodg commented Jan 11, 2026

that feels like a long time imo, should ideally be under 30s, does it take the same amount of time when run again ?

@syedazeez337
Copy link
Author

Pre-commit Component Timings

Linters

Component Time Description
lint.golint ~3s Go code linting
lint.kube-api-linter ~1s Kubernetes API validation
lint.codespell ~3s Spelling errors
lint.whitenoise ~1s Whitespace issues
lint.shellcheck ~1s Shell script linting
lint.dependabot ~4s Dependabot config
lint.yamllint ~1m 28s YAML validation

Other Tasks

Component Time Description
test ~40s Unit tests
generate ~27s Code generation
manifests ~2s Generate manifests
gen-check ~55s Runs format+generate+manifests+protos, checks for uncommitted changes

Possible Precommit Configurations

Config Components Total Time
Full All linters + test + gen-check ~3m 15s
No yamllint All linters except yamllint + test + gen-check ~1m 45s
No yamllint, no test All linters except yamllint + gen-check ~1m 5s
Linters only (no yamllint) Fast linters only ~12s

@arkodg What do you think should be kept in the pre-commit hook?

Add a git pre-commit hook configuration (via pre-commit) that runs
essential make targets locally before committing:

- make lint
- make test
- make generate
- make manifests
- make gen-check

This helps catch issues early and speeds up PR reviews by ensuring
code passes validations before being pushed.

Also updates the Developer Guide with instructions on how to install
and use pre-commit.

Fixes envoyproxy#7878

Signed-off-by: Azeez Syed <[email protected]>
Add a git pre-commit hook configuration (via pre-commit) that runs
essential make targets locally before committing:

- make lint.fix-golint - automatically fixes Go lint issues
- make lint - verifies no lint issues remain
- make test
- make generate
- make manifests
- make gen-check

This helps catch issues early and speeds up PR reviews by ensuring
code passes validations before being pushed.

Also updates the Developer Guide with instructions on how to install
and use pre-commit, and adds a 'make precommit' target for convenience.

Fixes envoyproxy#7878

Signed-off-by: Azeez Syed <[email protected]>
- Remove lint.fix-golint from precommit target to avoid auto-modifying code
- Remove GITHUB_ACTION= workaround from pre-commit config
- Fix root cause in lint.mk by using ${GITHUB_ACTION:-} to handle unset variable

Signed-off-by: Azeez Syed <[email protected]>
@zirain zirain force-pushed the feat/add-pre-commit-hook branch from 6fc32a8 to 6938870 Compare January 13, 2026 07:41
@arkodg
Copy link
Contributor

arkodg commented Jan 14, 2026

hey @syedazeez337 thanks for running the tests and sharing this data, will bring it up in the community meeting this week

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.

Add pre commit hook to run validations

4 participants