ci(molecule): select no scenario for a galaxy.yml change, guarded by a load check
Build / build (pull_request) Successful in 15s
Lint / lint (pull_request) Successful in 1m7s
Molecule / molecule (pull_request) Successful in 15m19s

Scenarios load mortis.kamino from the checkout, not the copy molecule installs from
galaxy.yml, so galaxy.yml goes on the selector's IGNORED list. A new check, run by
run_molecule_in_ci_image.sh before the scenarios, fails the run when the environment
molecule gives ansible-playbook would resolve the collection anywhere else.

Closes #355

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-24 15:56:27 +00:00
1 parent fcd331be06
commit 03b21a9aef
7 files changed
+274 -5

No files matched your search

@@ -33,6 +33,13 @@ mkdir -p "$3/bin"
cp "$STUB_SOURCE" "$3/bin/pip"
"""
# The python that runs the load check: records its arguments, paths and stdin.
CHECK_STUB = """#!/usr/bin/env bash
echo "python3 args=$* acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
[ -n "${STUB_FAIL_check:-}" ] && exit 1
exit 0
"""
# The scenario runner: records its arguments, paths and stdin.
RUNNER_STUB = """#!/usr/bin/env bash
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
@@ -57,6 +64,8 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
stub.chmod(0o755)
for name in ("sha256sum", "ansible-galaxy", "ansible", "molecule"):
shutil.copy(stub, bin_dir / name)
(bin_dir / "python3").write_text(CHECK_STUB)
(bin_dir / "python3").chmod(0o755)
python = self.tmp / "python"
python.write_text(PYTHON_STUB)
python.chmod(0o755)
@@ -142,6 +151,25 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
runner,
)
def test_the_load_check_sees_the_selection_and_the_final_path(self):
selection = "roles/alpha/molecule/default\nextensions/molecule/image-smoke\n"
result = self.run_script(selection, STUB_FAIL_sha256sum="1")
self.assertEqual(result.returncode, 0, result.stderr)
(check,) = self.calls("python3")
self.assertIn("args=-I scripts/check_scenarios_load_checkout.py ", check)
self.assertIn(
f"acp={self.ac_root}:{self.pins}/collections:/opt/collections ", check
)
self.assertIn(
"stdin=[roles/alpha/molecule/default extensions/molecule/image-smoke ]",
check,
)
def test_a_failing_load_check_runs_no_scenario(self):
result = self.run_script(STUB_FAIL_check="1")
self.assertNotEqual(result.returncode, 0)
self.assertEqual(self.calls("runner"), [])
def test_a_failing_install_fails_the_run(self):
for stub in ("python", "pip", "ansible-galaxy"):
with self.subTest(stub=stub):