Skip to content

chore: migrate pre-commit to prek with workspace mode#535

Open
einarwar wants to merge 2 commits intomainfrom
chore/migrate-to-prek
Open

chore: migrate pre-commit to prek with workspace mode#535
einarwar wants to merge 2 commits intomainfrom
chore/migrate-to-prek

Conversation

@einarwar
Copy link
Copy Markdown
Contributor

@einarwar einarwar commented May 4, 2026

Summary

Replaces the pre-commit framework with prek — a faster, drop-in compatible Rust reimplementation — and adopts prek's workspace mode to split the configuration into one config per project.

Why

  • Version drift: ruff and biome were previously installed twice — once via the astral-sh/ruff-pre-commit / biomejs/pre-commit hook repos at one version, and again as dev dependencies in api/pyproject.toml / web/package.json at 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.
  • Speed: prek runs hooks in parallel where possible, has no Python bootstrap, and shares language toolchains across hooks.
  • Monorepo ergonomics: with workspace mode, project-specific tooling lives next to the project it covers.

Layout

File Scope
.pre-commit-config.yaml Cross-cutting checks: commit message format, file parsers, whitespace/EOL hygiene, OpenAPI spec + API client build hooks.
api/.pre-commit-config.yaml ruff check --fix + ruff format, run via uv run from api/.
web/.pre-commit-config.yaml biome check --write, run via yarn biome from web/.

prek discovers all three configs automatically and runs hooks from the deepest project up — api and web first, then root.

Other changes

Validation

prek run --all-files and prek run --files <…> were exercised against representative files from each project to confirm scoping is correct:

Edited file Hooks that run Hooks that skip
api/src/app/features/.../*.py ruff, ruff-format, generate-openapi-spec, root checks biome, generate-api-client-from-spec
api/tests/conftest.py ruff, ruff-format, root .py parser generate-openapi-spec (outside trigger pattern)
web/src/App.tsx biome, root whitespace/EOL ruff, openapi hooks
web/package.json biome, check-json, whitespace ruff, openapi hooks
api/.openapi.json generate-api-client-from-spec, check-json ruff, generate-openapi-spec
README.md only root whitespace/EOL/line-ending hooks everything else

Migration for contributors

Install prek (any of: mise install, uv tool install prek, pip install prek, brew install prek) and run prek install once to register the git hooks. The project's .pre-commit-config.yaml files work unchanged with the legacy pre-commit CLI as well, so no flag day required.

@einarwar einarwar requested a review from a team as a code owner May 4, 2026 13:29
@einarwar einarwar requested a review from Copilot May 4, 2026 13:30
@einarwar einarwar linked an issue May 4, 2026 that may be closed by this pull request
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.
@einarwar einarwar force-pushed the chore/migrate-to-prek branch from 763fc5a to 3521ecb Compare May 4, 2026 13:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.useIgnoreFile to 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.

Comment thread web/.pre-commit-config.yaml
Comment thread docs/docs/contribute/development-guide/01-setup.md Outdated
Comment thread .github/workflows/linting-and-checks.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update CI workflow (tests.yaml) to reflect pre-commit

2 participants