ci(molecule): run Molecule from the ci image instead of the runner's venv

Pin molecule and its Docker driver in requirements-dev.txt and bake them,
with the driver's collection, into the ci image. The Molecule job runs
docker run on the pinned ci image with the Docker socket and the checkout
mounted at the same path, as the runner user. A pull request whose pins
differ from the image installs its own pins first, so a core bump runs its
scenarios on the new core. gitea_runner no longer installs the molecule
venv and collections.

Closes #225

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-24 07:14:19 +00:00
1 parent d9be7b7dc8
commit 2e32016c43
25 files changed
+292 -275

No files matched your search

+17 -9
View File
@@ -27,16 +27,24 @@ label_of() {
# 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.
# python3 is the molecule venv's, with PyYAML.
# 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.
remove_instances() {
local names ids
local py='import sys, yaml; print(*(p["name"] for p in yaml.safe_load(open(sys.argv[1]))["platforms"]))'
names="$(python3 -I -c "$py" "$1/molecule.yml")" || return 1
[ -n "$names" ] || return 1
# shellcheck disable=SC2046,SC2086 # names and ids are one word each
ids="$(docker ps -aq $(printf -- '--filter name=^/%s$ ' $names))" || return 1
# shellcheck disable=SC2086
if [ -n "$ids" ]; then docker rm -f $ids >/dev/null || return 1; fi
python3 -I - "$1/molecule.yml" <<'EOF'
import sys
import docker
import yaml
names = [p["name"] for p in yaml.safe_load(open(sys.argv[1]))["platforms"]]
if not names:
sys.exit("no platform names in " + sys.argv[1])
containers = docker.from_env().containers
for name in names:
for container in containers.list(all=True, filters={"name": f"^/{name}$"}):
if container.name == name:
container.remove(force=True)
EOF
}
# Runs scenario $2 into $work/$1/. Its outcome is the rc file, which a lane that died lacks.