From 871032ea6d2fb7c68143b5e730c206bfd051bab9 Mon Sep 17 00:00:00 2001 From: Renato Golin Date: Thu, 5 Mar 2026 10:44:59 +0000 Subject: [PATCH 1/2] Helper script to avoid pre-commit failures --- README.md | 33 +++++++++++++++++++++++++++++++-- precommit.sh | 12 ++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 precommit.sh diff --git a/README.md b/README.md index c0eeb237..799280a8 100644 --- a/README.md +++ b/README.md @@ -124,9 +124,38 @@ pip install .[ingress_torch_cpu] \ --only-binary :all: ``` -## Running tests +## Running pre-commit checks -Running the tests is as simple as `lit .` in the root of the project (in a suitable Python environment, e.g. through `uv run lit .`). +To make sure you create a clean PR, you should run the code formatter and tests before submitting it. + +There's a script that helps you with this, assuming you have already set up your environment as described above. + +At the root of the repository, run: +``` +bash precommit.sh +``` + +This script runs all of the checks below, so you can just run it every time before a commit. + +### Python formatting + +We have a formatting pre-commit check for every PR. To make sure you don't get PR check failures, you can run `ruff`: + +At the root of the repository, run: +``` +uv run pre-commit run --all-files +``` + +This will check for issues and fix them automatically, so if you commit after running this check, you'll always have correctly formatted Python code. + +### LIT tests + +Running the tests is as simple as `lit .` in the root of the project (in a suitable Python environment): + +At the root of the repository, run: +``` +uv run lit . +``` We assume that the [`FileCheck`](https://llvm.org/docs/CommandGuide/FileCheck.html) and [`lit`](https://llvm.org/docs/CommandGuide/lit.html) executables are available on the `PATH`. diff --git a/precommit.sh b/precommit.sh new file mode 100755 index 00000000..a5d1d352 --- /dev/null +++ b/precommit.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Run this script from the root of the repository +# to run all pre-commit hooks and tests. +# This helps ensure that all checks are performed, +# and all files are formatted correctly before committing code. + +set -ex + +uv sync +uv run pre-commit run --all-files +uv run lit -v . From ce8b7e33cf1bf3fd8ce288c0a73f350ab1b4e4c7 Mon Sep 17 00:00:00 2001 From: Renato Golin Date: Thu, 5 Mar 2026 13:51:36 +0000 Subject: [PATCH 2/2] remove sync --- precommit.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/precommit.sh b/precommit.sh index a5d1d352..7778f178 100755 --- a/precommit.sh +++ b/precommit.sh @@ -7,6 +7,5 @@ set -ex -uv sync uv run pre-commit run --all-files uv run lit -v .