diff --git a/scripts/run_molecule_in_ci_image.sh b/scripts/run_molecule_in_ci_image.sh index a0b46cb..3b17d85 100755 --- a/scripts/run_molecule_in_ci_image.sh +++ b/scripts/run_molecule_in_ci_image.sh @@ -11,7 +11,7 @@ set -euo pipefail selected="$(cat)" pins="$AC_ROOT/pins" -collections="" +extra_collections="" if sha256sum --quiet -c /opt/ci-pins.sha256; then echo "The pin files match the ci image; using the baked tools." else @@ -24,11 +24,11 @@ else ANSIBLE_COLLECTIONS_PATH="$pins/collections" \ ansible-galaxy collection install --force -r "$req" -p "$pins/collections" done - collections="$pins/collections:" + extra_collections="$pins/collections:" fi ansible --version molecule --version # The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME, # which the run script keeps in the job tree. -export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:$collections/opt/collections" +export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections" exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected" diff --git a/tests/scripts/test_run_molecule_in_ci_image.py b/tests/scripts/test_run_molecule_in_ci_image.py index 2f125d2..2f197f4 100644 --- a/tests/scripts/test_run_molecule_in_ci_image.py +++ b/tests/scripts/test_run_molecule_in_ci_image.py @@ -27,6 +27,7 @@ exit 0 # The base python: `-m venv ` makes a venv whose bin holds a pip stub. PYTHON_STUB = """#!/usr/bin/env bash echo "python args=$*" >> "$STUB_LOG" +[ -n "${STUB_FAIL_python:-}" ] && exit 1 [ "$1 $2" = "-m venv" ] || exit 1 mkdir -p "$3/bin" cp "$STUB_SOURCE" "$3/bin/pip" @@ -124,7 +125,7 @@ class RunMoleculeInCiImageTest(unittest.TestCase): line, ) # The target alone, so a baked copy is not taken as already installed. - self.assertIn(f"acp={self.pins}/collections\n", line + "\n") + self.assertTrue(line.endswith(f"acp={self.pins}/collections"), line) (runner,) = self.calls("runner") self.assertIn(f"path={self.pins}/venv/bin:", runner) self.assertIn( @@ -142,7 +143,7 @@ class RunMoleculeInCiImageTest(unittest.TestCase): ) def test_a_failing_install_fails_the_run(self): - for stub in ("pip", "ansible-galaxy"): + for stub in ("python", "pip", "ansible-galaxy"): with self.subTest(stub=stub): self.log.write_text("") shutil.rmtree(self.pins, True)