ci(molecule): select no scenario for a galaxy.yml change, guarded by a load check #357

Merged
Defame1297 merged 1 commits from ci/355-galaxy-yml-ignored into main 2026-11-24 16:40:42 +00:00
Owner

What and why

Closes #355 (decision: #352).

  • galaxy.yml goes on IGNORED in scripts/select_molecule_scenarios.py: a pull request changing only it selects no scenario; with a role change it selects that role's.
  • New guard scripts/check_scenarios_load_checkout.py, run by scripts/run_molecule_in_ci_image.sh on the selected scenarios before they start. For each it builds the environment molecule hands ansible-playbook (molecule's own Config(...).provisioner.env, so a scenario's own env counts), reads the ordered COLLECTIONS_PATHS from ansible-config dump in that environment, puts the scenario's own collections/ directory first (as ansible-playbook does), and fails with the rule as its message unless the first mortis.kamino is this checkout.
  • The rule is in .gitea/workflows/AGENTS.md (Molecule), with the IGNORED rule pointing to it.

Ruled out: ansible-galaxy collection list (its output is sorted, not in search order); a task in every scenario (touches every role, and the issue makes it the fallback); a check of the inherited environment only (the issue asks for molecule's).

The guard anchors on the checkout the script lives in, which in CI is $AC_ROOT/ansible_collections/mortis/kamino. It uses a throwaway ANSIBLE_HOME: if ANSIBLE_COLLECTIONS_PATH were ever unset, it finds no copy and fails rather than passing.

The selector runs from origin/main's copy, so this pull request still runs every scenario; the change applies from the next one.

Verified

  • Which copy a scenario loads: throwaway draft #356 (closed unmerged), its Molecule job. role_path of mortis.kamino.sshd was $AC_ROOT/ansible_collections/mortis/kamino/roles/sshd; COLLECTIONS_PATHS was [$AC_ROOT, /opt/collections]; molecule's install at $ANSIBLE_HOME/collections/... exists but is not on the path.
  • python3 -m unittest discover -s tests/scripts: 244 tests OK (12 skipped without molecule), and with the repository venv's python (molecule 26.11.0, ansible-core 2.22.0): 244 OK, none skipped. The guard's tests cover the checkout first (pass), another copy first, a scenario env putting another copy first, a copy in the scenario's collections/, no copy at all, and naming only the failing scenario.
  • pre-commit run --all-files: passed. ansible-test sanity ran in the pre-push hook.
  • Two review sub-agents (standards and spec) ran on the diff; their findings are addressed in this commit.

Not verified

  • The guard on the real runner: this pull request's own Molecule run (every scenario) is its first run there. Each check takes about 1 to 2 s per scenario locally; the time over a full run is not measured yet.
  • A real galaxy.yml-only pull request selecting nothing: covered by the selector test, not by a CI run, because the selector runs from main.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code

## What and why Closes #355 (decision: #352). - `galaxy.yml` goes on `IGNORED` in `scripts/select_molecule_scenarios.py`: a pull request changing only it selects no scenario; with a role change it selects that role's. - New guard `scripts/check_scenarios_load_checkout.py`, run by `scripts/run_molecule_in_ci_image.sh` on the selected scenarios before they start. For each it builds the environment molecule hands `ansible-playbook` (molecule's own `Config(...).provisioner.env`, so a scenario's own `env` counts), reads the ordered `COLLECTIONS_PATHS` from `ansible-config dump` in that environment, puts the scenario's own `collections/` directory first (as `ansible-playbook` does), and fails with the rule as its message unless the first `mortis.kamino` is this checkout. - The rule is in `.gitea/workflows/AGENTS.md` (Molecule), with the IGNORED rule pointing to it. Ruled out: `ansible-galaxy collection list` (its output is sorted, not in search order); a task in every scenario (touches every role, and the issue makes it the fallback); a check of the inherited environment only (the issue asks for molecule's). The guard anchors on the checkout the script lives in, which in CI is `$AC_ROOT/ansible_collections/mortis/kamino`. It uses a throwaway `ANSIBLE_HOME`: if `ANSIBLE_COLLECTIONS_PATH` were ever unset, it finds no copy and fails rather than passing. The selector runs from `origin/main`'s copy, so this pull request still runs every scenario; the change applies from the next one. ## Verified - Which copy a scenario loads: throwaway draft #356 (closed unmerged), [its Molecule job](https://git.rkdr.net/Mortis/Kamino/actions/runs/5379/jobs/6538). `role_path` of `mortis.kamino.sshd` was `$AC_ROOT/ansible_collections/mortis/kamino/roles/sshd`; `COLLECTIONS_PATHS` was `[$AC_ROOT, /opt/collections]`; molecule's install at `$ANSIBLE_HOME/collections/...` exists but is not on the path. - `python3 -m unittest discover -s tests/scripts`: 244 tests OK (12 skipped without molecule), and with the repository venv's python (molecule 26.11.0, ansible-core 2.22.0): 244 OK, none skipped. The guard's tests cover the checkout first (pass), another copy first, a scenario `env` putting another copy first, a copy in the scenario's `collections/`, no copy at all, and naming only the failing scenario. - `pre-commit run --all-files`: passed. `ansible-test sanity` ran in the pre-push hook. - Two review sub-agents (standards and spec) ran on the diff; their findings are addressed in this commit. ## Not verified - The guard on the real runner: this pull request's own Molecule run (every scenario) is its first run there. Each check takes about 1 to 2 s per scenario locally; the time over a full run is not measured yet. - A real `galaxy.yml`-only pull request selecting nothing: covered by the selector test, not by a CI run, because the selector runs from `main`. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code
Claude added this to the CI velocity (emergency) milestone 2026-11-24 15:57:07 +00:00
Claude added 1 commit 2026-11-24 15:57:07 +00:00
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
03b21a9aef
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
CODEOWNERS rules requested review from Defame1297 2026-11-24 15:57:07 +00:00
Defame1297 approved these changes 2026-11-24 16:40:39 +00:00
Defame1297 merged commit 86b6abf5d9 into main 2026-11-24 16:40:42 +00:00
Defame1297 deleted branch ci/355-galaxy-yml-ignored 2026-11-24 16:40:43 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#357