fix(hooks): run pre-commit cargo in builder image, not runtime app #42

Merged
David merged 1 commit from fix/pre-commit-clean-clone into main 2026-06-18 12:46:57 +02:00
Owner

Problem

On a fresh clone just pre-commit hung until killed instead of running checks. The recipe ran cargo via docker compose -f compose.dev.yml run --rm --no-deps app ..., but the compose app service builds the production runtime stage of oci-build/Dockerfile (FROM alpine:3.21, ENTRYPOINT ["/app/app"], no cargo toolchain). Each cargo ... argument list was passed to the rus server entrypoint, which ignores it and boots Actix on 0.0.0.0:4001. The very first step (cargo fmt --check) started the server and never returned. This is the rus case of DEV-370 (pre-commit not clean-clone-safe).

Fix

Run the pre-commit checks against the rust-builder-musl image (the same builder base the Dockerfile uses), with the working tree and per-user cargo caches mounted, mirroring the working pattern in mokosh-apps. Test secrets are injected with --env, so no .env / ensure-env is needed and the hook is self-contained on a clean clone. Checks unchanged: fmt, clippy (standalone + saas), build (standalone + saas), test --lib (standalone + saas).

Verification

just pre-commit on a clean tree completes green: fmt + clippy + build for both feature sets, 179 standalone unit tests and 111 saas unit tests pass, no server boot.

#DEV-370

## Problem On a fresh clone `just pre-commit` hung until killed instead of running checks. The recipe ran cargo via `docker compose -f compose.dev.yml run --rm --no-deps app ...`, but the compose `app` service builds the production runtime stage of `oci-build/Dockerfile` (`FROM alpine:3.21`, `ENTRYPOINT ["/app/app"]`, no cargo toolchain). Each `cargo ...` argument list was passed to the rus server entrypoint, which ignores it and boots Actix on `0.0.0.0:4001`. The very first step (`cargo fmt --check`) started the server and never returned. This is the `rus` case of DEV-370 (pre-commit not clean-clone-safe). ## Fix Run the pre-commit checks against the `rust-builder-musl` image (the same builder base the Dockerfile uses), with the working tree and per-user cargo caches mounted, mirroring the working pattern in `mokosh-apps`. Test secrets are injected with `--env`, so no `.env` / `ensure-env` is needed and the hook is self-contained on a clean clone. Checks unchanged: fmt, clippy (standalone + saas), build (standalone + saas), `test --lib` (standalone + saas). ## Verification `just pre-commit` on a clean tree completes green: fmt + clippy + build for both feature sets, 179 standalone unit tests and 111 saas unit tests pass, no server boot. #DEV-370
fix(hooks): run pre-commit cargo in builder image, not runtime app
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 49s
Create release / Create release from merged PR (pull_request) Has been skipped
6ef0c286c1
The pre-commit recipe ran cargo via `docker compose run app`, but the compose `app` service builds the production runtime stage (alpine + `ENTRYPOINT ["/app/app"]`, no cargo). Every cargo command was passed as args to the rus server entrypoint, so the first step booted Actix on :4001 and the hook hung until killed instead of running fmt/clippy/build/test. Run the checks against the rust-builder-musl image (the Dockerfile builder base) with the source and per-user cargo caches mounted, mirroring mokosh-apps; test secrets are injected via --env so no .env / ensure-env is required and a fresh clone passes.

#DEV-370

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
David merged commit ab8dbb8550 into main 2026-06-18 12:46:57 +02:00
David deleted branch fix/pre-commit-clean-clone 2026-06-18 12:46:57 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
a8n-tools/rus!42
No description provided.