ci(molecule): rename the run script after the molecule-controller image

scripts/run_molecule_in_ci_image.sh runs inside the molecule-controller
image, not the ci image, so its name pointed readers at the wrong image.
Its test file and class follow, and every reference is updated. ADR 0003
keeps the old name: it records what that change touched.

main's selector sees the old and the new path (it diffs with
--no-renames) and neither is on IGNORED, so this pull request runs every
scenario through the renamed script of its own checkout.

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-12-02 08:27:57 +00:00
1 parent 08c589e910
commit 3414880d05
7 files changed
+10 -10

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
#
# The Molecule workflow's run inside the molecule-controller image, from the checkout root: when a
# pin file differs from the image's, install the pull request's pins into $AC_ROOT/pins (/opt is not
# writable for the runner user) and put them first, then check that the scenarios on stdin load this
# checkout and run them. CI_BASE_PYTHON is a test seam.
#
# AC_ROOT=<dir holding ansible_collections> scripts/run_molecule_in_controller.sh < scenario-dirs
set -euo pipefail
selected="$(cat)"
pins="$AC_ROOT/pins"
extra_collections=""
if sha256sum --quiet -c /opt/molecule-pins.sha256; then
echo "The pin files match the molecule-controller image; using the baked tools."
else
echo "::warning::a pin file differs from the molecule-controller image; installing the pinned tools and collections for this run."
"${CI_BASE_PYTHON:-/opt/venv/bin/python}" -m venv "$pins/venv"
"$pins/venv/bin/pip" install --quiet --require-hashes -r requirements-molecule.lock -r requirements-molecule.txt
export PATH="$pins/venv/bin:$PATH"
# The target alone on the path, so a baked copy is not taken as already installed.
for req in requirements.yml extensions/molecule/requirements.yml; do
ANSIBLE_COLLECTIONS_PATH="$pins/collections" \
ansible-galaxy collection install --force -r "$req" -p "$pins/collections"
done
extra_collections="$pins/collections:"
fi
ansible --version
molecule --version
# The collection under test first; molecule does not install it again (prerun is off in
# .config/molecule/config.yml, which check_scenarios_load_checkout.py holds).
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
# Facts are not injected as variables (deprecated in ansible-core 2.22, removal scheduled for 2.24, see #364), so a
# role that reads a bare `ansible_<fact>` fails its scenario here instead of in a consumer's inventory.
export ANSIBLE_INJECT_FACT_VARS=False
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"