Molecule took 5+ minutes because every pull request ran every scenario one after another on the single-slot runner. A pull request now runs only the scenarios of the roles it changes.
scripts/select_molecule_scenarios.py decides, from the diff against origin/main:
a file under roles/<role>/ selects that role's scenarios;
a file on its IGNORED list (docs, changelogs, markdown, other workflows, images/, tooling no scenario reads) selects nothing;
any other file selects everything (galaxy.yml, meta/, extensions/, molecule.yml and so the image pins, the script itself, any new file);
every push to main and every manual dispatch runs everything.
The job stays unconditional, so Molecule can still be a required check. A changed role that exists but has no scenario fails instead of passing with nothing tested.
The workflow runs the selector from the base branch's copy (as lint.yml does for the bot-diff guard), so a pull request cannot edit its own rules. The first pull request that adds it has no base copy yet and uses its own; this pull request also changes molecule.yml, so it runs all scenarios anyway.
Also in this change:
the scenario loop no longer hands molecule the list on stdin (a child that read stdin would have swallowed the remaining scenarios and left the job green), and the step fails if it ran fewer scenarios than were selected;
tests in tests/scripts/test_select_molecule_scenarios.py, including one that fails if a role ever refers to another role, since the selection relies on roles being independent;
CONTRIBUTING.md no longer says Molecule cannot be a required check because of a path filter.
Tradeoff
A scenario a pull request skips is only exercised after merge, by the push to main (and the nightly run in the follow-up pull request). A regression that only shows in a skipped scenario turns main red instead of blocking the pull request. Today the roles do not depend on each other (dependencies: [] everywhere, no cross-role reference), and the new test keeps it that way.
Verified
python3 -m unittest discover -s tests/scripts: 152 tests pass, including the selector's (rules, non-UTF8 and newline file names, deleted role, role without scenario, git failure and empty base ref falling back to all, GIT_DIR isolation).
actionlint (with .gitea/actionlint.yaml), yamllint, REUSE and the pre-commit hooks pass.
Independent review of the diff, whose findings are folded in. The bash step was simulated under bash -e in a throwaway clone.
Not verified
Nothing has run in CI yet. Check this pull request's Molecule log for Running N of 7 scenarios.
BASE_REF is the constant origin/main, as in lint.yml; the workflow only runs for pull requests to main.
A selection of zero scenarios (only ignored files changed) passes green by design.
## What
Molecule took 5+ minutes because every pull request ran every scenario one after another on the single-slot runner. A pull request now runs only the scenarios of the roles it changes.
`scripts/select_molecule_scenarios.py` decides, from the diff against `origin/main`:
- a file under `roles/<role>/` selects that role's scenarios;
- a file on its `IGNORED` list (docs, changelogs, markdown, other workflows, `images/`, tooling no scenario reads) selects nothing;
- **any other file selects everything** (`galaxy.yml`, `meta/`, `extensions/`, `molecule.yml` and so the image pins, the script itself, any new file);
- every push to `main` and every manual dispatch runs everything.
The job stays unconditional, so Molecule can still be a required check. A changed role that exists but has no scenario fails instead of passing with nothing tested.
The workflow runs the selector from the base branch's copy (as `lint.yml` does for the bot-diff guard), so a pull request cannot edit its own rules. The first pull request that adds it has no base copy yet and uses its own; this pull request also changes `molecule.yml`, so it runs all scenarios anyway.
Also in this change:
- the scenario loop no longer hands molecule the list on stdin (a child that read stdin would have swallowed the remaining scenarios and left the job green), and the step fails if it ran fewer scenarios than were selected;
- tests in `tests/scripts/test_select_molecule_scenarios.py`, including one that fails if a role ever refers to another role, since the selection relies on roles being independent;
- `CONTRIBUTING.md` no longer says Molecule cannot be a required check because of a path filter.
## Tradeoff
A scenario a pull request skips is only exercised after merge, by the push to `main` (and the nightly run in the follow-up pull request). A regression that only shows in a skipped scenario turns `main` red instead of blocking the pull request. Today the roles do not depend on each other (`dependencies: []` everywhere, no cross-role reference), and the new test keeps it that way.
## Verified
- `python3 -m unittest discover -s tests/scripts`: 152 tests pass, including the selector's (rules, non-UTF8 and newline file names, deleted role, role without scenario, git failure and empty base ref falling back to all, `GIT_DIR` isolation).
- `actionlint` (with `.gitea/actionlint.yaml`), `yamllint`, REUSE and the pre-commit hooks pass.
- Independent review of the diff, whose findings are folded in. The bash step was simulated under `bash -e` in a throwaway clone.
## Not verified
- Nothing has run in CI yet. Check this pull request's Molecule log for `Running N of 7 scenarios`.
- `BASE_REF` is the constant `origin/main`, as in `lint.yml`; the workflow only runs for pull requests to `main`.
- A selection of zero scenarios (only ignored files changed) passes green by design.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
A pull request now runs the scenarios of the roles it touches, none when it
touches only paths no scenario reads, and everything for any other file, for
every push to main and for manual dispatch. The job stays unconditional so
Molecule can remain a required check.
scripts/select_molecule_scenarios.py makes the choice and is run from the base
branch's copy, so a pull request cannot edit its own rules. A changed role
that exists but has no scenario fails instead of passing with nothing tested.
The scenario loop no longer gives molecule the list as stdin, which a child
could have drained, and fails when it ran fewer scenarios than were selected.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
ansible-test sanity runs pylint over scripts/ and tests/scripts/ too and
rejects a mutable default argument (environ=os.environ) and `_` as a variable
name. main() now takes environ=None and reads os.environ itself, and the tests
name the values they ignore.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
Closing without merging: everything in this pull request landed in main through #117, whose branch contained these commits (it had this branch merged in to carry the pylint fix). The diff against main is empty. The "not verified" list in the description is out of date: the first Molecule run passed in CI, and the post-merge runs on main for #117's merge are the remaining check.
Closing without merging: everything in this pull request landed in `main` through #117, whose branch contained these commits (it had this branch merged in to carry the pylint fix). The diff against `main` is empty. The "not verified" list in the description is out of date: the first Molecule run passed in CI, and the post-merge runs on `main` for #117's merge are the remaining check.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Molecule took 5+ minutes because every pull request ran every scenario one after another on the single-slot runner. A pull request now runs only the scenarios of the roles it changes.
scripts/select_molecule_scenarios.pydecides, from the diff againstorigin/main:roles/<role>/selects that role's scenarios;IGNOREDlist (docs, changelogs, markdown, other workflows,images/, tooling no scenario reads) selects nothing;galaxy.yml,meta/,extensions/,molecule.ymland so the image pins, the script itself, any new file);mainand every manual dispatch runs everything.The job stays unconditional, so Molecule can still be a required check. A changed role that exists but has no scenario fails instead of passing with nothing tested.
The workflow runs the selector from the base branch's copy (as
lint.ymldoes for the bot-diff guard), so a pull request cannot edit its own rules. The first pull request that adds it has no base copy yet and uses its own; this pull request also changesmolecule.yml, so it runs all scenarios anyway.Also in this change:
tests/scripts/test_select_molecule_scenarios.py, including one that fails if a role ever refers to another role, since the selection relies on roles being independent;CONTRIBUTING.mdno longer says Molecule cannot be a required check because of a path filter.Tradeoff
A scenario a pull request skips is only exercised after merge, by the push to
main(and the nightly run in the follow-up pull request). A regression that only shows in a skipped scenario turnsmainred instead of blocking the pull request. Today the roles do not depend on each other (dependencies: []everywhere, no cross-role reference), and the new test keeps it that way.Verified
python3 -m unittest discover -s tests/scripts: 152 tests pass, including the selector's (rules, non-UTF8 and newline file names, deleted role, role without scenario, git failure and empty base ref falling back to all,GIT_DIRisolation).actionlint(with.gitea/actionlint.yaml),yamllint, REUSE and the pre-commit hooks pass.bash -ein a throwaway clone.Not verified
Running N of 7 scenarios.BASE_REFis the constantorigin/main, as inlint.yml; the workflow only runs for pull requests tomain.🤖 Generated with Claude Code
Closing without merging: everything in this pull request landed in
mainthrough #117, whose branch contained these commits (it had this branch merged in to carry the pylint fix). The diff againstmainis empty. The "not verified" list in the description is out of date: the first Molecule run passed in CI, and the post-merge runs onmainfor #117's merge are the remaining check.🤖 Generated with Claude Code
Pull request closed