From cb1e8f5d8323d1af03940057e41d1e7da9d63118 Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Tue, 10 Mar 2026 17:49:26 +0100 Subject: [PATCH 1/9] Add minimal pre-commit config --- .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 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..78ac61ca --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-merge-conflict + - id: check-vcs-permalinks + - id: check-executables-have-shebangs + - id: mixed-line-ending +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.5 + hooks: + - id: ruff-format + types_or: [python, pyi] +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v22.1.0 + hooks: + - id: clang-format + types_or: [c++, c, cuda] From 3acba350b280bf924872af6f3f82489d48cd5089 Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Wed, 11 Mar 2026 19:16:46 +0100 Subject: [PATCH 2/9] Add gersemi --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78ac61ca..5d7aeb67 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,3 +22,7 @@ repos: hooks: - id: clang-format types_or: [c++, c, cuda] +- repo: https://github.com/BlankSpruce/gersemi + rev: 0.26.0 + hooks: + - id: gersemi From 11d86298f98eb11931b6a9a92e4147cbf5a6e7fb Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Thu, 12 Mar 2026 11:31:09 +0100 Subject: [PATCH 3/9] Add yamlfmt and jsonnet-{format,lint} --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d7aeb67..d9027ab6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,3 +26,12 @@ repos: rev: 0.26.0 hooks: - id: gersemi +- repo: https://github.com/google/go-jsonnet + rev: v0.21.0 + hooks: + - id: jsonnet-format + - id: jsonnet-lint +- repo: https://github.com/google/yamlfmt + rev: v0.19.0 + hooks: + - id: yamlfmt From 31a65ee2ceef5197bb12f5a13173ac61cdedc430 Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Thu, 12 Mar 2026 11:50:14 +0100 Subject: [PATCH 4/9] Yaml-format the pre-commit config --- .pre-commit-config.yaml | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9027ab6..c2cc3421 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,37 +1,37 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-toml - - id: check-merge-conflict - - id: check-vcs-permalinks - - id: check-executables-have-shebangs - - id: mixed-line-ending -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.5 - hooks: - - id: ruff-format - types_or: [python, pyi] -- repo: https://github.com/pre-commit/mirrors-clang-format - rev: v22.1.0 - hooks: - - id: clang-format - types_or: [c++, c, cuda] -- repo: https://github.com/BlankSpruce/gersemi - rev: 0.26.0 - hooks: - - id: gersemi -- repo: https://github.com/google/go-jsonnet - rev: v0.21.0 - hooks: - - id: jsonnet-format - - id: jsonnet-lint -- repo: https://github.com/google/yamlfmt - rev: v0.19.0 - hooks: - - id: yamlfmt + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-merge-conflict + - id: check-vcs-permalinks + - id: check-executables-have-shebangs + - id: mixed-line-ending + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.5 + hooks: + - id: ruff-format + types_or: [python, pyi] + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v22.1.0 + hooks: + - id: clang-format + types_or: [c++, c, cuda] + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.26.0 + hooks: + - id: gersemi + - repo: https://github.com/google/go-jsonnet + rev: v0.21.0 + hooks: + - id: jsonnet-format + - id: jsonnet-lint + - repo: https://github.com/google/yamlfmt + rev: v0.19.0 + hooks: + - id: yamlfmt From e5339e4a76a4c87b50472a139f31da41295b5c52 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 13 Mar 2026 08:48:24 -0500 Subject: [PATCH 5/9] Update ruff-pre-commit version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c2cc3421..1fe53d23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-executables-have-shebangs - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.5 + rev: v0.15.6 hooks: - id: ruff-format types_or: [python, pyi] From f559396387bb79b153ed5a5dc3d48e39dea5ce5c Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 13 Mar 2026 09:04:54 -0500 Subject: [PATCH 6/9] Exclude test/max-parallelism from jsonnet-linting The files in that directory import files that are generated during the build stage. They cannot be meaningfully linted during a pre-commit step. --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1fe53d23..65033c2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,6 +31,9 @@ repos: hooks: - id: jsonnet-format - id: jsonnet-lint + # The files in test/max-parallelism import files that are generated during the build. + # We therefore exclude them from linting, but still format them. + exclude: ^test/max-parallelism - repo: https://github.com/google/yamlfmt rev: v0.19.0 hooks: From 48c6c01661850573b0348e20bedef16428f35375 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 13 Mar 2026 09:14:36 -0500 Subject: [PATCH 7/9] Change from yamlfmt to prettier --- .pre-commit-config.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65033c2d..a7e0aa53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,8 @@ repos: # The files in test/max-parallelism import files that are generated during the build. # We therefore exclude them from linting, but still format them. exclude: ^test/max-parallelism - - repo: https://github.com/google/yamlfmt - rev: v0.19.0 + - repo: https://github.com/rbubley/mirrors-prettier + rev: v3.8.1 hooks: - - id: yamlfmt + - id: prettier + types_or: [yaml] From 3416f35973b5b040af7340bf8fe1ea21a0cc573e Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Fri, 13 Mar 2026 18:19:44 +0100 Subject: [PATCH 8/9] Update clang-format version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7e0aa53..70d85b24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: ruff-format types_or: [python, pyi] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v22.1.0 + rev: v22.1.1 hooks: - id: clang-format types_or: [c++, c, cuda] From a40cced886954757e4ba90d231158d459607ca5d Mon Sep 17 00:00:00 2001 From: Oliver Lantwin Date: Fri, 13 Mar 2026 18:20:12 +0100 Subject: [PATCH 9/9] Add pre-commit section to DEVELOPING.md --- DEVELOPING.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/DEVELOPING.md b/DEVELOPING.md index 9ef73b1a..f915e625 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -122,3 +122,19 @@ The `.github/copilot-instructions.md` contains various "ground rules" to be obse The instructions in this file were created not by hand, but by asking Copilot to produce instructions for itself to achieve a goal, such as, "Please update the instructions file to ensure adherence to `markdown-lint` rules when generating Markdown files." This way (hopefully), the instructions are more likely to have the intended effect on the AI since they were generated by the AI itself. If you wish to add your own personalized instructions, or adjust/augment the repository-level instructions via PR, best results will be achieved by following this method rather than writing them yourself except in the most trivial of cases. + +## Pre-commit + +The tool pre-commit offers a framework for setting up hooks that are run on staged files before committing, ensuring correct formatting and catching some errors before they end up in a commit. + +To set up this tool locally, first install `pre-commit` (or `prek`, a faster re-implementation in rust) using your system package manager or `uv`/`pip(x)`, e.g. `uv tool install pre-commit`. + +So set up the hooks in the Phlex repository, run the `pre-commit install` command once in the repository. The hooks now should run automatically prior to each commit. + +To skip a check temporarily, run `SKIP=ruff-format git commit -m "...". To skip all hooks, you can use the `--no-verify` flag to `git commit`. + +To manually run hooks over all files, run `pre-commit run --all-files`. + +The pre-commit hooks are configured in `.pre-commit-config.yaml`. + +For further reference, see the extensive [pre-commit documentation](https://pre-commit.com/).