Skip to content

Conversation

@kriscoleman
Copy link
Collaborator

@kriscoleman kriscoleman commented Apr 5, 2025

This PR

  • Implements Lefthook for easy git hooks, w/ configuration to:
    • Ensuresgo fmt as a pre-commit hook with stage_fixed: true (it will automatically stage the fixes), preventing pushes with bad code formatting.
    • Ensures make generate-docs is executed pre-push, preventing a push with forgotten document generation updates
    • Ensures go test is executed and tests pass pre-push, preventing a push with broken tests
  • Updates the README.md to reflect the latest Lefthook setup and usage instructions.

Notes

  • I find these kinds of automation to help tremendously - when switching projects and adhering to different standards, having this automation in place can make jumping around seamless, and prevents wasting time when you forget to handle checks before a push.
  • Developers can manually run hooks using lefthook run pre-commit or lefthook run pre-push.

Follow-up Tasks

  • Monitor team feedback on the updated Lefthook setup.
  • Consider adding additional hooks if needed, such as security checks, or go vet.

How to test

  1. Install Lefthook using brew install lefthook.
  2. Run lefthook install to opt-in and set up the hooks.
  3. Test the pre-commit hook:
    • Make a change to a Go file and commit it.
    • Verify that go fmt runs and stages any changes automatically.
  4. Test the pre-push hook:
    • Introduce a change to the auto-generated documentation, like delete an entire section. Commit the change.
    • Attempt to push and verify that the push is blocked.
    • Break a test on purpose and attempt to push and verify that the push is blocked if tests fail.
image

@kriscoleman kriscoleman force-pushed the chore/prepush branch 3 times, most recently from 3021ddb to daeb67c Compare April 5, 2025 20:30
@kriscoleman kriscoleman changed the title chore: automate project standards chore: automate project standards before push Apr 6, 2025
Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

This is great, thanks!

@beeme1mr
Copy link
Member

Hey @kriscoleman, please ping me when the merge conflicts and readme changes have been addressed so I can merge the PR. Thanks!

@kriscoleman
Copy link
Collaborator Author

Hey @kriscoleman, please ping me when the merge conflicts and readme changes have been addressed so I can merge the PR. Thanks!

Sounds great @beeme1mr
I'll wait until after #97 is merged, then rebase this.

Adds Lefthook configuration to automate Git hooks, ensuring consistent pre-commit & pre-push checks.

Lefthook automates pre-commit checks such as code formatting and pre-push checks to ensure documentation and tests are up-to-date.

This helps maintain code quality and consistency across the team. I find this saves me time as I switch projects and standards, so I don't push and wait for a PR check to fail.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
@kriscoleman
Copy link
Collaborator Author

@beeme1mr rebased this and addressed your feedback on docs. I also dropped the fmt commit, because that got merged in the other PR. I reran all hooks and they passed locally and no changes were generated.

@beeme1mr beeme1mr added this pull request to the merge queue Apr 14, 2025
Merged via the queue into open-feature:main with commit e32547f Apr 14, 2025
6 checks passed
Adityasinghvats pushed a commit to Adityasinghvats/cli that referenced this pull request May 28, 2025
feat: integrates pre-commit and pre-push hooks to automate standards

Adds Lefthook configuration to automate Git hooks, ensuring consistent pre-commit & pre-push checks.

Lefthook automates pre-commit checks such as code formatting and pre-push checks to ensure documentation and tests are up-to-date.

This helps maintain code quality and consistency across the team. I find this saves me time as I switch projects and standards, so I don't push and wait for a PR check to fail.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Signed-off-by: Adityasinghvats <131326798+Adityasinghvats@users.noreply.github.com>
Adityasinghvats pushed a commit to Adityasinghvats/cli that referenced this pull request May 28, 2025
feat: integrates pre-commit and pre-push hooks to automate standards

Adds Lefthook configuration to automate Git hooks, ensuring consistent pre-commit & pre-push checks.

Lefthook automates pre-commit checks such as code formatting and pre-push checks to ensure documentation and tests are up-to-date.

This helps maintain code quality and consistency across the team. I find this saves me time as I switch projects and standards, so I don't push and wait for a PR check to fail.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Signed-off-by: Adityasinghvats <131326798+Adityasinghvats@users.noreply.github.com>
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.

2 participants