Skip to content

Commit beb0315

Browse files
corbtCursor Bot
andauthored
feat: Replace run_checks.sh with prek pre-commit hooks (#516)
* feat: Replace run_checks.sh with prek pre-commit hooks - Add prek as dev dependency for faster, Rust-based pre-commit hooks - Add .pre-commit-config.yaml with ruff, pyright, uv.lock check, and pytest hooks - Rename ruff.yml workflow to prek.yml, now runs all hooks via prek - pytest runs as manual hook locally but included in CI - Delete run_checks.sh (superseded by prek hooks) - Update CONTRIBUTING.md and AGENT.md with new workflow * ci: Trigger prek workflow on PRs to any branch This enables CI checks for stacked PRs that target non-main branches. --------- Co-authored-by: Cursor Bot <bot@cursor.com>
1 parent 913b35d commit beb0315

7 files changed

Lines changed: 78 additions & 345 deletions

File tree

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
name: Code Quality Checks
1+
name: Prek
22

33
on:
44
pull_request:
5-
branches: [ main ]
65
push:
76
branches: [ main ]
87

@@ -28,17 +27,10 @@ jobs:
2827
run: |
2928
uv sync --all-extras
3029
31-
- name: Run code quality checks
30+
- name: Run prek hooks (lint, format, typecheck, uv.lock, tests)
31+
run: |
32+
uv run prek run --all-files
33+
34+
- name: Run unit tests (via prek)
3235
run: |
33-
./scripts/run_checks.sh --verbose-test-failure || {
34-
echo ""
35-
echo "❌ Code quality checks failed!"
36-
echo ""
37-
echo "To fix these issues locally, run:"
38-
echo " ./scripts/run_checks.sh --fix"
39-
echo ""
40-
echo "Then commit and push the changes."
41-
echo ""
42-
echo "For more details, see CONTRIBUTING.md"
43-
exit 1
44-
}
36+
uv run prek run pytest

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.12.1
4+
hooks:
5+
- id: ruff
6+
- id: ruff-format
7+
8+
- repo: local
9+
hooks:
10+
- id: pyright
11+
name: Pyright type checking
12+
entry: uv run pyright src tests
13+
language: system
14+
pass_filenames: false
15+
16+
- id: uv-lock-check
17+
name: uv.lock sync check
18+
entry: uv lock --check
19+
language: system
20+
pass_filenames: false
21+
22+
- id: pytest
23+
name: Unit tests (manual)
24+
entry: uv run pytest --nbval --current-env --tb=short tests/unit
25+
language: system
26+
pass_filenames: false
27+
stages: [manual]

AGENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project uses the `uv` package manager.
88

99
## Testing
1010

11-
- Always run tests before committing. The test command is `./scripts/run_checks.sh`.
11+
- Always run tests before committing. The test command is `uv run prek run --all-files`.
1212

1313
## Releases
1414

CONTRIBUTING.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,32 @@ cd ART
1010
Install the dependencies:
1111

1212
```bash
13-
uv sync
13+
uv sync --group dev
1414
```
1515

16-
### Code Formatting and Linting
16+
### Code Quality Checks (prek)
1717

18-
This project uses [ruff](https://github.com/astral-sh/ruff) for both code formatting and linting. Before submitting a pull request, please ensure your code passes all quality checks:
18+
This project uses [prek](https://github.com/j178/prek) to run local checks (ruff, pyright, uv.lock sync, and unit tests). Before submitting a pull request, please ensure your code passes all quality checks:
1919

2020
```bash
21-
# Run all code quality checks (formatting, linting, and dependency sync)
22-
./scripts/run_checks.sh
21+
# Install git hooks (optional but recommended)
22+
uv run prek install
2323

24-
# Automatically fix any issues that can be fixed
25-
./scripts/run_checks.sh --fix
24+
# Run all checks against all files (formatting, linting, typecheck, uv.lock, tests)
25+
uv run prek run --all-files
2626
```
2727

28-
The `run_checks.sh` script will:
28+
You can also run individual hooks:
2929

30-
1. Check code formatting with ruff
31-
2. Check for linting issues with ruff
32-
3. Verify that `uv.lock` is in sync with `pyproject.toml`
30+
```bash
31+
uv run prek run ruff
32+
uv run prek run ruff-format
33+
uv run prek run pyright
34+
uv run prek run uv-lock-check
35+
uv run prek run pytest
36+
```
3337

34-
These checks are automatically run in CI for all pull requests. If your PR fails these checks, simply run `./scripts/run_checks.sh --fix` locally and commit the changes.
38+
These checks are automatically run in CI for all pull requests. If your PR fails these checks, re-run the corresponding `prek` hook locally and commit any fixes.
3539

3640
### Release Process
3741

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ dev = [
117117
"pytest-asyncio>=1.1.0",
118118
"duckdb>=1.0.0",
119119
"pyarrow>=15.0.0",
120+
"prek>=0.2.29",
120121
]
121122

122123
[tool.uv.sources]

0 commit comments

Comments
 (0)