Each file holds its directory's rules in full: the rule, a one-sentence reason and how it is held (control, review or aspirational). The interim dependency and image section of making-a-change.md moves into scripts/AGENTS.md and images/AGENTS.md; the contributor docs point to the new files. Closes #182 Assisted-by: Claude Code:claude-opus-5-5
104 lines
7.2 KiB
Markdown
104 lines
7.2 KiB
Markdown
# Workflow rules
|
|
|
|
Every rule for the workflows in `.gitea/workflows/`, in full. Each gives its reason (*Why*) and
|
|
how it is held (*Held*): a control names its hook or check; review means a person other than the
|
|
author sees the change before it merges (this directory is under `CODEOWNERS`); aspirational
|
|
means nothing checks it. "Until X (#N) lands" names a change that is planned and its backlog
|
|
issue.
|
|
|
|
## Writing a workflow
|
|
|
|
- **Never `pull_request_target`.** *Why:* it runs a fork's pull request with the base
|
|
repository's secrets and a write token. *Held:* control: the `zizmor` hook.
|
|
- **Pass ref, repository and name values to a script through `env:`; never interpolate
|
|
`${{ github.* }}` into a `run:` block.** *Why:* a branch name is chosen by whoever pushes it,
|
|
and interpolated into a script it becomes shell code. *Held:* control: the `zizmor` hook.
|
|
- **Runner labels are `kamino-docker` and `kamino-molecule` only, and expressions use the
|
|
`github.*` contexts, which Gitea aliases.** *Why:* the jobs of this repository run only on its
|
|
own runners, and actionlint knows no `gitea.*` context. *Held:* control: the `actionlint` hook
|
|
with the label list in `.gitea/actionlint.yaml`.
|
|
- **A step prints no host sizing, address or network detail.** *Why:* job output is readable
|
|
without an account. *Held:* review.
|
|
|
|
## Secrets
|
|
|
|
- **Each secret is referenced by exactly one workflow:** `image.yml` the registry push
|
|
credential, `renovate.yml` the Renovate token, and `release.yml` the release token once that
|
|
workflow exists. No other workflow references `secrets.` except the job token
|
|
(`secrets.GITHUB_TOKEN`). *Why:* a same-repository pull request gets the organisation's
|
|
Actions secrets, so every reference is a way for a branch to reach a credential. *Held:*
|
|
review (`CODEOWNERS`).
|
|
|
|
## Scripts a workflow runs
|
|
|
|
- **Judge scripts:** a script that judges a pull request's own diff runs from `main`'s copy; a
|
|
content or artefact check runs from the pull request's copy. `check_bot_pr_diff.py` (Lint) and
|
|
`select_molecule_scenarios.py` (Molecule) run from `origin/main`; the pull request that adds
|
|
such a script runs its own copy once, with a notice. Exception until #165 removes it:
|
|
`check_image_versions.py bump` (Lint) judges the diff but runs from the pull request's copy.
|
|
*Why:* a pull request that could edit the rules it is judged by could pass by weakening them,
|
|
while a content check must see the content it is given. *Held:* review (`CODEOWNERS`).
|
|
- **A pull request from a `renovate/` branch changes only version, tag, digest and pin lines**
|
|
(tool pins with their lock entries and hashes, hook `rev:` lines, Dockerfile `FROM` tags and
|
|
digests, matrix `version:` lines, `job_image:` pins, consumer image pins).
|
|
*Why:* the bot's minor and patch pull requests automerge, so they must not be able to change
|
|
anything else. *Held:* control: the Lint check's "Check a bot pull request only moves pins"
|
|
step, `scripts/check_bot_pr_diff.py` run from `main`'s copy. The branch name is chosen by the
|
|
pusher, so this constrains only the bot's own pull requests.
|
|
- **Workflows never mention the image namespace this repository's CI must not use** (the string
|
|
is in `scripts/check_image_versions.py`). *Why:* this repository's images are built and pulled
|
|
only under its own organisation's namespace. *Held:* control: the Lint check's "Check image
|
|
pins" step.
|
|
|
|
## Lint and Build
|
|
|
|
- **Lint and Build run in the pinned `ci` image and compare the pin files with the checksums
|
|
baked into it (`/opt/ci-pins.sha256`).** A pull request that changes `requirements-dev.txt`,
|
|
`requirements-dev.lock`, `requirements.yml` or `.pre-commit-config.yaml` takes the slow path,
|
|
which installs the pinned tools and collections. *Why:* a pull request is tested on its own
|
|
pins, and an unchanged one starts in seconds. *Held:* control: the "Check the baked tooling
|
|
against the pins" step.
|
|
- **Triggers:** both run on pull requests to `main`, on push to `main` until #166 removes that
|
|
trigger, and on manual dispatch; Build also runs on `v*` tags, where it checks the tag against
|
|
`galaxy.yml`. *Why:* the tag is what consumers install. *Held:* review.
|
|
|
|
## Molecule
|
|
|
|
- **Molecule runs on every same-repository pull request, Renovate's included, with no path
|
|
filter.** A fork pull request is skipped by the job's `if:`, which is a convenience: a fork
|
|
controls its own workflow file. *Why:* a check that always reports can be required, and a new
|
|
image is tested by its own pin pull request. *Held:* review.
|
|
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
|
|
of the roles it changes and of the roles that use them (any file naming
|
|
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
|
|
changed role with no scenario, and every scenario for any other file. *Why:* a full run takes
|
|
the single runner slot for a long time. *Held:* control: the selector and its tests.
|
|
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
|
|
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
|
|
*Held:* control: a selector test fails a bare or templated name.
|
|
- **A new file outside `roles/<role>/` runs every scenario until it is added to IGNORED, and it
|
|
belongs there only if no scenario reads it.** *Why:* a file a scenario reads but the selector
|
|
ignores would let a breaking change through untested. *Held:* review.
|
|
- **Every scenario runs on a manual dispatch and in the nightly run (04:43 UTC, after
|
|
Renovate's).** A push to `main` that touches the `push:` `paths:` list runs every scenario
|
|
too, until #166 removes that trigger. *Why:* a pull request runs only its selection, so
|
|
drift in the other roles shows up here. *Held:* review.
|
|
- **A new commit cancels the pull request's running Molecule run, and the run step first removes
|
|
the containers a cancelled run left.** Two runs never overlap only because the runner has a
|
|
single slot, and the scenarios' container names are fixed; raising the runner's capacity needs
|
|
per-run container names first (#166). *Why:* a cancelled run is killed before it can destroy
|
|
its instances, and two runs would collide on the same names. *Held:* review.
|
|
- **Molecule tests the pull request's pins, as Lint and Build do.** *Why:* the pull request that
|
|
raises the ansible-core floor must be behaviour-tested on the new core before it automerges.
|
|
*Held:* aspirational until #225 runs Molecule from the `ci` image with the pin comparison
|
|
against `/opt/ci-pins.sha256`; today it runs from the runner's own venv.
|
|
- **Every scenario sets `scenario.test_sequence` to molecule's default minus the leading
|
|
`destroy`;** copy it into a new scenario. *Why:* the workflow clears stale containers first,
|
|
and the molecule state lives in the job's own `ANSIBLE_HOME`, so a killed run leaves none
|
|
behind. *Held:* review.
|
|
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
|
|
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
|
|
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
|
|
[images/AGENTS.md](../../images/AGENTS.md). *Why:* the workflow discovers exactly these and pins
|
|
both images by digest. *Held:* review.
|