The image.yml matrix holds a hand-edited base (MAJOR.MINOR) per image instead of a version. On main, scripts/next_image_version.py compares a checksum of the image's inputs with the inputs-sha256 label of the newest published <base>.N and the job publishes <base>.N+1 when they differ, or builds nothing when they match. A published tag is still never moved. renovate.yml runs live on the successful completion of Images (workflow_run), so the pin pull request opens minutes after a push instead of on the schedule. Removed: bump_image_versions.py and its tests, check_image_versions.py bump, Lint's bump step, Renovate's postUpgradeTasks, and the bot-diff allowance for matrix version lines. Closes #165 Assisted-by: Claude Code:claude-opus-5-5
60 lines
3.8 KiB
Markdown
60 lines
3.8 KiB
Markdown
# Code style
|
|
|
|
Read this before writing or changing a script, a workflow, a hook, a comment or a guidance document.
|
|
Rules for roles are in [roles/AGENTS.md](../../roles/AGENTS.md); rules for scripts, workflows and images
|
|
are in [scripts/AGENTS.md](../../scripts/AGENTS.md), [.gitea/workflows/AGENTS.md](../../.gitea/workflows/AGENTS.md)
|
|
and [images/AGENTS.md](../../images/AGENTS.md); rules for ADRs in [docs/adr/AGENTS.md](../adr/AGENTS.md).
|
|
|
|
Every rule gives its reason and how it is held: by a control (a named hook or check), by review, or
|
|
aspirational (checked by nothing and nobody). Links between the contributor docs are held by review
|
|
until an offline link check exists. The rules bind new and changed lines from the day they land;
|
|
existing content is brought in line by separate issues.
|
|
|
|
## Rules
|
|
|
|
1. **Existing tool first.** Use an Ansible module, a lint rule or a tool's own setting before a
|
|
script. A pull request that adds or grows a script says what it ruled out.
|
|
*Counter-example:* a custom checker for comment or file length. No standard tool measures them for
|
|
YAML or shell, so those limits are held by review (below) rather than by a script of our own.
|
|
*Does not forbid:* a script where no tool does the job, such as the scenario selector.
|
|
*Reason:* every script here is code someone has to review and maintain.
|
|
*Held by:* review.
|
|
2. **One job per file, readable in one sitting.**
|
|
*Counter-example:* `scripts/check_image_versions.py` holds a YAML reader and four checks (pins, job
|
|
containers, labels, the Python pin) in over 700 lines.
|
|
*Does not forbid:* helpers in the file that serve its one job, or a long file that is still one job;
|
|
do not split a file only for its length.
|
|
*Reason:* a reviewer has to hold the whole file in mind to judge a change to it.
|
|
*Held by:* control in part: `ruff` (complexity and function size at its defaults) and `shellcheck`
|
|
hooks; review for the rest.
|
|
3. **A comment gives the reason, in a line or two.**
|
|
*Counter-example:* the header of `scripts/dev-setup.sh`, over twenty lines that mostly restate what
|
|
the code does.
|
|
*Does not forbid:* a usage line, or a reason that takes three lines because it is subtle.
|
|
*Reason:* the code says what it does; only the reason is missing from it.
|
|
*Held by:* review.
|
|
4. **Write for the next reader, not the record.** No incident history, change narration or session
|
|
notes in code, comments or agent context; they go in the commit message or an ADR.
|
|
*Counter-example:* "ci 0.2.26 failed to push" in agent context, a past incident where the reason
|
|
(Cloudflare rejects request bodies over 100 MB) is all a reader needs.
|
|
*Does not forbid:* stating the fact that justifies a rule.
|
|
*Reason:* history in context ages into noise that every later reader pays for.
|
|
*Held by:* review.
|
|
5. **Change only what the task needs.** Unrelated cleanup is a separate pull request.
|
|
*Counter-example:* reformatting a role while fixing a typo in another.
|
|
*Does not forbid:* fixing a line you had to touch anyway.
|
|
*Reason:* a small diff is one a reviewer can read in full.
|
|
*Held by:* review.
|
|
|
|
## Limits and exceptions
|
|
|
|
- **Soft limits: a comment block over 5 lines, a script or workflow over 200 lines, a guidance document
|
|
over 200 lines.** Above one, the pull request says why; nothing fails.
|
|
*Reason:* the numbers prompt a question in review without forcing a split that makes things worse.
|
|
*Held by:* review. This file is the only home of these numbers; a number a tool holds lives in that
|
|
tool's committed config, never in an environment variable.
|
|
- **An exception is explicit and local: an inline suppression with its reason, or one sentence in the
|
|
pull request. Never a global exclude.**
|
|
*Reason:* a reviewer can judge an exception only where it is visible.
|
|
*Held by:* review.
|