This repository was archived by the owner on Jul 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
Implement Pre-Commit/Pre-Push Hook for Automated Testing #49
Copy link
Copy link
Open
Labels
Description
Summary
Implement a pre-commit or pre-push hook that ensures all tests, including RuboCop, linters, and potentially the act gem, are run locally before changes are pushed to the remote repository. This will help catch errors early and maintain code quality before reaching the CI pipeline on GitHub.
Details
We would like to implement a Git hook that performs the following actions before allowing a commit or push:
- Run Test Suite:
- Ensure that all tests pass.
- Run Linters:
- Execute
RuboCopto enforce code style and catch syntax errors. - Run JavaScript linters (e.g.,
ESLint) to check for code quality in the frontend.
- Run
act gem:
- Use the
act gemto simulate the GitHub Actions CI pipeline locally to catch any errors before pushing to GitHub.
- Run Security Scans (Optional):
- Run any security tools to check for vulnerabilities (e.g.,
Brakeman,bundler-audit).
- Run Database Schema Validation (Optional):
- Ensure there are no pending migrations that haven't been run, or that the schema is up-to-date.
Proposed Implementation
- Pre-Commit Hook: Runs every time a commit is made. This ensures that only code that passes all tests and lint checks is committed.
- Pre-Push Hook: Runs every time code is pushed to the remote repository. This can include running the
act gemto simulate the CI environment.
Tools & Libraries (more research needed):
- Use
Husky(for JavaScript projects) orOvercommit(for Ruby projects) to manage Git hooks. - Alternatively, custom shell scripts can be used in
.git/hooks/.
Benefits
- Early Error Detection: Catch errors before they reach the CI pipeline, reducing failed builds.
- Code Quality: Maintain high code quality with enforced linting and testing.
- Developer Efficiency: Prevent the back-and-forth of fixing issues after pushing by ensuring code is CI-ready.
Additional Considerations
- How to handle long-running tests in the pre-push hook? Should we exclude some tests, or provide an option to skip running act?
- Configurability: Allow developers to customize or opt-out of certain checks.
- Cross-platform compatibility: Ensure hooks work on both macOS and Linux environments.
Reactions are currently unavailable