Seed pre-commit .env from committed .env.example #302

Merged
vas2000-work merged 2 commits from fix/pre-commit-clean-clone into main 2026-06-18 04:42:00 +02:00
Owner

Root cause

just pre-commit depends on the ensure-env recipe, which ran @test -f .env || cp .env.dev .env. .env.dev was never committed (only .env.example is tracked), so on a clean clone the copy failed with cp: cannot stat '.env.dev': No such file or directory and aborted the whole pre-commit run. This is the mokosh-server instance of umbrella issue DEV-370 (pre-commit recipe fails on a clean checkout).

Fix

Seed .env from the committed .env.example instead of the missing .env.dev: @test -f .env || cp .env.example .env.

A second clean-clone failure surfaced after that change: docker compose interpolates the entire compose.dev.yml at parse time, and several ${VAR:?...} guards reference variables that previously lived only in the uncommitted .env.dev. Even though pre-commit runs with --no-deps (so the infisical and server compose services never start), the parse-time guards still have to resolve. Added committed dev defaults to .env.example to satisfy them: MOKOSH_PORT, the INFISICAL_* set (PG_DB/PG_USER/PG_PASSWORD, DB_CONNECTION_URI, REDIS_URL, SITE_URL, TELEMETRY_ENABLED, ENCRYPTION_KEY, AUTH_SECRET), and non-empty GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRET placeholders. All are clearly-marked dev-only placeholders to rotate before any shared or production use; no new uncommitted file was introduced.

Verification

Ran just pre-commit from a clean state (no .env present) on the branch. All five stages (fmt, clippy with -D warnings, check, unit tests, doc tests) ran to completion and the recipe printed:

[pre-commit] all checks passed

#DEV-370

## Root cause `just pre-commit` depends on the `ensure-env` recipe, which ran `@test -f .env || cp .env.dev .env`. `.env.dev` was never committed (only `.env.example` is tracked), so on a clean clone the copy failed with `cp: cannot stat '.env.dev': No such file or directory` and aborted the whole pre-commit run. This is the mokosh-server instance of umbrella issue DEV-370 (pre-commit recipe fails on a clean checkout). ## Fix Seed `.env` from the committed `.env.example` instead of the missing `.env.dev`: `@test -f .env || cp .env.example .env`. A second clean-clone failure surfaced after that change: docker compose interpolates the entire `compose.dev.yml` at parse time, and several `${VAR:?...}` guards reference variables that previously lived only in the uncommitted `.env.dev`. Even though `pre-commit` runs with `--no-deps` (so the infisical and server compose services never start), the parse-time guards still have to resolve. Added committed dev defaults to `.env.example` to satisfy them: `MOKOSH_PORT`, the `INFISICAL_*` set (`PG_DB`/`PG_USER`/`PG_PASSWORD`, `DB_CONNECTION_URI`, `REDIS_URL`, `SITE_URL`, `TELEMETRY_ENABLED`, `ENCRYPTION_KEY`, `AUTH_SECRET`), and non-empty `GOOGLE_OAUTH_CLIENT_ID` / `GOOGLE_OAUTH_CLIENT_SECRET` placeholders. All are clearly-marked dev-only placeholders to rotate before any shared or production use; no new uncommitted file was introduced. ## Verification Ran `just pre-commit` from a clean state (no `.env` present) on the branch. All five stages (fmt, clippy with `-D warnings`, check, unit tests, doc tests) ran to completion and the recipe printed: ``` [pre-commit] all checks passed ``` #DEV-370
fix(hooks): seed .env from committed .env.example on clean clone
Some checks failed
Check / fmt + clippy + compile + unit/doc tests (pull_request) Failing after 11s
E2E / Playwright against staging (pull_request) Successful in 1m12s
Integration / integration tests (pull_request) Failing after 3m59s
3af2a2431c
The ensure-env recipe (a dependency of pre-commit) ran `cp .env.dev .env`, but .env.dev was never committed (only .env.example is). On a clean clone the copy failed with `cp: cannot stat '.env.dev'`, aborting `just pre-commit`. Seed from the committed .env.example instead so the recipe works on a fresh checkout.

Add the compose-required variables to .env.example so docker compose interpolation (the ${VAR:?...} guards in compose.dev.yml) succeeds at parse time: MOKOSH_PORT, the INFISICAL_* dev defaults (PG_DB/USER/PASSWORD, DB_CONNECTION_URI, REDIS_URL, SITE_URL, TELEMETRY_ENABLED, ENCRYPTION_KEY, AUTH_SECRET), and non-empty GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRET placeholders. Compose interpolates the whole file at parse time, so these must be set even though pre-commit runs with --no-deps and never starts the infisical or server services. All values are clearly-marked dev placeholders to rotate before any shared or production use.

Verified: `just pre-commit` from a clean state now runs fmt, clippy, check, unit tests, and doc tests to completion and prints `[pre-commit] all checks passed`.

#DEV-370
Merge branch 'main' into fix/pre-commit-clean-clone
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 34s
Check / fmt + clippy + compile + unit/doc tests (pull_request) Successful in 1m6s
Integration / integration tests (pull_request) Successful in 3m43s
Create release / Create release from merged PR (pull_request) Has been skipped
ff6111b2f5
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
psa-systems/mokosh-server!302
No description provided.