ci(molecule): run Molecule in the molecule-controller image
Molecule ran in the ci image, so a ci pin bump for a tool only Lint uses selected every scenario (ADR 0003). The workflow now pins molecule-controller 0.1.0 by digest as CONTROLLER_IMAGE, the hand-made first pin the ADR calls for. - The run script checks /opt/molecule-pins.sha256 and installs requirements-molecule.lock when a pull request changed a pin file. - The selector reads CONTROLLER_IMAGE: a controller pin change selects every scenario; a ci pin bump touches only lint.yml and build.yml, which are on IGNORED, so it selects none. - Tests show requirements-molecule.* selects every scenario and requirements-dev.* none. - Renovate's molecule.yml regex matches CONTROLLER_IMAGE. Closes #434 Assisted-by: Claude Code
This commit is contained in:
1 parent
6e89e4d857
commit
89bd579e87
7 files changed
+58
-32
No files matched your search
@@ -2,10 +2,10 @@
|
||||
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# The Molecule workflow's run inside the ci 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.
|
||||
# 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_ci_image.sh < scenario-dirs
|
||||
set -euo pipefail
|
||||
@@ -13,12 +13,12 @@ set -euo pipefail
|
||||
selected="$(cat)"
|
||||
pins="$AC_ROOT/pins"
|
||||
extra_collections=""
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
echo "The pin files match the ci image; using the baked tools."
|
||||
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 ci image; installing the pinned tools and collections for this run."
|
||||
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-dev.lock -r requirements-dev.txt
|
||||
"$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
|
||||
|
||||
@@ -39,7 +39,7 @@ label_of() {
|
||||
# Removes the scenario's containers by the platform names in its molecule.yml, expanded by molecule's
|
||||
# interpolator, in place of molecule's destroy, which the scenarios leave out: its driver waits about
|
||||
# 5.6 s per scenario for the deletion (about 84 s over 15), and the whole destroy phase measured about
|
||||
# 103 s a full run. The ci image has no docker CLI: python3 is the one molecule runs on, with PyYAML
|
||||
# 103 s a full run. The controller image has no docker CLI: python3 is the one molecule runs on, with PyYAML
|
||||
# and the Docker SDK of molecule's Docker driver.
|
||||
remove_instances() {
|
||||
python3 -I - "$1/molecule.yml" <<'EOF'
|
||||
|
||||
@@ -21,8 +21,8 @@ Only a pull request is narrowed, and only when <base-ref> is given and EVENT_NAM
|
||||
* .gitea/workflows/molecule.yml, when only comments, blank lines (both outside a block
|
||||
scalar such as `run: |`) or the image pins changed: nothing for comments; for
|
||||
MOLECULE_IMAGE or MOLECULE_IMAGE_2604, every scenario whose directory names that variable,
|
||||
or every scenario when a shared molecule file names it; for CI_IMAGE (the tools molecule
|
||||
runs with), every scenario. Any other change to it is "any other file";
|
||||
or every scenario when a shared molecule file names it; for CONTROLLER_IMAGE (the tools
|
||||
molecule runs with), every scenario. Any other change to it is "any other file";
|
||||
* any other file selects every scenario.
|
||||
|
||||
A role uses another when any file under its directory names it as `mortis.kamino.<other>`
|
||||
@@ -120,7 +120,7 @@ IGNORED = (
|
||||
WORKFLOW = ".gitea/workflows/molecule.yml"
|
||||
# The image pins of WORKFLOW, each a `KEY: >-` line followed by its value line, in the shape
|
||||
# Renovate writes.
|
||||
PIN_KEY = re.compile(r"(\s+)(CI_IMAGE|MOLECULE_IMAGE|MOLECULE_IMAGE_2604): >-")
|
||||
PIN_KEY = re.compile(r"(\s+)(CONTROLLER_IMAGE|MOLECULE_IMAGE|MOLECULE_IMAGE_2604): >-")
|
||||
PIN_VALUE = re.compile(
|
||||
r"(\s+)git\.rkdr\.net/mortis/[a-z0-9._-]+:[^@\s]+@sha256:[0-9a-f]{64}"
|
||||
)
|
||||
@@ -331,7 +331,7 @@ def select(all_scenarios, changed, root=".", pins=None):
|
||||
for path in changed:
|
||||
if is_ignored(path):
|
||||
continue
|
||||
if path == WORKFLOW and pins is not None and "CI_IMAGE" not in pins:
|
||||
if path == WORKFLOW and pins is not None and "CONTROLLER_IMAGE" not in pins:
|
||||
image_pins = pins
|
||||
for pin in pins:
|
||||
by_image.update(naming(all_scenarios, pin, root))
|
||||
|
||||
Reference in new issue
Block a user