This repository uses pre-commit to ensure code quality and that builds succeed before committing.
-
Install pre-commit (if not already installed):
pip install pre-commit
-
Install the git hook scripts:
cd /path/to/isomdl-uniffi pre-commit install -
(Optional) Run against all files to verify setup:
pre-commit run --all-files
The pre-commit hooks will automatically run on each commit and check:
- Cargo Check: Verifies the Rust crate compiles without errors
- Cargo Test: Runs all Rust unit tests
- Cargo Format: Ensures Rust code follows formatting standards
- Build Python Bindings: Builds the Rust crate in release mode and generates Python bindings
- Only runs when Rust source files or Cargo files are modified
- Ensures bindings can be generated successfully
- Run Python Tests: Executes the full Python test suite
- Runs when Rust code, Cargo files, or Python test files are modified
- Ensures all tests pass before committing
- Automatically builds bindings first if they don't exist
- Ruff: Formats Python test files and checks code style
- Combines formatting and linting in a single fast tool
- Replaces both Black and Flake8 functionality
- Removes trailing whitespace
- Ensures files end with a newline
- Validates YAML and TOML files
- Checks for large files (>1MB)
- Detects merge conflicts
If you need to skip pre-commit hooks for a specific commit (not recommended):
git commit --no-verify -m "Your commit message"To update to the latest versions of the pre-commit hooks:
pre-commit autoupdateIf hooks fail:
- Read the error message carefully - it will tell you what failed
- Fix the issue in your code
- Stage the fixes:
git add . - Try committing again
Common issues:
- Rust build fails: Fix any Rust compilation errors
- Python bindings fail: Ensure Rust builds successfully first
- Format check fails: Run
cargo fmtto auto-format Rust code - Black formatting: Black will auto-format Python files; just stage the changes