ci(molecule): run the in-image step from a tested script and list the fifth pin file
Assisted-by: Claude Code
This commit is contained in:
1 parent
2e32016c43
commit
8c52c91dfd
8 files changed
+215
-46
No files matched your search
@@ -53,10 +53,10 @@ issue.
|
||||
|
||||
- **Lint and Build run in the pinned `ci` image and compare the pin files with the checksums
|
||||
baked into it (`/opt/ci-pins.sha256`).** A pull request that changes `requirements-dev.txt`,
|
||||
`requirements-dev.lock`, `requirements.yml` or `.pre-commit-config.yaml` takes the slow path,
|
||||
which installs the pinned tools and collections. *Why:* a pull request is tested on its own
|
||||
pins, and an unchanged one starts in seconds. *Held:* control: the "Check the baked tooling
|
||||
against the pins" step.
|
||||
`requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` or
|
||||
`.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
|
||||
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
|
||||
*Held:* control: the "Check the baked tooling against the pins" step.
|
||||
- **Triggers:** both run on pull requests to `main`, on push to `main` until #166 removes that
|
||||
trigger, and on manual dispatch; Build also runs on `v*` tags, where it checks the tag against
|
||||
`galaxy.yml`. *Why:* the tag is what consumers install. *Held:* review.
|
||||
|
||||
@@ -64,7 +64,8 @@ jobs:
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
echo "The pin files match the ci image; using the baked tools."
|
||||
else
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
"installing the pinned tools for this run."
|
||||
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
fi
|
||||
|
||||
@@ -6,8 +6,8 @@ name: Lint
|
||||
# The tools come from the ci image (images/ci, built by image.yml): the pinned Python
|
||||
# tools of requirements-dev.txt, the collections of requirements.yml and the hook
|
||||
# environments of .pre-commit-config.yaml are baked in. When a PR changes one of those
|
||||
# files the checksum check below fails and the job installs the pinned tools and
|
||||
# collections itself for this run (slower, same result).
|
||||
# files or extensions/molecule/requirements.yml the checksum check below fails and the
|
||||
# job installs the pinned tools and collections itself for this run (slower, same result).
|
||||
on: # yamllint disable-line rule:truthy
|
||||
pull_request:
|
||||
branches:
|
||||
@@ -64,7 +64,8 @@ jobs:
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
echo "The pin files match the ci image; using the baked tools."
|
||||
else
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
"installing the pinned tools and collections for this run."
|
||||
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
# --force: the baked copy of a changed pin is replaced, not kept as "already installed".
|
||||
|
||||
@@ -11,12 +11,11 @@ name: Molecule
|
||||
# own workflow file. So the repository does not accept fork pull requests; the real
|
||||
# condition is that only trusted people can push branches or open pull requests here.
|
||||
#
|
||||
# molecule runs in the pinned ci image, started with `docker run` and the runner's Docker socket,
|
||||
# so the scenario containers it creates run beside it on the runner's daemon; the job tree is
|
||||
# mounted at the same path, so paths molecule hands the daemon resolve. Like Lint and Build, the
|
||||
# job compares the pin files with the image and installs the pull request's pins when they differ.
|
||||
# The test images are pulled by tag and digest (the digest is what is enforced). Bump both here
|
||||
# when image.yml publishes a new ci, molecule-ubuntu2404 or molecule-ubuntu2604 version.
|
||||
# molecule runs in the pinned ci image via `docker run` with the runner's Docker socket, so the
|
||||
# scenario containers start beside it on the runner's daemon; the job tree is mounted at the same
|
||||
# path, so the paths molecule hands the daemon resolve. Like Lint and Build, it installs the pull
|
||||
# request's pins when they differ from the image's. The images are pinned by tag and digest: bump
|
||||
# them here when image.yml publishes a new ci, molecule-ubuntu2404 or molecule-ubuntu2604 version.
|
||||
on: # yamllint disable-line rule:truthy
|
||||
pull_request:
|
||||
branches:
|
||||
@@ -77,7 +76,7 @@ jobs:
|
||||
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
|
||||
MOLECULE_IMAGE_2604: >-
|
||||
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.6@sha256:d7c216b33d18fa8f1ecbfee8795eb4adc867fe5ad8e7a73b7c67effe301cf771
|
||||
# The container molecule runs in, named by the run so the cleanup step finds it.
|
||||
# The container molecule runs in, named and labelled by the run so the cleanup step finds it.
|
||||
RUN_CONTAINER: kamino-molecule-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
steps:
|
||||
- name: Check the Docker daemon
|
||||
@@ -141,39 +140,12 @@ jobs:
|
||||
sock_gid="$(stat -c %g /var/run/docker.sock)"
|
||||
mkdir -p "$ac_root/home"
|
||||
docker run --rm -i --init --name "$RUN_CONTAINER" \
|
||||
--label "net.rkdr.mortis.molecule-run=$RUN_CONTAINER" \
|
||||
--user "$(id -u):$(id -g)" --group-add "$sock_gid" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock -v "$ac_root:$ac_root" -w "$PWD" \
|
||||
-e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \
|
||||
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 \
|
||||
"$CI_IMAGE" bash -c "$(cat <<'EOF'
|
||||
set -euo pipefail
|
||||
selected="$(cat)"
|
||||
# The pull request's own pins when they differ from the image's. /opt is not writable for
|
||||
# this user, so they go to the job tree, first on the paths.
|
||||
pins="$AC_ROOT/pins"
|
||||
collections=""
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
echo "The pin files match the ci 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."
|
||||
/opt/venv/bin/python -m venv "$pins/venv"
|
||||
"$pins/venv/bin/pip" install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.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
|
||||
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"
|
||||
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
|
||||
EOF
|
||||
)" <<< "$selected"
|
||||
"$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
|
||||
|
||||
# A cancelled run can leave the container running when the docker client is killed.
|
||||
- name: Remove the molecule container
|
||||
|
||||
Reference in new issue
Block a user