fix(hooks): fail loudly when compose_service is not a service #25

Open
Claude-Run wants to merge 1 commit from fix/PC-19-compose-service-preflight-check into main
Member

pre-commit-compose already resolves the dev service through compose_service (it stopped hardcoding app in 7397c2a), so a convention-named repo like roci runs its checks with compose_service := "roci". What was still missing is the diagnosis when the name is wrong: docker answers no such service: app, which never mentions that a just variable picks the name, so the reader has nothing to act on and the practical response is git commit --no-verify.

Add _check-compose-service, a private dependency of pre-commit-compose that runs after ensure-env and before _pre-commit-prepare, so the failure lands before any container or host prepare step. It reads docker compose -f compose.dev.yml config --services --no-interpolate and, when compose_service is absent, prints the configured value, the services the file does define, and the variable to set, then exits non-zero. --no-interpolate keeps the guard from failing on an unset .env variable: that is the build step's error to report, not this one's. A non-zero exit from docker itself is not swallowed either, it prints docker's stderr and the exit code.

The recipe joins the check-justfile protected list, so a consumer cannot shadow the guard away.

PC-19 proposed the variable be named dev_service, assuming none existed. It does: compose_service landed in 7397c2a and psa-systems/roci already sets it on its default branch (justfile:26), so renaming would break that repo on its next submodule bump and violates the blast-radius rule that variable changes stay backward compatible. The variable keeps its shipped name; the criterion is met in substance.

Header contract and README no longer state the compose service must be named app; both now name compose_service (default app) as what picks it.

#PC-19

`pre-commit-compose` already resolves the dev service through `compose_service` (it stopped hardcoding `app` in 7397c2a), so a convention-named repo like roci runs its checks with `compose_service := "roci"`. What was still missing is the diagnosis when the name is wrong: docker answers `no such service: app`, which never mentions that a just variable picks the name, so the reader has nothing to act on and the practical response is `git commit --no-verify`. Add `_check-compose-service`, a private dependency of `pre-commit-compose` that runs after `ensure-env` and before `_pre-commit-prepare`, so the failure lands before any container or host prepare step. It reads `docker compose -f compose.dev.yml config --services --no-interpolate` and, when `compose_service` is absent, prints the configured value, the services the file does define, and the variable to set, then exits non-zero. `--no-interpolate` keeps the guard from failing on an unset .env variable: that is the build step's error to report, not this one's. A non-zero exit from docker itself is not swallowed either, it prints docker's stderr and the exit code. The recipe joins the `check-justfile` protected list, so a consumer cannot shadow the guard away. PC-19 proposed the variable be named `dev_service`, assuming none existed. It does: `compose_service` landed in 7397c2a and psa-systems/roci already sets it on its default branch (`justfile:26`), so renaming would break that repo on its next submodule bump and violates the blast-radius rule that variable changes stay backward compatible. The variable keeps its shipped name; the criterion is met in substance. Header contract and README no longer state the compose service must be named `app`; both now name `compose_service` (default `app`) as what picks it. #PC-19
`pre-commit-compose` already resolves the dev service through `compose_service` (it stopped hardcoding `app` in 7397c2a), so a convention-named repo like roci runs its checks with `compose_service := "roci"`. What was still missing is the diagnosis when the name is wrong: docker answers `no such service: app`, which never mentions that a just variable picks the name, so the reader has nothing to act on and the practical response is `git commit --no-verify`.

Add `_check-compose-service`, a private dependency of `pre-commit-compose` that runs after `ensure-env` and before `_pre-commit-prepare`, so the failure lands before any container or host prepare step. It reads `docker compose -f compose.dev.yml config --services --no-interpolate` and, when `compose_service` is absent, prints the configured value, the services the file does define, and the variable to set, then exits non-zero. `--no-interpolate` keeps the guard from failing on an unset .env variable: that is the build step's error to report, not this one's. A non-zero exit from docker itself is not swallowed either, it prints docker's stderr and the exit code.

The recipe joins the `check-justfile` protected list, so a consumer cannot shadow the guard away.

PC-19 proposed the variable be named `dev_service`, assuming none existed. It does: `compose_service` landed in 7397c2a and psa-systems/roci already sets it on its default branch (`justfile:26`), so renaming would break that repo on its next submodule bump and violates the blast-radius rule that variable changes stay backward compatible. The variable keeps its shipped name; the criterion is met in substance.

Header contract and README no longer state the compose service must be named `app`; both now name `compose_service` (default `app`) as what picks it.

#PC-19
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/PC-19-compose-service-preflight-check:fix/PC-19-compose-service-preflight-check
git switch fix/PC-19-compose-service-preflight-check
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
psa-systems/common!25
No description provided.