check_scenarios_load_checkout.py now merges the base config the way molecule's CLI does (its own lookup of .config/molecule/config.yml) and fails a scenario whose merged prerun is not false, naming the base config. Before, it built Config with no base config, so a scenario that turned prerun back on, or a moved base config, slowed every run and nothing failed. Closes #452 Assisted-by: Claude Code
11 KiB
11 KiB
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: thezizmorhook. - Pass ref, repository and name values to a script through
env:; never interpolate${{ github.* }}into arun:block. Why: a branch name is chosen by whoever pushes it, and interpolated into a script it becomes shell code. Held: control: thezizmorhook. - Runner labels are
kamino-dockerandkamino-moleculeonly, and expressions use thegithub.*contexts, which Gitea aliases. Why: the jobs of this repository run only on its own runners, and actionlint knows nogitea.*context. Held: control: theactionlinthook 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.ymlthe registry push credential,renovate.ymlthe Renovate token, andrelease.ymlthe release token once that workflow exists. No other workflow referencessecrets.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) andselect_molecule_scenarios.py(Molecule) run fromorigin/main; the pull request that adds such a script runs its own copy once, with a notice. 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, hookrev:lines, DockerfileFROMtags and digests,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.pyrun frommain'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
ciimage and compare the pin files with the checksums baked into it (/opt/ci-pins.sha256). A pull request that changesrequirements-dev.txt,requirements-dev.lock,requirements.yml,extensions/molecule/requirements.ymlor.pre-commit-config.yamltakes 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. - On the fast path the network is cut by environment:
PIP_NO_INDEX=1, the proxy variables set to a dead local port andno_proxyempty, for every later step except "Test the repository scripts", which unsets them for its fake registry on loopback; the slow path keeps network. Why: a runtime download is a bake-in defect and must fail the job, not silently slow it. Held: control, set by the "Check the baked tooling against the pins" step, for pip, curl, git over HTTPS and Python's urllib or requests (anything honouringPIP_NO_INDEXor the proxy variables); review for a raw socket or a tool that ignores the proxy variables, and for the script tests. - Triggers: both run on pull requests to
mainand on manual dispatch; Build also runs onv*tags, where it checks the tag againstgalaxy.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, not a boundary: a fork controls its own workflow file. Gitea's approval gate keeps a fork's runs from starting, and the fork rule in reviewing.md keeps it shut. 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 namingmortis.kamino.<role>, transitively), none for a diff of only IGNORED paths, a failure for a changed role with no scenario, for a.gitea/workflows/molecule.ymldiff of only comments (outsiderun:scripts) or image pins the scenarios that name a changedMOLECULE_IMAGE*pin (every scenario forCI_IMAGE, or when a shared molecule file names the pin), 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. - Scenarios load
mortis.kaminofrom the checkout, never from an installed copy, sogalaxy.ymlis on IGNORED. Why: the checkout is first onANSIBLE_COLLECTIONS_PATHand the shared base config.config/molecule/config.ymlturns off molecule's install of the collection (prerun: false), so changes togalaxy.yml(release versions,build_ignore) do not change what a scenario runs, and the Build check proves the collection builds; they had caused about a third of full pull request runs and their minutes (#338). Held: control:scripts/check_scenarios_load_checkout.py, whichrun_molecule_in_ci_image.shruns on the selected scenarios before they start, fails the run when the environment molecule givesansible-playbookresolvesmortis.kaminoanywhere else, or whenprerunis not off once the base config is merged as molecule's CLI merges it (a scenario turns it on, or the base config is moved or turns it on). A pull request that selects no scenario runs no check; the next one that does, and the nightly run, catch a change that broke the rule. - 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 (galaxy.ymlonly by the rule above). 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
mainruns no Molecule. 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; every other run has a
concurrency group of its own. Runs may overlap on the runner's Docker daemon: every container
is named and labelled by its run (
KAMINO_RUN_ID). The job first removes labelled containers older than its timeout, which a cancelled run left, and finally its own. The scenarios of one run overlap (scripts/run_molecule_scenarios.sh,MOLECULE_LANESat a time, 2 unless a manual dispatch sets itslanesinput), so no two scenarios may share a platform name. They start longest first by the script's list of last full-run times, an unlisted one first; the logs stay in selection order. A scenario still running at the script's per-scenario limit is stopped and fails. Why: a cancelled run is killed before it can remove its instances, a younger container may belong to a run still going, a long scenario started late sets the end of the run, and a hang that fails alone inside the job timeout still lets every scenario's log print. Held: review; control: the start order bytest_the_longest_scenarios_start_firstand the input byLanesInputTest, both intests/scripts/test_run_molecule_scenarios.py; control: the names and labels by the test thetest_sequencerule below names, and the sweep's age bound equal to the job timeout bytest_the_sweep_spares_containers_younger_than_the_job_timeoutintests/scripts/test_run_molecule_scenarios.py; control: the limit bytest_a_scenario_past_its_time_limit_fails_aloneandtest_the_default_time_limit_is_inside_the_job_timeout, in the same file. - Molecule tests the pull request's pins, as Lint and Build do. It runs molecule in the pinned
ciimage and, when a pin file differs from/opt/ci-pins.sha256, installs the pull request's tools and the collections ofrequirements.ymlandextensions/molecule/requirements.ymlfirst. Why: a pull request that raises the ansible-core floor must run its scenarios on the new core before it automerges. Held: control: the pin comparison inmolecule.yml. - Every scenario sets
scenario.test_sequenceto molecule's default minus bothdestroysteps, with a role scenario'scheckright before and right afterconverge, names each platform${KAMINO_RUN_ID:-local}-<name>and labels itnet.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"in itsmolecule.yml; copy it into a new scenario. Why: the run script removes each scenario's containers by those names as soon as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the label, and the molecule state lives in each scenario's ownANSIBLE_HOMEin the job tree, so a killed run leaves none behind. Held: control:tests/scripts/test_run_molecule_scenarios.pyfails adestroyin a sequence, a role scenario'sconvergewithout acheckon each side, a platform name that is not unique or not per run, a missing label, and a workflow that does not filter by it. - Scenarios live in
roles/*/molecule/*/andextensions/molecule/*/. A role scenario that must pass on Ubuntu 24.04 and 26.04 takesimage: ${MOLECULE_IMAGE}or${MOLECULE_IMAGE_2604}per platform; the image-smoke scenarios are described in images/AGENTS.md. Why: the workflow discovers exactly these and pins both images by digest. Held: review.