ci(molecule): skip the Molecule runner when no scenario is selected
A pull request that selects no scenario still took the single Molecule runner slot to pull the controller image, select nothing and exit. The workflow now has three jobs. select runs the selector from main's copy in a job container on kamino-docker, in the molecule-controller pin, and outputs the selected list. scenarios runs it on kamino-molecule and is skipped when the list is empty. result runs always() and is the one job to require: it fails unless select passed and scenarios passed or was skipped for an empty list, because Gitea counts a skipped job as passing. Scheduled and dispatched runs still select every scenario. container.image cannot read env, so the controller pin is written in all three jobs; a test holds the copies equal. The pin moves to 0.1.1, which has git for the select job's checkout. Branch protection must then require "Molecule / Result (pull_request)". Closes #433 Assisted-by: Claude Code
This commit is contained in:
1 parent
492a68395e
commit
2d1f142662
5 files changed
+236
-37
No files matched your search
@@ -72,11 +72,23 @@ issue.
|
||||
## Molecule
|
||||
|
||||
- **Molecule runs on every same-repository pull request, Renovate's included, with no path
|
||||
filter.** A fork pull request is skipped by the job's `if:`, which is a convenience, not a
|
||||
filter.** A fork pull request is skipped by the jobs' shared `if:` guard, which is a convenience, not a
|
||||
boundary: a fork controls its own workflow file. Gitea's approval gate keeps a fork's runs from
|
||||
starting, and the fork rule in [reviewing.md](../../docs/contributing/reviewing.md) keeps it
|
||||
shut. *Why:* a check that always reports can be required, and a new image is tested by its own
|
||||
pin pull request. *Held:* review.
|
||||
- **Molecule has three jobs: `select`, `scenarios` and `result`.** `select` runs the selector in
|
||||
a job container on `kamino-docker`, in the `molecule-controller` pin (never the `ci` pin, whose
|
||||
bumps would then select every scenario), and outputs the selected directories. `scenarios`
|
||||
runs them on `kamino-molecule` and is skipped when the list is empty. `result` (check
|
||||
`Molecule / Result (pull_request)`) is the required check: it runs `if: always()` and fails
|
||||
unless `select` passed and `scenarios` passed or was skipped for an empty list. The
|
||||
controller pin is written in all three jobs, because `container.image` cannot read `env`.
|
||||
*Why:* a pull request that selects nothing takes no Molecule runner slot, and a skipped job
|
||||
counts as passing in Gitea, so only a job that always runs can be required. *Held:* control:
|
||||
`WorkflowJobsTest` in `tests/scripts/test_run_molecule_scenarios.py` for the jobs, runners,
|
||||
guard and result logic, and `test_every_controller_pin_is_the_same` in
|
||||
`tests/scripts/test_select_molecule_scenarios.py` for the pin copies.
|
||||
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
|
||||
of the roles it changes and of the roles that use them (any file naming
|
||||
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
|
||||
|
||||
Reference in new issue
Block a user