ci(molecule): isolate runs per run and drop the push trigger on main

Two Molecule runs could not overlap on one Docker daemon because every
scenario's container name was fixed; only the runner's single slot kept
them apart. Each platform is now named and labelled by KAMINO_RUN_ID
(run id and attempt, "local" outside CI), the run script expands those
names with molecule's own interpolator before removing them, and the
workflow removes its own containers by label and only sweeps labelled
leftovers older than the job timeout, so a run still going is never hit.
Non-pull-request runs get a concurrency group of their own.

Push to main no longer triggers Molecule, Lint or Build: a merged pull
request was already tested, and the nightly and manual Molecule runs
cover every scenario. Build keeps its v* tag trigger.

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Defame1297 committed 2026-11-24 09:35:03 +00:00
1 parent 33fc3fd3a5
commit 96cb9246c6
23 files changed
+223 -160

No files matched your search

+10 -6
View File
@@ -24,19 +24,23 @@ label_of() {
esac
}
# Removes the scenario's containers by the literal platform names in its molecule.yml, in place of
# molecule's destroy, which the scenarios leave out: its driver waits about 5.6 s per scenario for
# the deletion (about 84 s over 15), and the whole destroy phase measured about 103 s a full run.
# The ci image has no docker CLI: python3 is the one molecule runs on, with PyYAML and the Docker
# SDK of molecule's Docker driver.
# Removes the scenario's containers by the platform names in its molecule.yml, expanded as molecule
# expands them (they carry ${KAMINO_RUN_ID}), in place of molecule's destroy, which the scenarios
# leave out: its driver waits about 5.6 s per scenario for the deletion (about 84 s over 15), and
# the whole destroy phase measured about 103 s a full run. The ci image has no docker CLI: python3
# is the one molecule runs on, with molecule, PyYAML and the Docker SDK of molecule's Docker driver.
remove_instances() {
python3 -I - "$1/molecule.yml" <<'EOF'
import os
import sys
import docker
import yaml
from molecule.interpolation import Interpolator, TemplateWithDefaults
names = [p["name"] for p in yaml.safe_load(open(sys.argv[1]))["platforms"]]
with open(sys.argv[1]) as f:
text = Interpolator(TemplateWithDefaults, os.environ).interpolate(f.read())
names = [p["name"] for p in yaml.safe_load(text)["platforms"]]
if not names:
sys.exit("no platform names in " + sys.argv[1])
containers = docker.from_env().containers
+2 -2
View File
@@ -33,7 +33,7 @@ everything.
Every other case runs everything: a push, a manual dispatch, a scheduled run, no <base-ref>, a git
failure.
Narrowing is an optimisation, so any doubt resolves to the full set. The scenarios the
selection skips are not skipped on `main`: the push run after the merge runs them all.
selection skips still run on `main`: the nightly run and a manual dispatch run them all.
A changed role that exists but has no scenario is an error, not an empty selection: a new role
without a molecule scenario, or a deleted or renamed scenario, must not pass Molecule with
@@ -42,7 +42,7 @@ nothing tested. A role whose directory is gone (the role was deleted) selects no
The workflow runs this script from the base branch's copy, not the pull request's, so a pull
request cannot edit the rules it is judged by (the same reason lint.yml runs
check_bot_pr_diff.py from origin/main). No scenario runs the pull request's copy, so this file
is on the IGNORED list: its unit tests test it, and the push run after the merge runs it.
is on the IGNORED list: its unit tests test it, and the nightly run and a manual dispatch run it.
Exit codes: 0 ok (an empty selection from an all-ignored diff is ok), 1 no scenario exists at
all, or a changed role has none, 2 bad usage. Notices go to stderr as `::notice::` lines, with