Seed pre-commit .env from committed .env.example #302
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pre-commit-clean-clone"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
just pre-commitdepends on theensure-envrecipe, which ran@test -f .env || cp .env.dev .env..env.devwas never committed (only.env.exampleis tracked), so on a clean clone the copy failed withcp: cannot stat '.env.dev': No such file or directoryand 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
.envfrom the committed.env.exampleinstead 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.ymlat parse time, and several${VAR:?...}guards reference variables that previously lived only in the uncommitted.env.dev. Even thoughpre-commitruns 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.exampleto satisfy them:MOKOSH_PORT, theINFISICAL_*set (PG_DB/PG_USER/PG_PASSWORD,DB_CONNECTION_URI,REDIS_URL,SITE_URL,TELEMETRY_ENABLED,ENCRYPTION_KEY,AUTH_SECRET), and non-emptyGOOGLE_OAUTH_CLIENT_ID/GOOGLE_OAUTH_CLIENT_SECRETplaceholders. 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-commitfrom a clean state (no.envpresent) on the branch. All five stages (fmt, clippy with-D warnings, check, unit tests, doc tests) ran to completion and the recipe printed:#DEV-370
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