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.
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-bundlesThen install the hooks:
pre-commit installEnsures 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-namesEmbeds the output of make help into README.md between marker comments.
Triggers on: Changes to Makefile
Usage:
- id: update-readme-helpValidates 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:
- id: check-rhiza-configChecks 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 missingEnsures Python version is consistent between .python-version and pyproject.toml's requires-python.
Usage:
- id: check-python-version-consistencyValidates 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- Python 3.11+
- uv (recommended) or pip
# 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 installmake 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 targetsUse 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.ymlThis project is licensed under the MIT License - see the LICENSE file for details.
- Rhiza - The template system these hooks are designed for
- pre-commit - The framework that makes this possible