Pre-commit hooks with prek
The repository uses prek to execute .pre-commit-config.yaml. Hooks catch file hygiene, formatting, lint, and selected browser checks before a commit. They supplement focused Bazel builds/tests; they do not prove compilation, integration behavior, or release readiness.
Install the CI-compatible version
CI currently installs prek==0.3.9. Match that version unless the checked-in workflow and hook configuration are being updated together:
uv tool install 'prek==0.3.9'
Install the Git hook from the repository root:
prek install -f
The hook configuration remains .pre-commit-config.yaml; there is no separate prek configuration file.
Run hooks
Run hooks for the staged files before committing:
prek run
Run every hook against every tracked file only when doing a deliberate repository-wide hygiene check:
prek run --all-files
A full-file run can be slow and can modify files outside the current change. Review resulting modifications and do not include unrelated rewrites.
The configured hooks include:
- file, JSON, YAML, TOML, XML, symlink, conflict, large-file, and private-key checks;
- Markdown lint, Prettier, Vale, and textlint;
actionlintandyamllintfor workflow/configuration changes;shfmtand ShellCheck for shell changes;- Kotlin, Java, and portal lint hooks selected by changed paths;
- focused retail/support Playwright hooks selected by portal source, configuration, or E2E changes.
Portal Playwright hooks
The local Playwright hooks expect the integrated stack to be running. Prepare it before committing a retail or support portal change:
./scripts/local-validation.sh up
./scripts/local-validation.sh smoke browser
prek run
The hook wrapper supplies the local default E2E credentials when E2E_EMAIL and E2E_PASSWORD are unset; explicitly exported values take precedence. CI intentionally skips playwright-retail and playwright-support in its pre-commit job because runtime browser evidence belongs to the dedicated validation lanes.
Bazel validation still applies
After hooks pass, run the owning Bazel targets. For example:
bazel test //apps/websites/portals/retail:test //apps/websites/portals/retail:lint
bazel test //apps/microservices/merchant-api:core_test
Use Testing strategy to choose targets and Local development and manual QA for integrated smoke. A formatting-only hook pass is not sufficient evidence for a behavior change.
CI comparison
.github/workflows/ci-gate.yml installs the pinned prek, disables unauthenticated Bazel remote reporting through a CI-local override, and runs hooks over the pull-request or push diff. A local prek run normally covers staged files, so CI can still catch a changed file that was not staged during an earlier local hook run.
Emergency bypass
Only bypass hooks when an incident procedure explicitly requires an immediate commit:
git commit --no-verify
Record the bypass. Before opening or merging the PR, rerun prek over the affected files (or prek run --all-files when the bypass scope is uncertain), fix its findings, and run the focused Bazel validation. Never treat --no-verify as approval to skip required tests, secret detection, or generated-contract checks.
Do not run prek auto-update as routine setup. Hook revision changes modify the shared repository policy and require their own reviewed change and CI proof.