tqchen commented on code in PR #209: URL: https://github.com/apache/tvm-ffi/pull/209#discussion_r2479414363
########## CONTRIBUTING.md: ########## @@ -31,6 +31,133 @@ pip install --no-build-isolation -e . -v ``` We recommend using the `--no-build-isolation` flag to ensure compatibility with your existing environment. + +## Setting Up Pre-commit Hooks + +This project uses [pre-commit](https://pre-commit.com/) to maintain code quality and consistency. +Pre-commit hooks automatically check your code for common issues before you commit changes. + +### Installing Pre-commit + +First, install pre-commit (requires version 2.18.0 or later): + +```bash +pip install pre-commit +``` + +### Installing the Git Hooks + +After cloning the repository, install the pre-commit hooks: + +```bash +cd tvm-ffi +pre-commit install +``` + +This configures git to automatically run the hooks before each commit. + +### Running Hooks Manually + +You can run the hooks manually on all files: + +```bash +pre-commit run --all-files +``` + +Or run them only on staged files: + +```bash +pre-commit run +``` + +### What the Hooks Check + +The pre-commit configuration includes checks for: + +- **License headers**: Ensures all files have proper Apache Software Foundation headers +- **Code formatting**: Runs clang-format (C++), ruff (Python), shfmt (Shell scripts) +- **Linting**: Runs clang-tidy, ruff, shellcheck, markdownlint, yamllint, and more +- **Type checking**: Runs mypy for Python type annotations +- **File quality**: Checks for trailing whitespace, file sizes, merge conflicts, etc. + +### Hook Versions and Requirements + +The project uses the following pre-commit hooks with specific versions (as defined in `.pre-commit-config.yaml`): Review Comment: agree we can skip this -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
