From 6cce8174853bb94b92ea466dfa78cdeb0add131c Mon Sep 17 00:00:00 2001 From: reacher-z <68239571+reacher-z@users.noreply.github.com> Date: Tue, 17 Nov 2026 01:16:31 -0700 Subject: [PATCH] Add a pre-commit configuration matching the CI style checks Ruff check and format run on scripts/, src/ and tests/, pinned to the Ruff version in uv.lock, plus YAML, TOML, JSON and whitespace checks on the files outside tasks/. All hooks pass on the current tree. --- .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ docs/development.md | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..39f8f126 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# Runs the same Ruff checks as CI on the development code. Install with +# uvx pre-commit install +# Keep the Ruff revision equal to the version in uv.lock. +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.17.3 + hooks: + - id: ruff-check + files: ^(scripts|src|tests)/ + - id: ruff-format + files: ^(scripts|src|tests)/ + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-yaml + exclude: ^tasks/ + - id: check-toml + exclude: ^tasks/ + - id: check-json + files: ^src/websitebench/.*\.json$ + - id: end-of-file-fixer + exclude: ^(tasks/|assets/) + - id: trailing-whitespace + exclude: ^(tasks/|assets/) diff --git a/docs/development.md b/docs/development.md index 898bc24e..3550326e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -41,6 +41,12 @@ Format edited development code with: uv run ruff format scripts src tests ``` +To run Ruff and basic YAML, TOML and whitespace checks on every commit, install the [pre-commit](https://pre-commit.com/) hooks: + +```sh +uvx pre-commit install +``` + ## CI [CI](../.github/workflows/ci.yml) runs on Python 3.12 and 3.13. It installs locked dependencies, checks source task definitions, runs the unit tests and Ruff checks, and verifies the official Harbor command's help output.