Custom pre-commit hooks for projects using Rhiza templates.
This repository extracts rhiza's local hooks into a standalone package, allowing rhiza and downstream projects to use them as an external hook repository.
🚀 Quick Start
Add to your .pre-commit-config.yaml:
repos: - repo: https://github.com/Jebel-Quant/rhiza-hooks rev: v0.1.0 # Use the latest release hooks: # Migrated from rhiza - id: check-rhiza-workflow-names - id: update-readme-help # Additional utility hooks - id: check-rhiza-config - id: check-makefile-targets - id: check-python-version-consistency - id: check-template-bundles
Then install the hooks:
📋 Available Hooks
Migrated from Rhiza
check-rhiza-workflow-names
Ensures GitHub Actions workflow names have the (RHIZA) prefix in uppercase. Automatically fixes files that don't conform.
Files: .github/workflows/rhiza_*.yml
Usage:
- id: check-rhiza-workflow-names
update-readme-help
Embeds the output of make help into README.md between marker comments.
Triggers on: Changes to Makefile
Usage:
Additional Utility Hooks
check-rhiza-config
Validates the .rhiza/template.yml configuration file to ensure:
- All required keys are present (
template-repository,template-branch) - At least one of
includeortemplatesis present - The
template-repositoryis in the correctowner/repoformat - No unknown keys are present
- The
includelist (if present) is not empty - The
templateslist (if present) is not empty
Usage:
check-makefile-targets
Checks that your Makefile contains recommended targets for rhiza-based projects:
install- Install dependenciestest- Run testsfmt- Format codehelp- Show available targets
By default, this hook only warns about missing targets. Use --strict to fail on missing targets.
Usage:
- id: check-makefile-targets args: [--strict] # Optional: fail if targets are missing
check-python-version-consistency
Ensures Python version is consistent between .python-version and pyproject.toml's requires-python.
Usage:
- id: check-python-version-consistency
check-template-bundles
Validates templates specified in .rhiza/template.yml against the template-bundles.yml file from the template repository. This hook:
- Fetches
template-bundles.ymlfrom the remote template repository specified in your config - Ensures all templates listed in your
.rhiza/template.ymlexist in the remote bundles - Validates bundle structure (each bundle has
descriptionandfiles) - Checks that bundle dependencies are valid
Triggers on: Changes to .rhiza/template.yml
Usage:
- id: check-template-bundles
🛠️ Development
Prerequisites
- Python 3.11+
- uv (recommended) or pip
Setup
# Clone the repository git clone https://github.com/Jebel-Quant/rhiza-hooks.git cd rhiza-hooks # Install dependencies make install # Install pre-commit hooks pre-commit install
Common Commands
make install # Install dependencies make test # Run tests with coverage make fmt # Format and lint code make deptry # Check for unused/missing dependencies make help # Show all available targets
Testing hooks locally
Use pre-commit try-repo to test hooks without committing:
# Test all hooks against your current project pre-commit try-repo . --all-files # Test a specific hook pre-commit try-repo . check-rhiza-config --files .rhiza/template.yml
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Rhiza - The template system these hooks are designed for
- pre-commit - The framework that makes this possible