ci(molecule): run only the image-smoke scenario a pull request changes
Build / build (pull_request) Successful in 20s
Lint / lint (pull_request) Successful in 1m6s
Molecule / molecule (pull_request) Successful in 1s

A file under extensions/molecule/<name>/ ran every scenario, although
only that image-smoke scenario reads it: they test the images, not the
roles. It now selects that scenario only. A shared file such as
extensions/molecule/requirements.yml, or a name that is not a scenario,
still runs everything.

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Defame1297 committed 2026-11-22 21:14:45 +00:00
1 parent b49c953e8d
commit 5c8b8f5342
2 files changed
+56 -11

No files matched your search

@@ -208,7 +208,8 @@ class SelectTest(unittest.TestCase):
"galaxy.yml",
"meta/runtime.yml",
"plugins/modules/x.py",
"extensions/molecule/image-smoke/molecule.yml",
"extensions/molecule/requirements.yml",
"extensions/molecule/gone/molecule.yml",
".gitea/workflows/molecule.yml",
"tests/unit/x.py",
"new_top_level_file",
@@ -217,6 +218,25 @@ class SelectTest(unittest.TestCase):
chosen, _reason = self.select(["roles/docker/tasks/main.yml", path])
self.assertEqual(chosen, ALL, path)
def test_image_smoke_change_selects_only_that_scenario(self):
chosen, reason = self.select(
["extensions/molecule/image-smoke-2604/verify.yml"]
)
self.assertEqual(chosen, ["extensions/molecule/image-smoke-2604"])
self.assertIn("image-smoke-2604", reason)
def test_image_smoke_and_role_changes_combine(self):
chosen, _reason = self.select(
[
"extensions/molecule/image-smoke/converge.yml",
"roles/docker/tasks/main.yml",
]
)
self.assertEqual(
chosen,
["extensions/molecule/image-smoke", "roles/docker/molecule/default"],
)
def test_deleted_role_selects_nothing_of_its_own(self):
chosen, _reason = self.select(["roles/gone/tasks/main.yml"])
self.assertEqual(chosen, [])
@@ -495,7 +515,7 @@ class MainTest(unittest.TestCase):
finally:
os.chdir(cwd)
def test_every_tracked_file_is_ignored_or_selects_everything_or_is_a_role_file(
def test_every_tracked_file_is_ignored_or_selects_everything_or_its_own_scenario(
self,
):
tracked = subprocess.run(
@@ -512,7 +532,12 @@ class MainTest(unittest.TestCase):
if sel.is_ignored(path) or path.startswith("roles/"):
continue
chosen, _reason = sel.select(scenarios, [path], str(REPO))
self.assertEqual(chosen, scenarios, path)
own = "/".join(path.split("/")[:3])
if path.startswith("extensions/molecule/") and own in scenarios:
# A file of one image-smoke scenario selects that scenario only.
self.assertEqual(chosen, [own], path)
else:
self.assertEqual(chosen, scenarios, path)
def test_roles_call_each_other_by_full_name_only(self):
# The selection finds a role's users by the text mortis.kamino.<role> (users()). A use