chore: migrate pre-commit to prek with workspace mode#535
Open
chore: migrate pre-commit to prek with workspace mode#535
Conversation
Replace the pre-commit framework with prek (https://prek.j178.dev/), a faster, drop-in compatible Rust reimplementation. Adopt prek's workspace mode to split the configuration into one config per project: - Root .pre-commit-config.yaml: cross-cutting checks (commit message format, file parsers, whitespace/EOL hygiene) and the OpenAPI/API client build hooks. - api/.pre-commit-config.yaml: ruff (check + format), invoked via uv run so the version pinned in api/pyproject.toml dev deps is used. - web/.pre-commit-config.yaml: biome, invoked via yarn so the version pinned in web/package.json devDependencies is used. Other changes: - Replace the pre-commit mise tool with prek (.mise/config.toml). - Add ruff to api/pyproject.toml dev dependencies so the pinned version drives both the editor and the hook. - biome.json: enable vcs.useIgnoreFile so biome respects .gitignore (avoids linting the yarn-generated .pnp.cjs / .pnp.loader.mjs). - CI: install api/web dependencies before running prek, since the ruff and biome hooks now shell out to uv/yarn. - Update setup docs and RUNBOOK to reference prek.
763fc5a to
3521ecb
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates the repo’s git hook runner from pre-commit to prek and adopts prek “workspace mode” so project-specific hooks live under api/ and web/, while the root config retains cross-cutting checks and build hooks.
Changes:
- Replace ruff/biome hook repos with local hooks that shell out to project-pinned binaries (
uv run ruff,yarn biome) via workspace-scoped configs. - Update CI to install API/Web dependencies before running
prek run --all-files. - Update developer docs/runbook references and enable Biome’s
vcs.useIgnoreFileto respect.gitignore.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.pre-commit-config.yaml |
Converts root hooks to workspace-mode-friendly layout; removes ruff/biome hook repos. |
api/.pre-commit-config.yaml |
Adds API-local ruff hooks executed via uv run. |
web/.pre-commit-config.yaml |
Adds Web-local Biome hook executed via yarn biome. |
.github/workflows/linting-and-checks.yaml |
Switches CI from pre-commit action to running prek after installing deps. |
.mise/config.toml |
Replaces pre-commit tool pin with prek. |
api/pyproject.toml |
Adds ruff to dev dependency group to pin hook/editor version. |
api/uv.lock |
Locks ruff dependency in the API environment. |
biome.json |
Enables Biome VCS integration to respect .gitignore. |
docs/docs/contribute/development-guide/01-setup.md |
Updates contributor setup docs to use prek. |
RUNBOOK.md |
Updates runbook resource link to point at prek. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
pre-commitframework withprek— a faster, drop-in compatible Rust reimplementation — and adopts prek's workspace mode to split the configuration into one config per project.Why
astral-sh/ruff-pre-commit/biomejs/pre-commithook repos at one version, and again as dev dependencies inapi/pyproject.toml/web/package.jsonat another version. Hooks now invoke the project-pinned binaries (uv run ruff,yarn biome), so the version in the lockfile is the version that runs.Layout
.pre-commit-config.yamlapi/.pre-commit-config.yamlruff check --fix+ruff format, run viauv runfromapi/.web/.pre-commit-config.yamlbiome check --write, run viayarn biomefromweb/.prek discovers all three configs automatically and runs hooks from the deepest project up —
apiandwebfirst, then root.Other changes
pre-commit = "4.5.1"withprek = "0.3.11".ruff>=0.15.12to thedevgroup so the pinned version drives both the editor and the hook.vcs.useIgnoreFileso biome respects.gitignore(avoids linting the yarn-generated.pnp.cjs/.pnp.loader.mjs).prek run --all-files, since the ruff and biome hooks shell out touv/yarn.Validation
prek run --all-filesandprek run --files <…>were exercised against representative files from each project to confirm scoping is correct:api/src/app/features/.../*.pyapi/tests/conftest.pyweb/src/App.tsxweb/package.jsonapi/.openapi.jsonREADME.mdMigration for contributors
Install
prek(any of:mise install,uv tool install prek,pip install prek,brew install prek) and runprek installonce to register the git hooks. The project's.pre-commit-config.yamlfiles work unchanged with the legacypre-commitCLI as well, so no flag day required.