Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22f5bc33e9 | ||
|
|
a48cd063ea | ||
|
|
6fee0ea8b2 | ||
|
|
39ec8e5b3c | ||
|
|
3414880d05 | ||
|
|
08c589e910 | ||
|
|
476239b119 | ||
|
|
e4039871a6 | ||
|
|
69ed7776b0 | ||
|
|
479efe1ddc | ||
|
|
2d1f142662 | ||
|
|
12cc3b8ef4 | ||
|
|
492a68395e | ||
|
|
75f9d27329 | ||
|
|
2ad2fe6060 | ||
|
|
70adc0de29 | ||
|
|
5fd5d63984 | ||
|
|
bdf2cd8e59 | ||
|
|
25c9772726 | ||
|
|
91cc633665 | ||
|
|
4db1a2b3c9 | ||
|
|
89bd579e87 |
No files matched your search
@@ -16,7 +16,7 @@ provisioner:
|
||||
defaults:
|
||||
# Gather each host's facts once per playbook run, not in every play.
|
||||
gathering: smart
|
||||
# Per-task timings, to see what a scenario's time goes to; ansible.posix is in the ci image
|
||||
# Per-task timings, to see what a scenario's time goes to; ansible.posix is in the molecule-controller image
|
||||
# and in requirements.yml, so the controller always has these callbacks.
|
||||
callbacks_enabled: ansible.posix.profile_tasks, ansible.posix.timer
|
||||
callback_profile_tasks:
|
||||
|
||||
+29
-11
@@ -53,8 +53,8 @@ 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`, `extensions/molecule/requirements.yml` or
|
||||
`.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
|
||||
`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.
|
||||
- **On the fast path the network is cut by environment**: `PIP_NO_INDEX=1`, the proxy variables
|
||||
@@ -72,19 +72,33 @@ 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, or `none`.
|
||||
`scenarios` runs them on `kamino-molecule` and is skipped for `none` or an empty output.
|
||||
`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
|
||||
`none`, so a lost output fails it. 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
|
||||
changed role with no scenario, for a `.gitea/workflows/molecule.yml` diff of only comments
|
||||
(outside `run:` scripts) or image pins the scenarios that name a changed `MOLECULE_IMAGE*` pin
|
||||
(every scenario for `CI_IMAGE`, or when a shared molecule file names the pin), and every
|
||||
scenario for any other file. *Why:* a full run takes
|
||||
the single runner slot for a long time. *Held:* control: the selector and its tests.
|
||||
(every scenario for `CONTROLLER_IMAGE`, or when a shared molecule file names the pin), and every
|
||||
scenario for any other file, `requirements-molecule.*` included; `requirements-dev.*`, and
|
||||
`lint.yml` and `build.yml` with their `ci` pins, are on IGNORED. *Why:* a full run takes the
|
||||
single runner slot for a long time. *Held:* control: the selector and its tests.
|
||||
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
|
||||
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
|
||||
*Held:* control: a selector test fails a bare or templated name.
|
||||
@@ -95,7 +109,7 @@ issue.
|
||||
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check
|
||||
proves the collection builds; they had caused about a third of full pull request runs and their
|
||||
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
|
||||
`run_molecule_in_ci_image.sh` runs on the selected scenarios before they start, fails the run
|
||||
`run_molecule_in_controller.sh` runs on the selected scenarios before they start, fails the run
|
||||
when the environment molecule gives `ansible-playbook` resolves `mortis.kamino` anywhere else,
|
||||
or when `prerun` is not off once the base config is merged as molecule's CLI merges it (a
|
||||
scenario turns it on, or the base config is moved or turns it on).
|
||||
@@ -127,10 +141,14 @@ issue.
|
||||
`test_a_scenario_past_its_time_limit_fails_alone` and
|
||||
`test_the_default_time_limit_is_inside_the_job_timeout`, in the same file.
|
||||
- **Molecule tests the pull request's pins, as Lint and Build do.** It runs molecule in the pinned
|
||||
`ci` image and, when a pin file differs from `/opt/ci-pins.sha256`, installs the pull request's
|
||||
tools and the collections of `requirements.yml` and `extensions/molecule/requirements.yml` first.
|
||||
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
|
||||
before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
|
||||
`molecule-controller` image ([ADR 0003](../../docs/adr/0003-molecule-controller-image.md)) and,
|
||||
when a pin file differs from `/opt/molecule-pins.sha256`, installs the pull request's tools from
|
||||
`requirements-molecule.lock` and the collections of `requirements.yml` and
|
||||
`extensions/molecule/requirements.yml` first. A change to `requirements-molecule.txt` or
|
||||
`requirements-molecule.lock` selects every scenario; `requirements-dev.*` pins only Lint's tools
|
||||
and selects none. *Why:* a pull request that bumps ansible-core or molecule must run its
|
||||
scenarios on them before it automerges. *Held:* control: the pin comparison in
|
||||
`run_molecule_in_controller.sh`, and the selector's tests for which pin files select what.
|
||||
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
|
||||
steps, with a role scenario's `check` right before and right after `converge`, names each
|
||||
platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
|
||||
|
||||
@@ -66,8 +66,8 @@ jobs:
|
||||
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
|
||||
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
|
||||
else
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, 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
|
||||
|
||||
@@ -39,15 +39,15 @@ on: # yamllint disable-line rule:truthy
|
||||
- main
|
||||
paths:
|
||||
- 'images/**'
|
||||
# The ci image bakes these files' contents in (images/ci/Dockerfile).
|
||||
# The ci image bakes these files' contents in (images/ci/Dockerfile); requirements.yml too.
|
||||
- 'requirements-dev.txt'
|
||||
- 'requirements-dev.lock'
|
||||
- 'requirements.yml'
|
||||
- 'extensions/molecule/requirements.yml'
|
||||
- '.pre-commit-config.yaml'
|
||||
# The molecule-controller image bakes these (images/molecule-controller/Dockerfile).
|
||||
# The molecule-controller image bakes these, and requirements.yml (its Dockerfile).
|
||||
- 'requirements-molecule.txt'
|
||||
- 'requirements-molecule.lock'
|
||||
- 'extensions/molecule/requirements.yml'
|
||||
- '.gitea/workflows/image.yml'
|
||||
workflow_dispatch: {}
|
||||
|
||||
|
||||
@@ -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 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).
|
||||
# files 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:
|
||||
@@ -65,8 +65,8 @@ jobs:
|
||||
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
|
||||
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
|
||||
else
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, 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".
|
||||
|
||||
+124
-34
@@ -4,18 +4,25 @@ name: Molecule
|
||||
# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke and
|
||||
# image-smoke-2604 test the test images themselves, so they run even before any role exists.
|
||||
#
|
||||
# It runs on the `kamino-molecule` label, a host executor that uses the runner's own
|
||||
# Docker daemon; no job container is given the Docker socket. That makes the job
|
||||
# Three jobs, so that a pull request that selects no scenario takes no Molecule runner slot:
|
||||
# `select` chooses the scenarios in a job container on `kamino-docker`; `scenarios` runs them on
|
||||
# `kamino-molecule`, and is skipped when none is selected; `result` is the required check and
|
||||
# passes only when `select` passed and `scenarios` passed or was skipped for an empty selection.
|
||||
#
|
||||
# The scenarios job runs on the `kamino-molecule` label, a host executor that uses the runner's
|
||||
# own Docker daemon; no job container is given the Docker socket. That makes the job
|
||||
# root-equivalent on the runner, which is disposable and holds no secret from outside
|
||||
# this repository. The `if:` guard is a convenience filter, not a boundary: a fork controls its
|
||||
# own workflow file. The boundaries are write access, which only trusted people have, and Gitea's
|
||||
# approval gate on fork runs, which the fork rule in docs/contributing/reviewing.md keeps shut.
|
||||
#
|
||||
# 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.
|
||||
# molecule runs in the pinned molecule-controller 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 molecule-controller, molecule-ubuntu2404 or
|
||||
# molecule-ubuntu2604 version. The molecule-controller pin is written three times, because
|
||||
# `container.image` cannot read `env`; a script test holds the copies equal.
|
||||
on: # yamllint disable-line rule:truthy
|
||||
pull_request:
|
||||
branches:
|
||||
@@ -43,23 +50,91 @@ concurrency:
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
molecule:
|
||||
select:
|
||||
# Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new
|
||||
# image); the nightly run and a manual dispatch always run. No paths filter on pull requests, so
|
||||
# that Molecule can be a required check: a required check that a pull request never starts would
|
||||
# block it. A fork pull request is skipped by the guard below.
|
||||
# block it. A fork pull request is skipped by the guard below, which all three jobs share.
|
||||
if: >-
|
||||
github.repository == 'mortis/kamino' &&
|
||||
(github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: kamino-docker
|
||||
timeout-minutes: 10
|
||||
# The molecule-controller pin, as CONTROLLER_IMAGE below: a ci pin here would make every ci
|
||||
# bump select every scenario (ADR 0003).
|
||||
container:
|
||||
image: git.rkdr.net/mortis/molecule-controller:0.1.1@sha256:94af071ecae858016f9a61afa6e45f8344f8fef7d22d1fe899e05f5f48f756e8
|
||||
outputs:
|
||||
scenarios: ${{ steps.select.outputs.scenarios }}
|
||||
steps:
|
||||
# The selector's diff needs origin/main and the full history, so a clone, not a fetch of HEAD.
|
||||
- name: Checkout the commit under test
|
||||
env:
|
||||
GIT_CONFIG_COUNT: "1"
|
||||
GIT_CONFIG_KEY_0: http.extraheader
|
||||
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
|
||||
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
REF: ${{ github.ref }}
|
||||
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
||||
run: |
|
||||
rm -rf ac
|
||||
mkdir -p ac/ansible_collections/mortis
|
||||
git clone "$REPO_URL" ac/ansible_collections/mortis/kamino
|
||||
cd ac/ansible_collections/mortis/kamino
|
||||
# A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch.
|
||||
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
|
||||
echo "Checked out $(git rev-parse HEAD)"
|
||||
|
||||
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
|
||||
# explains the rules); the nightly run and a manual dispatch run all of them, because the
|
||||
# selector narrows only when EVENT_NAME is pull_request.
|
||||
- name: Select the scenarios
|
||||
id: select
|
||||
working-directory: ac/ansible_collections/mortis/kamino
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
# The workflow only runs for pull requests to main; lint.yml uses the same constant.
|
||||
BASE_REF: origin/main
|
||||
run: |
|
||||
# The selector comes from the base branch, so a pull request cannot edit the rules it is
|
||||
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
|
||||
# adds it has no base copy yet and uses its own.
|
||||
sel=scripts/select_molecule_scenarios.py
|
||||
if git cat-file -e "$BASE_REF:$sel" 2>/dev/null; then
|
||||
sel_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$sel_dir"' EXIT
|
||||
git show "$BASE_REF:$sel" > "$sel_dir/select.py"
|
||||
sel="$sel_dir/select.py"
|
||||
else
|
||||
echo "::notice::no base copy of $sel; running this checkout's copy"
|
||||
fi
|
||||
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
|
||||
# `none` marks an empty selection, so a lost or empty output fails result, never passes.
|
||||
if [ -z "$selected" ]; then selected=none; fi
|
||||
# One directory per line; a random delimiter, so no line of the list can end the value.
|
||||
delim="scenarios-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"
|
||||
printf 'scenarios<<%s\n%s\n%s\n' "$delim" "$selected" "$delim" >> "$GITHUB_OUTPUT"
|
||||
|
||||
scenarios:
|
||||
needs: select
|
||||
# Skipped, not failed, when select fails, selects nothing (`none`) or loses its output (empty);
|
||||
# result passes only the second.
|
||||
if: >-
|
||||
needs.select.outputs.scenarios != 'none' &&
|
||||
needs.select.outputs.scenarios != '' &&
|
||||
github.repository == 'mortis/kamino' &&
|
||||
(github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: [kamino-molecule]
|
||||
# A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the
|
||||
# age past which the sweep step removes a run's containers; a script test holds the two equal.
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
# The tools and collections molecule runs with: the image Lint and Build use.
|
||||
CI_IMAGE: >-
|
||||
git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
# The tools and collections molecule runs with, apart from Lint's (ADR 0003), so a tool
|
||||
# bump only Lint uses selects no scenario.
|
||||
CONTROLLER_IMAGE: >-
|
||||
git.rkdr.net/mortis/molecule-controller:0.1.1@sha256:94af071ecae858016f9a61afa6e45f8344f8fef7d22d1fe899e05f5f48f756e8
|
||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||
# one locally.
|
||||
MOLECULE_IMAGE: >-
|
||||
@@ -119,33 +194,15 @@ jobs:
|
||||
for id in $old; do left="$left$(docker ps -aq --filter "id=$id")"; done
|
||||
if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi
|
||||
|
||||
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
|
||||
# explains the rules); the nightly run and a manual dispatch run all of them, a few at a time.
|
||||
# scripts/run_molecule_scenarios.sh runs them and removes each scenario's containers as soon as
|
||||
# it ends.
|
||||
# scripts/run_molecule_scenarios.sh runs the selected scenarios, a few at a time, and removes
|
||||
# each scenario's containers as soon as it ends.
|
||||
- name: Run the scenarios
|
||||
working-directory: ac/ansible_collections/mortis/kamino
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
# The workflow only runs for pull requests to main; lint.yml uses the same constant.
|
||||
BASE_REF: origin/main
|
||||
SELECTED: ${{ needs.select.outputs.scenarios }}
|
||||
# Empty outside a dispatch, which the run script reads as its default.
|
||||
MOLECULE_LANES: ${{ inputs.lanes }}
|
||||
run: |
|
||||
# The selector comes from the base branch, so a pull request cannot edit the rules it is
|
||||
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
|
||||
# adds it has no base copy yet and uses its own.
|
||||
sel=scripts/select_molecule_scenarios.py
|
||||
if git cat-file -e "$BASE_REF:$sel" 2>/dev/null; then
|
||||
sel_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$sel_dir"' EXIT
|
||||
git show "$BASE_REF:$sel" > "$sel_dir/select.py"
|
||||
sel="$sel_dir/select.py"
|
||||
else
|
||||
echo "::notice::no base copy of $sel; running this checkout's copy"
|
||||
fi
|
||||
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
|
||||
|
||||
# As the runner user, with the socket's group, so nothing in the job tree is left root-owned.
|
||||
# HOME (ansible's temp and caches) is in the job tree; a mounted passwd entry points the user
|
||||
# at it, because ansible's temp path is `~<user>/.ansible/tmp`. The driver's connection plugin
|
||||
@@ -163,7 +220,7 @@ jobs:
|
||||
-v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \
|
||||
-e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \
|
||||
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID -e MOLECULE_LANES \
|
||||
"$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
|
||||
"$CONTROLLER_IMAGE" scripts/run_molecule_in_controller.sh <<< "$SELECTED"
|
||||
|
||||
# A cancelled run can leave its containers running when the docker client is killed.
|
||||
- name: Remove this run's containers
|
||||
@@ -176,3 +233,36 @@ jobs:
|
||||
for id in $ids; do docker rm -f "$id" >/dev/null || true; done
|
||||
left="$(docker ps -aq --filter "label=net.rkdr.mortis.molecule-run=$KAMINO_RUN_ID")"
|
||||
if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi
|
||||
|
||||
result:
|
||||
name: Result
|
||||
needs: [select, scenarios]
|
||||
# always(): otherwise a failed select would skip this job, and Gitea counts a skipped job as
|
||||
# passing. The guard is select's, so a fork pull request skips all three jobs alike and the run
|
||||
# step below never sees a select skipped by it.
|
||||
if: >-
|
||||
always() &&
|
||||
github.repository == 'mortis/kamino' &&
|
||||
(github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: kamino-docker
|
||||
timeout-minutes: 5
|
||||
# The controller pin again, so this job adds no pin of its own to bump.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/molecule-controller:0.1.1@sha256:94af071ecae858016f9a61afa6e45f8344f8fef7d22d1fe899e05f5f48f756e8
|
||||
steps:
|
||||
- name: Check the select and scenarios jobs
|
||||
env:
|
||||
SELECT_RESULT: ${{ needs.select.result }}
|
||||
SCENARIOS_RESULT: ${{ needs.scenarios.result }}
|
||||
SELECTED: ${{ needs.select.outputs.scenarios }}
|
||||
run: |
|
||||
if [ "$SELECT_RESULT" != success ]; then
|
||||
echo "::error::select ended as $SELECT_RESULT"; exit 1
|
||||
fi
|
||||
# A skip is a pass only for select's `none`: an empty output means it was lost.
|
||||
if [ "$SCENARIOS_RESULT" = skipped ] && [ "$SELECTED" = none ]; then
|
||||
echo "No scenario selected."
|
||||
elif [ "$SCENARIOS_RESULT" != success ]; then
|
||||
echo "::error::scenarios ended as $SCENARIOS_RESULT"; exit 1
|
||||
fi
|
||||
+12
-9
@@ -113,13 +113,16 @@ reduction. A later decision that accepts a risk adds an entry here.
|
||||
|
||||
### Pin bumps first behaviour-tested after they merge
|
||||
|
||||
- **Risk:** Lint, Build and Molecule install a pull request's pins when they differ from the
|
||||
image, so a pull request that changes an image input is tested on its own pins. But most pin
|
||||
bumps select no Molecule scenario: every Python pin except an ansible-core minor bump, which
|
||||
edits `meta/runtime.yml`. Such a bump is first behaviour-tested after it has merged, by the
|
||||
pull request that moves the workflows to the new `ci` image.
|
||||
- **Why accepted:** that pull request runs every scenario before the new image is used,
|
||||
and running every scenario on every Python pin bump would cost about 10 minutes each.
|
||||
- **Trigger:** the pull request that moves the workflows to a new `ci` image fails Molecule
|
||||
because of a bumped pin.
|
||||
- **Risk:** Lint, Build and Molecule install a pull request's pins when they differ from their
|
||||
image, and a change to `requirements-molecule.*`, `requirements.yml` or
|
||||
`extensions/molecule/requirements.yml` selects every Molecule scenario, so Molecule's own tools
|
||||
and collections are tested before they merge. A change to the `molecule-controller` Dockerfile
|
||||
(its base image, uv or Python) selects none, because `images/` is on the selector's IGNORED
|
||||
list; it is first behaviour-tested after it has merged, by the pull request that moves
|
||||
`molecule.yml` to the new `molecule-controller` version. `requirements-dev.*` pins only Lint's
|
||||
and Build's tools, which no scenario runs.
|
||||
- **Why accepted:** that pull request runs every scenario before the new image is used, and the
|
||||
Dockerfile's self-checks fail the build on `main` before any pin moves.
|
||||
- **Trigger:** the pull request that moves `molecule.yml` to a new `molecule-controller` image
|
||||
fails Molecule because of a changed image input.
|
||||
- **Planned reduction:** none for now.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
trivial:
|
||||
- >-
|
||||
ufw - The check-mode probes read whether a command ran instead of whether it was skipped, which
|
||||
ansible-core 2.25 stops reporting for a command in check mode.
|
||||
@@ -56,10 +56,10 @@ Every secret the workflows in [.gitea/workflows/](../../.gitea/workflows/) refer
|
||||
A checklist, not rules: what the repository and organisation settings should be. The maintainer
|
||||
applies them and checks them against this list after any change.
|
||||
|
||||
- Branch protection on `main`: required checks Lint, Build and Molecule; zero required approvals;
|
||||
"Require approval from code owners"; "Dismiss stale approvals"; block on rejected and on official
|
||||
review requests; block on an outdated branch; administrators cannot override; the approvals
|
||||
allowlist is the maintainer.
|
||||
- Branch protection on `main`: required checks Lint, Build and `Molecule / Result (pull_request)`;
|
||||
zero required approvals; "Require approval from code owners"; "Dismiss stale approvals"; block
|
||||
on rejected and on official review requests; block on an outdated branch; administrators cannot
|
||||
override; the approvals allowlist is the maintainer.
|
||||
- Merge allowlist on `main`: the maintainer, each trusted contributor and the Renovate bot.
|
||||
- Push allowlist on `release/*`: the maintainer; no rule for `renovate/*`.
|
||||
- Tag protection on `v*`, with the maintainer on its allowlist.
|
||||
|
||||
+14
-18
@@ -1,20 +1,21 @@
|
||||
# ci
|
||||
|
||||
The **CI tooling image** of the [`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Collection: everything the Lint, Build and
|
||||
Molecule workflows used to install on each run is baked in, so a job only checks out the code and runs.
|
||||
The **CI tooling image** of the [`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Collection: everything the Lint and Build
|
||||
workflows used to install on each run is baked in, so a job only checks out the code and runs. The Molecule workflow
|
||||
runs in the [`molecule-controller`](molecule-controller.md) image instead
|
||||
([ADR 0003](../adr/0003-molecule-controller-image.md)), so a tool bump only Lint uses selects no Molecule scenario.
|
||||
|
||||
## What is in it
|
||||
|
||||
Ubuntu 26.04 with:
|
||||
|
||||
- **Python tools** in `/opt/venv` (on `PATH`; it runs on Python 3.14, the version of `.python-version`, from the baked copy and not from the distribution's `python3`), from `requirements-dev.lock` (the hashed lock of `requirements-dev.txt`, installed with `pip install --require-hashes`): `ansible-core`,
|
||||
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`, `molecule` and
|
||||
`molecule-plugins[docker]` (the Docker driver, with the `docker` Python SDK), and `proxmoxer`, the controller-side
|
||||
library the modules of `community.proxmox` import.
|
||||
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`, `molecule`
|
||||
(without its Docker driver: Lint's "Test the repository scripts" step runs the tests that import it), and
|
||||
`proxmoxer`, the controller-side library the modules of `community.proxmox` import.
|
||||
- **The collections the roles call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it), from
|
||||
`requirements.yml`: `community.general`, `ansible.posix` and `community.proxmox` at the exact versions CI tests against, so
|
||||
`ansible-lint --offline` resolves their modules instead of mocking them; and from
|
||||
`extensions/molecule/requirements.yml`, `community.docker`, which the Molecule Docker driver's own playbooks call.
|
||||
`ansible-lint --offline` resolves their modules instead of mocking them.
|
||||
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
|
||||
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks, actionlint and zizmor. The Go
|
||||
hooks are prebuilt; their toolchains, and the binaries of those repositories that no hook runs, are removed to
|
||||
@@ -26,7 +27,7 @@ Ubuntu 26.04 with:
|
||||
`python3`, so sanity runs its compile test for those interpreters instead of skipping it.
|
||||
- `git`, `shellcheck` (actionlint runs it over `run:` blocks), `python3`, `python3-venv` and `ca-certificates`.
|
||||
The image runs as root and sets no working directory.
|
||||
- `/opt/ci-pins.sha256`: the checksums of the five pin files this image was built from.
|
||||
- `/opt/ci-pins.sha256`: the checksums of the four pin files this image was built from.
|
||||
|
||||
It has no Node, so JavaScript actions (`actions/checkout`) cannot run in it: clone with `git`.
|
||||
|
||||
@@ -59,25 +60,20 @@ jobs:
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
```
|
||||
|
||||
The Molecule job runs on the `kamino-molecule` runner, a host executor, so it starts the image itself with
|
||||
`docker run`, as the runner user, with the Docker socket and the checkout mounted at the same path (molecule
|
||||
hands the daemon paths in the checkout); `scripts/run_molecule_in_ci_image.sh` does the same pin check inside it.
|
||||
Read `.gitea/workflows/molecule.yml` for the full command.
|
||||
|
||||
`/opt/ci-pins.sha256` lists the five pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When
|
||||
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
|
||||
`/opt/ci-pins.sha256` lists the four pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When
|
||||
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
|
||||
collections are used as they are, and Lint and Build cut the network by environment (proxy variables and
|
||||
`PIP_NO_INDEX`) for all but the script tests, so a tool that downloads at run time fails the job. When a pull request changes a pin the check fails and the job installs the pinned
|
||||
tools and collections itself for that run
|
||||
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml`
|
||||
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml` and `gitea-release-key.yml`
|
||||
are the real consumers.
|
||||
|
||||
## Tags and pinning
|
||||
|
||||
- `<version>` is semver, independent of the Collection's version. A published version is never moved or
|
||||
rebuilt, so one digest belongs to exactly one version. `latest` is the newest version, for looking only.
|
||||
- Pin `ci:<version>@sha256:<digest>`; the digest decides what is pulled. Consumers: `lint.yml`, `build.yml`,
|
||||
`molecule.yml` and `gitea-release-key.yml`.
|
||||
- Pin `ci:<version>@sha256:<digest>`; the digest decides what is pulled. Consumers: `lint.yml`, `build.yml` and
|
||||
`gitea-release-key.yml`.
|
||||
- Renovate is configured to move the pins to a new version after the image is built on `main` (the rule is in
|
||||
`renovate.json`; the first pin of a brand-new image is made by hand).
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ Ubuntu 26.04 with:
|
||||
- **The collections the scenarios call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it): those of
|
||||
`requirements.yml` (`community.general`, `ansible.posix`, `community.proxmox`), which the roles call, and of
|
||||
`extensions/molecule/requirements.yml` (`community.docker`), which the Docker driver's own playbooks call.
|
||||
- `python3`, `python3-venv` and `ca-certificates` from the distribution. The image runs as root and sets no
|
||||
- `python3`, `python3-venv`, `ca-certificates` and `git` from the distribution. The image runs as root and sets no
|
||||
working directory.
|
||||
- `/opt/molecule-pins.sha256`: the checksums of the four pin files this image was built from.
|
||||
|
||||
It has no Docker CLI and no `git`: mount the host's Docker CLI and socket, and the checkout.
|
||||
It has no Docker CLI: mount the host's Docker CLI and socket, and the checkout.
|
||||
|
||||
## How to use it
|
||||
|
||||
@@ -32,8 +32,8 @@ checkout). In the checkout root, run `sha256sum --quiet -c /opt/molecule-pins.sh
|
||||
`requirements-molecule.lock`, `requirements.yml` or `extensions/molecule/requirements.yml`, install the pinned tools
|
||||
and collections for that run first (slower, same result), until the image is rebuilt from `main`.
|
||||
|
||||
No workflow consumes it yet; the Molecule workflow still runs in the [`ci`](ci.md) image until its first pin is made
|
||||
by hand.
|
||||
`.gitea/workflows/molecule.yml` is its consumer: it pins the image as `CONTROLLER_IMAGE`, and
|
||||
`scripts/run_molecule_in_controller.sh` runs the pin check inside it. Read the workflow for the full command.
|
||||
|
||||
## Tags and pinning
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ platforms:
|
||||
|
||||
systemd needs a writable cgroup (`cgroupns_mode: host`, the `/sys/fs/cgroup` mount and tmpfs on `/run`), the
|
||||
firewall tools need `NET_ADMIN`, AppArmor is left unconfined for the container (`apparmor=unconfined`), and
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the ci image provides.
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the molecule-controller image provides.
|
||||
|
||||
The scenario `extensions/molecule/image-smoke` tests this image against that contract (release,
|
||||
systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`).
|
||||
|
||||
@@ -50,7 +50,7 @@ platforms:
|
||||
|
||||
systemd needs a writable cgroup (`cgroupns_mode: host`, the `/sys/fs/cgroup` mount and tmpfs on `/run`), the
|
||||
firewall tools need `NET_ADMIN`, AppArmor is left unconfined for the container (`apparmor=unconfined`), and
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the ci image provides.
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the molecule-controller image provides.
|
||||
|
||||
The scenario `extensions/molecule/image-smoke-2604` tests this image against that contract (release,
|
||||
systemd, packages, the `dbus` and `ssh` units, the Python bindings, `NET_ADMIN`).
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Collections the Molecule test harness itself calls, as opposed to the roles under test (those are
|
||||
# in the requirements.yml at the repository root). The Docker driver of molecule-plugins runs
|
||||
# community.docker modules in its own create and destroy playbooks, so every scenario needs it.
|
||||
# The ci image (images/ci) bakes it into /opt/collections next to the root one; a pull request that
|
||||
# changes it fails the image's pin check, so the Molecule job installs it itself.
|
||||
# The molecule-controller image (images/molecule-controller) bakes it into /opt/collections next to the
|
||||
# root one; a pull request that changes it fails the image's pin check, so the Molecule job installs it itself.
|
||||
# Renovate (renovate.json, ansible-galaxy manager) bumps this pin.
|
||||
collections:
|
||||
- name: community.docker
|
||||
|
||||
+3
-3
@@ -25,9 +25,9 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
|
||||
publishes `<base>.N+1` when they differ. Edit `base:` by hand only for a minor or major.
|
||||
*Why:* a version a person must remember to raise is a version someone forgets. *Held:*
|
||||
control: the Images workflow assigns it (`next_image_version.py`, with its tests).
|
||||
- **After the build pushes a new version, a second pull request moves the
|
||||
`image:<version>@sha256:<digest>` pins in `lint.yml`, `build.yml`, `molecule.yml` and
|
||||
`gitea-release-key.yml` to it.** Renovate opens it within minutes: the Images run's successful
|
||||
- **After the build pushes a new version, a second pull request moves its
|
||||
`image:<version>@sha256:<digest>` pins to it:** `ci` in `lint.yml`, `build.yml` and
|
||||
`gitea-release-key.yml`; `molecule-controller` and the `molecule-ubuntu*` images in `molecule.yml`. Renovate opens it within minutes: the Images run's successful
|
||||
completion starts a live Renovate run (`workflow_run` in `renovate.yml`). It changes no image
|
||||
input, so it publishes nothing. A new image's first pin is a hand-made pull request, and a
|
||||
major version is moved by hand. *Why:* consumers run exactly the digest a reviewer saw.
|
||||
|
||||
+16
-20
@@ -1,5 +1,6 @@
|
||||
# CI image for the Lint, Build and Molecule workflows of this Collection: every tool they used
|
||||
# to install on each run is baked in, so a job only checks out the code and runs.
|
||||
# CI image for the Lint and Build workflows of this Collection: every tool they used to install
|
||||
# on each run is baked in, so a job only checks out the code and runs. Molecule runs in the
|
||||
# molecule-controller image (ADR 0003).
|
||||
#
|
||||
# Built by .gitea/workflows/image.yml with kaniko (repository root as build context,
|
||||
# because the pin files below are copied in) and pushed, never on pull requests, to
|
||||
@@ -12,12 +13,13 @@
|
||||
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), the
|
||||
# distribution's python3 and ca-certificates.
|
||||
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
||||
# antsibull-changelog, galaxy-importer, reuse, molecule and its Docker driver, proxmoxer), on the Python of
|
||||
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of
|
||||
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses.
|
||||
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
|
||||
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
|
||||
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
||||
# tested against), found through ANSIBLE_COLLECTIONS_PATH, so `ansible-lint --offline`
|
||||
# resolves their modules without a mock list; and those of extensions/molecule/requirements.yml
|
||||
# (community.docker), which the Molecule Docker driver's own playbooks call.
|
||||
# resolves their modules without a mock list.
|
||||
# - /opt/pre-commit: every hook environment of .pre-commit-config.yaml, installed by
|
||||
# `pre-commit install-hooks` (gitleaks and actionlint are built from source by
|
||||
# pre-commit, which downloads a Go toolchain: that is most of the time saved).
|
||||
@@ -26,8 +28,8 @@
|
||||
# - Python 3.11, 3.13 and PYTHON_VERSION as python<MINOR> on PATH, so that
|
||||
# `ansible-test sanity` runs its compile test for them instead of skipping it.
|
||||
# They come from python-build-standalone through uv, pinned by the uv version.
|
||||
# - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements-dev.lock, requirements.yml,
|
||||
# extensions/molecule/requirements.yml and .pre-commit-config.yaml this image was built from. A job runs
|
||||
# - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements-dev.lock, requirements.yml
|
||||
# and .pre-commit-config.yaml this image was built from. A job runs
|
||||
# `sha256sum -c /opt/ci-pins.sha256` in its checkout; when a pull request changes a
|
||||
# pin the check fails and the job installs the tools as before, until the image
|
||||
# is rebuilt from main.
|
||||
@@ -65,8 +67,6 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
|
||||
WORKDIR /src
|
||||
COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml ./
|
||||
# Kept at its checkout path: its name matches the root requirements.yml.
|
||||
COPY extensions/molecule/requirements.yml extensions/molecule/
|
||||
|
||||
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
|
||||
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
|
||||
@@ -98,13 +98,11 @@ RUN "$(echo /opt/python/cpython-${PYTHON_VERSION}.*/bin/python${PYTHON_VERSION})
|
||||
&& /opt/venv/bin/python --version \
|
||||
&& /opt/venv/bin/pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
|
||||
# The collections of requirements.yml and extensions/molecule/requirements.yml. ANSIBLE_COLLECTIONS_PATH is set to the target for the
|
||||
# The collections of requirements.yml. ANSIBLE_COLLECTIONS_PATH is set to the target for the
|
||||
# install only: a collection found anywhere else on the path would be skipped as "already
|
||||
# installed" and not copied here.
|
||||
RUN ANSIBLE_COLLECTIONS_PATH=/opt/collections \
|
||||
/opt/venv/bin/ansible-galaxy collection install -r requirements.yml -p /opt/collections \
|
||||
&& ANSIBLE_COLLECTIONS_PATH=/opt/collections \
|
||||
/opt/venv/bin/ansible-galaxy collection install -r extensions/molecule/requirements.yml -p /opt/collections \
|
||||
&& du -sh /opt/collections
|
||||
|
||||
# pre-commit needs a git repository to resolve a config. The hook repositories are
|
||||
@@ -177,16 +175,16 @@ FROM os AS final
|
||||
ARG PYTHON_VERSION=3.14
|
||||
|
||||
LABEL org.opencontainers.image.title="ci" \
|
||||
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint, Build and Molecule workflows run in it, so a job only checks out the code and runs. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule with its Docker driver, proxmoxer, the collections of requirements.yml and extensions/molecule/requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \
|
||||
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs; Molecule runs in the molecule-controller image. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule (for the script tests), proxmoxer, the collections of requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \
|
||||
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
|
||||
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
|
||||
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/ci.md" \
|
||||
org.opencontainers.image.licenses="GPL-3.0-or-later" \
|
||||
org.opencontainers.image.authors="Defame1297 and contributors" \
|
||||
org.opencontainers.image.base.name="ubuntu:26.04" \
|
||||
net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint, Build and Molecule workflows run in it, so a job only checks out the code and runs." \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, molecule-plugins[docker], proxmoxer), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \
|
||||
net.rkdr.mortis.usage="Lint and Build: job container on the kamino-docker runner, git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit. Molecule (host executor, kamino-molecule runner): docker run as the runner user, with the Docker socket and the checkout mounted at the same path. In both, run sha256sum -c /opt/ci-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label."
|
||||
net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs." \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), /opt/collections (community.general, ansible.posix, community.proxmox), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \
|
||||
net.rkdr.mortis.usage="Lint and Build: job container on the kamino-docker runner, git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit. Run sha256sum -c /opt/ci-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label."
|
||||
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PRE_COMMIT_HOME=/opt/pre-commit \
|
||||
@@ -202,16 +200,14 @@ COPY --from=build /root/.ansible/test /root/.ansible/test
|
||||
|
||||
# The target interpreters ansible-test looks for on PATH, and the pin record.
|
||||
COPY --from=build /src/requirements-dev.txt /src/requirements-dev.lock /src/requirements.yml /src/.pre-commit-config.yaml /opt/ci-pins/
|
||||
# Under its checkout path, so `sha256sum -c` in a checkout root finds it.
|
||||
COPY --from=build /src/extensions/molecule/requirements.yml /opt/ci-pins/extensions/molecule/
|
||||
RUN set -eu; \
|
||||
for v in $(printf '%s\n' 3.11 3.13 "${PYTHON_VERSION}" | sort -u); do \
|
||||
ln -sf "$(echo /opt/python/cpython-${v}.*/bin/python${v})" "/usr/local/bin/python${v}"; \
|
||||
"python${v}" --version; \
|
||||
done; \
|
||||
cd /opt/ci-pins; \
|
||||
sha256sum requirements-dev.txt requirements-dev.lock requirements.yml extensions/molecule/requirements.yml \
|
||||
.pre-commit-config.yaml > /opt/ci-pins.sha256; \
|
||||
sha256sum requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml \
|
||||
> /opt/ci-pins.sha256; \
|
||||
ansible --version | head -n1; \
|
||||
ansible-galaxy collection list; \
|
||||
pre-commit --version; \
|
||||
|
||||
@@ -29,9 +29,10 @@ FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da0
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# python3 and python3-venv only bootstrap uv in the build stage; ca-certificates serve the
|
||||
# install a job runs when a pull request changes a pin. apt lists are removed in the same layer.
|
||||
# install a job runs when a pull request changes a pin; git lets the selector diff the checkout.
|
||||
# apt lists are removed in the same layer.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates python3 python3-venv \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates git python3 python3-venv \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
@@ -92,7 +93,7 @@ LABEL org.opencontainers.image.title="molecule-controller" \
|
||||
org.opencontainers.image.authors="Defame1297 and contributors" \
|
||||
org.opencontainers.image.base.name="ubuntu:26.04" \
|
||||
net.rkdr.mortis.purpose="Molecule controller image for the mortis.kamino Ansible Collection: the Molecule workflow runs molecule in it, so a tool only Lint uses does not change it." \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, molecule, molecule-plugins[docker]), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), python<PYTHON_VERSION> (the one of /opt/venv), python3 (distribution), /opt/molecule-pins.sha256" \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, molecule, molecule-plugins[docker]), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), python<PYTHON_VERSION> (the one of /opt/venv), python3 and git (distribution), /opt/molecule-pins.sha256" \
|
||||
net.rkdr.mortis.usage="Molecule (host executor, kamino-molecule runner): docker run as the runner user, with the Docker socket, the host Docker CLI and the checkout mounted at the same path. Run sha256sum -c /opt/molecule-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label."
|
||||
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
@@ -122,6 +123,7 @@ RUN set -eu; \
|
||||
molecule --version | grep -F "molecule ${mol}"; \
|
||||
molecule drivers | grep -qw docker; \
|
||||
python -c "import docker"; \
|
||||
git --version; \
|
||||
collections="$(ansible-galaxy collection list --format json)"; \
|
||||
for c in $(sed -n 's/^ *- name: *//p' requirements.yml extensions/molecule/requirements.yml); do \
|
||||
printf '%s' "$collections" | python -c "import json, sys; d = json.load(sys.stdin); sys.exit(0 if any('$c' in v for v in d.values()) else 1)" \
|
||||
|
||||
+3
-3
@@ -79,12 +79,12 @@
|
||||
},
|
||||
{
|
||||
"customType": "regex",
|
||||
"description": "The CI_IMAGE, MOLECULE_IMAGE and MOLECULE_IMAGE_<release> values of molecule.yml are a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.",
|
||||
"description": "The CONTROLLER_IMAGE (molecule-controller), MOLECULE_IMAGE and MOLECULE_IMAGE_<release> values of molecule.yml are a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.",
|
||||
"managerFilePatterns": [
|
||||
"/^\\.gitea/workflows/molecule\\.yml$/"
|
||||
],
|
||||
"matchStrings": [
|
||||
"(?:CI_IMAGE|MOLECULE_IMAGE(?:_[0-9]+)?):\\s*>-\\s*\\n\\s*(?<depName>git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?<currentValue>[^@\\s]+)@(?<currentDigest>sha256:[0-9a-f]{64})"
|
||||
"(?:CONTROLLER_IMAGE|MOLECULE_IMAGE(?:_[0-9]+)?):\\s*>-\\s*\\n\\s*(?<depName>git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?<currentValue>[^@\\s]+)@(?<currentDigest>sha256:[0-9a-f]{64})"
|
||||
],
|
||||
"datasourceTemplate": "docker",
|
||||
"versioningTemplate": "semver"
|
||||
@@ -168,7 +168,7 @@
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci, molecule-controller and both molecule target images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
|
||||
+4
-23
@@ -687,11 +687,6 @@ distro==1.9.0 \
|
||||
# via
|
||||
# ansible-lint
|
||||
# bindep
|
||||
# selinux
|
||||
docker==7.2.0 \
|
||||
--hash=sha256:a3f45fdeb9165e2d25d9a1d02ddf3bc70fb572cf5ebbf9b58558c22caf29b71f \
|
||||
--hash=sha256:cebb93773d334f778e023a7ee352a8d6e13ab1bd3b863a4d4a59dec897df43ac
|
||||
# via molecule-plugins
|
||||
docutils==0.23 \
|
||||
--hash=sha256:25d013af9bf23bc1c7b2b093dff4208166c53a94786c9e447808335ef1185fea \
|
||||
--hash=sha256:746f5060322511280a1e50eb76846ed6bf2342984b2ac04dc42caa1a8d78799e
|
||||
@@ -1204,15 +1199,9 @@ mdurl==0.1.2 \
|
||||
--hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \
|
||||
--hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba
|
||||
# via markdown-it-py
|
||||
molecule==26.11.0 \
|
||||
--hash=sha256:5e48f66e97ce03ba1e9cfdf4a3667db499e960543c91bb62f530c6cd6337dd9b \
|
||||
--hash=sha256:706bb3d9a34e1531cfe1cda294974aad4ccba70af3ecb2d434266e0df73b0c09
|
||||
# via
|
||||
# -r requirements-dev.txt
|
||||
# molecule-plugins
|
||||
molecule-plugins==26.11.0 \
|
||||
--hash=sha256:194be2c43d950545cc699ab19f1a55b26853809e6e8c855ea1a42edacf5c7ee7 \
|
||||
--hash=sha256:513808288b7027c465b124e66a2a31002c7c907b2fea9002f63ee90bb2d0ef84
|
||||
molecule==26.11.1 \
|
||||
--hash=sha256:34035f2852f1c0461539051ec1dd2398492c1e4f370ba507b81a781f322e4147 \
|
||||
--hash=sha256:dcd147fb60bb66c060e0bf6a3eaa18f34433a18254a6f56f25ac254fb7980f64
|
||||
# via -r requirements-dev.txt
|
||||
multidict==7.2.1 \
|
||||
--hash=sha256:02009b402129a73e1f3da68f48eb999afbacd29f25aef0d5052b84ff5c2786a2 \
|
||||
@@ -1969,9 +1958,7 @@ requests==2.34.2 \
|
||||
# via
|
||||
# apm-cli
|
||||
# azure-core
|
||||
# docker
|
||||
# galaxy-importer
|
||||
# molecule-plugins
|
||||
resolvelib==1.2.1 \
|
||||
--hash=sha256:7d08a2022f6e16ce405d60b68c390f054efcfd0477d4b9bd019cc941c28fad1c \
|
||||
--hash=sha256:fb06b66c8da04172d9e72a21d7d06186d8919e32ae5ab5cdf5b9d920be805ac2
|
||||
@@ -2139,10 +2126,6 @@ ruamel-yaml==0.19.1 \
|
||||
# via
|
||||
# ansible-lint
|
||||
# apm-cli
|
||||
selinux==0.3.0 \
|
||||
--hash=sha256:2a88b337ac46ad0f06f557b2806c3df62421972f766673dd8bf26732fb75a9ea \
|
||||
--hash=sha256:ecf7add45c939e9dda682c390a2cd0a845c94a4793a2cce9e8870d4ee9501f99
|
||||
# via molecule-plugins
|
||||
semantic-version==2.10.0 \
|
||||
--hash=sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c \
|
||||
--hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177
|
||||
@@ -2223,9 +2206,7 @@ tzdata==2026.6 \
|
||||
urllib3==2.8.0 \
|
||||
--hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \
|
||||
--hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63
|
||||
# via
|
||||
# docker
|
||||
# requests
|
||||
# via requests
|
||||
virtualenv==21.15.12 \
|
||||
--hash=sha256:a3976f886eb6019fcb1d137b223d160adaeff524ab0ad785c729a43c31cc158c \
|
||||
--hash=sha256:bbbf764388a18dee8c3532c77af7a29680cd8121911d6dcb3484335d76547323
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Pinned tooling for lint, build and Molecule, used by CI (.gitea/workflows) and locally:
|
||||
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally:
|
||||
# python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
|
||||
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
|
||||
@@ -12,10 +12,11 @@ pre-commit==4.7.0
|
||||
antsibull-changelog==0.38.0
|
||||
galaxy-importer==0.4.44
|
||||
reuse==6.3.0
|
||||
molecule==26.11.0
|
||||
molecule-plugins[docker]==26.11.0
|
||||
# molecule without its Docker driver: Lint's "Test the repository scripts" step imports it in
|
||||
# test_check_scenarios_load_checkout.py and test_run_molecule_scenarios.py, which skip without it.
|
||||
molecule==26.11.1
|
||||
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
||||
# so lint and Molecule run where a consumer's controller would.
|
||||
# so lint runs where a consumer's controller would.
|
||||
proxmoxer==2.3.0
|
||||
# apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252):
|
||||
# before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key.
|
||||
|
||||
@@ -563,9 +563,9 @@ mdurl==0.1.2 \
|
||||
--hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \
|
||||
--hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba
|
||||
# via markdown-it-py
|
||||
molecule==26.11.0 \
|
||||
--hash=sha256:5e48f66e97ce03ba1e9cfdf4a3667db499e960543c91bb62f530c6cd6337dd9b \
|
||||
--hash=sha256:706bb3d9a34e1531cfe1cda294974aad4ccba70af3ecb2d434266e0df73b0c09
|
||||
molecule==26.11.1 \
|
||||
--hash=sha256:34035f2852f1c0461539051ec1dd2398492c1e4f370ba507b81a781f322e4147 \
|
||||
--hash=sha256:dcd147fb60bb66c060e0bf6a3eaa18f34433a18254a6f56f25ac254fb7980f64
|
||||
# via
|
||||
# -r requirements-molecule.txt
|
||||
# molecule-plugins
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
# ansible-core equals the pin of requirements-dev.txt (check_image_versions.py pins fails otherwise), so
|
||||
# Lint and Molecule judge the code with one ansible-core.
|
||||
ansible-core==2.22.0
|
||||
molecule==26.11.0
|
||||
molecule==26.11.1
|
||||
# The Docker driver, with the docker Python SDK it and the community.docker modules of its playbooks use.
|
||||
molecule-plugins[docker]==26.11.0
|
||||
+3
-2
@@ -2,8 +2,9 @@
|
||||
# Collections the roles of this Collection call (the dependencies of galaxy.yml, pinned exactly).
|
||||
# galaxy.yml holds the lower bounds a consumer needs; this file holds the versions CI tests
|
||||
# against. One file feeds every consumer, so they cannot drift apart:
|
||||
# - the ci image (images/ci/Dockerfile) bakes it into /opt/collections for Lint and Molecule;
|
||||
# - the Molecule job (.gitea/workflows/molecule.yml) installs it itself when a pull request changes it;
|
||||
# - the ci image (images/ci/Dockerfile) bakes it into /opt/collections for Lint;
|
||||
# - the molecule-controller image (images/molecule-controller/Dockerfile) bakes it for Molecule,
|
||||
# and scripts/run_molecule_in_controller.sh installs it itself when a pull request changes it;
|
||||
# - scripts/dev-setup.sh installs it into .ansible/collections for local lint.
|
||||
# Renovate (renovate.json, ansible-galaxy manager) bumps these pins.
|
||||
collections:
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ There is no discovery by variable name, and a variable that looks like one fails
|
||||
|
||||
### `service_rules`
|
||||
|
||||
A service role that owns firewall rules calls the role with `include_role` and `tasks_from: service_rules` after the main entry has run, with `apply: {tags: [...]}` so `--tags <role>` reaches these tasks. The entry point installs nothing and touches no default policy, no `before.rules` and no base rule. Outside check mode (`--check` or the `check_mode` keyword; the role detects it with a skipped probe task, not `ansible_check_mode`) it fails when ufw is not installed and active. In check mode it skips the reconcile only when `ufw status` fails (ufw not installed yet, the main entry may not have reached the host); a host with ufw installed but inactive is reconciled as usual.
|
||||
A service role that owns firewall rules calls the role with `include_role` and `tasks_from: service_rules` after the main entry has run, with `apply: {tags: [...]}` so `--tags <role>` reaches these tasks. The entry point installs nothing and touches no default policy, no `before.rules` and no base rule. Outside check mode (`--check` or the `check_mode` keyword; the role detects it with a probe command that does not run there, not `ansible_check_mode`) it fails when ufw is not installed and active. In check mode it skips the reconcile only when `ufw status` fails (ufw not installed yet, the main entry may not have reached the host); a host with ufw installed but inactive is reconciled as usual.
|
||||
|
||||
| Variable | Default | Required | Description |
|
||||
|---|---|---|---|
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
# svc_o2 that looks like the SSH rule, and a rule of svc_m. The managed owners below are
|
||||
# the ones used above plus svc_m (listed but never called), so svc_o1 and svc_o2 are
|
||||
# orphans. The cases that must change nothing run first and the purge last, so the
|
||||
# idempotence run finds nothing left to delete. Under --check the role's own skipped probe
|
||||
# idempotence run finds nothing left to delete. Under --check the role's own check-mode probe
|
||||
# keeps the purge from deleting, and orphan_check.yml skips its counts.
|
||||
- name: Report and purge the rules of unmanaged owners
|
||||
hosts: all
|
||||
|
||||
@@ -474,8 +474,8 @@
|
||||
# apply of community.general.ufw reports changed for the would-be rule, so molecule's
|
||||
# idempotence run (a second converge) would fail on it. Verify runs once, outside that count.
|
||||
# The play runs under the check_mode keyword, which does not set ansible_check_mode in the
|
||||
# included role; the role detects check mode with a probe task instead (a command task is
|
||||
# skipped under the keyword). A present call that would add a rule and an absent call for an
|
||||
# included role; the role detects check mode with a probe task instead (a command does
|
||||
# not run under the keyword). A present call that would add a rule and an absent call for an
|
||||
# owner that holds rules must change nothing. The two reads of the rule list are forced to
|
||||
# run (check_mode: false) and compared as a whole.
|
||||
- name: Check mode of service_rules changes nothing
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
state: present
|
||||
register: __ufw_install
|
||||
|
||||
# ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set it inside
|
||||
# include_role tasks. A command task is skipped in both forms, the same probe as tasks/sysctl.yml.
|
||||
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role
|
||||
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode.
|
||||
- name: Probe whether the run is in check mode
|
||||
ansible.builtin.command: "true"
|
||||
ansible.builtin.command: echo ran
|
||||
register: __ufw_install_probe
|
||||
changed_when: false
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
# Undefined when this file's tags are skipped; the guards then default it to true.
|
||||
- name: Remember whether ufw can be configured
|
||||
ansible.builtin.set_fact:
|
||||
__ufw_can_configure: "{{ __ufw_install is not changed or __ufw_install_probe is not skipped }}"
|
||||
__ufw_can_configure: "{{ __ufw_install is not changed or __ufw_install_probe.stdout == 'ran' }}"
|
||||
@@ -63,17 +63,16 @@
|
||||
the rule tags): {{ ufw_managed_owners }}
|
||||
quiet: true
|
||||
|
||||
# ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set
|
||||
# that magic variable inside include_role tasks (only --check does). A command task is
|
||||
# skipped in both forms and its result says so, which is the one signal that holds for both.
|
||||
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role
|
||||
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode.
|
||||
- name: Probe whether the run is in check mode
|
||||
ansible.builtin.command: "true"
|
||||
ansible.builtin.command: echo ran
|
||||
register: ufw_oa_probe
|
||||
changed_when: false
|
||||
|
||||
- name: Remember whether the run is in check mode
|
||||
ansible.builtin.set_fact:
|
||||
ufw_oa_check: "{{ ufw_oa_probe is skipped }}"
|
||||
ufw_oa_check: "{{ ufw_oa_probe.stdout != 'ran' }}"
|
||||
|
||||
- name: Read the firewall status
|
||||
become: true
|
||||
|
||||
@@ -121,17 +121,16 @@
|
||||
- ufw_manage_rules
|
||||
tags: [ufw, ufw_service_rules]
|
||||
block:
|
||||
# ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set
|
||||
# that magic variable inside include_role tasks (only --check does). A command task is
|
||||
# skipped in both forms and its result says so, which is the one signal that holds for both.
|
||||
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role
|
||||
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode.
|
||||
- name: Probe whether the run is in check mode
|
||||
ansible.builtin.command: "true"
|
||||
ansible.builtin.command: echo ran
|
||||
register: ufw_sr_probe
|
||||
changed_when: false
|
||||
|
||||
- name: Remember whether the run is in check mode
|
||||
ansible.builtin.set_fact:
|
||||
ufw_sr_check: "{{ ufw_sr_probe is skipped }}"
|
||||
ufw_sr_check: "{{ ufw_sr_probe.stdout != 'ran' }}"
|
||||
|
||||
- name: Read the firewall status
|
||||
become: true
|
||||
|
||||
@@ -7,18 +7,17 @@
|
||||
check_mode: false
|
||||
when: ufw_enabled and ufw_sysctl_overrides | length > 0
|
||||
|
||||
# ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set that
|
||||
# magic variable inside include_role tasks (only --check does). A command task
|
||||
# is skipped in both forms and its result says so, the same probe as tasks/service_rules.yml.
|
||||
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role
|
||||
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode.
|
||||
- name: Probe whether the run is in check mode
|
||||
ansible.builtin.command: "true"
|
||||
ansible.builtin.command: echo ran
|
||||
register: ufw_sysctl_probe
|
||||
changed_when: false
|
||||
when: ufw_enabled and ufw_sysctl_overrides | length > 0
|
||||
|
||||
- name: Remember whether the run is in check mode
|
||||
ansible.builtin.set_fact:
|
||||
ufw_sysctl_check: "{{ ufw_sysctl_probe is skipped }}"
|
||||
ufw_sysctl_check: "{{ ufw_sysctl_probe.stdout != 'ran' }}"
|
||||
when: ufw_enabled and ufw_sysctl_overrides | length > 0
|
||||
|
||||
# In check mode on a fresh host ufw is not installed yet, so the file is absent.
|
||||
|
||||
@@ -70,9 +70,18 @@ USER_AGENT = "kamino-next-image-version"
|
||||
|
||||
|
||||
class RegistryError(Exception):
|
||||
def __init__(self, url, status, text, challenge=""):
|
||||
def __init__(self, url, status, text, challenge="", codes=()):
|
||||
super().__init__(f"GET {url}: HTTP {status}: {text}")
|
||||
self.status, self.challenge = status, challenge
|
||||
self.status, self.challenge, self.codes = status, challenge, codes
|
||||
|
||||
|
||||
def _error_codes(raw):
|
||||
"""The OCI error codes of an error body (`{"errors": [{"code": ...}]}`), or () for any other body."""
|
||||
try:
|
||||
errors = json.loads(raw).get("errors") or []
|
||||
return tuple(e.get("code") for e in errors if isinstance(e, dict))
|
||||
except (ValueError, AttributeError, TypeError):
|
||||
return ()
|
||||
|
||||
|
||||
def _readable(raw):
|
||||
@@ -92,7 +101,9 @@ def _fetch(url, headers):
|
||||
except urllib.error.HTTPError as exc:
|
||||
raw = exc.read(20000).decode("utf-8", errors="replace")
|
||||
challenge = exc.headers.get("WWW-Authenticate", "")
|
||||
raise RegistryError(url, exc.code, _readable(raw), challenge) from exc
|
||||
raise RegistryError(
|
||||
url, exc.code, _readable(raw), challenge, _error_codes(raw)
|
||||
) from exc
|
||||
|
||||
|
||||
class Registry:
|
||||
@@ -139,7 +150,8 @@ class Registry:
|
||||
body, headers = self._get(path)
|
||||
except RegistryError as exc:
|
||||
# A repository not pushed yet is 404 NAME_UNKNOWN (OCI distribution spec): no tags.
|
||||
if exc.status == 404 and not tags:
|
||||
# Any other 404, such as a wrong registry path, must fail rather than restart at .0.
|
||||
if exc.status == 404 and "NAME_UNKNOWN" in exc.codes and not tags:
|
||||
return []
|
||||
raise
|
||||
tags += body.get("tags") or []
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
# 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
|
||||
# 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/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))
|
||||
|
||||
@@ -511,11 +511,12 @@ class PureTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(civ.dockerfile_labels('FROM c\nLABEL a="unbalanced\n'), {})
|
||||
|
||||
def test_the_molecule_collections_are_an_input_of_the_ci_image(self):
|
||||
def test_the_molecule_collections_are_not_an_input_of_the_ci_image(self):
|
||||
# Lint uses no collection of them, so their bump must not publish a ci version.
|
||||
root = pathlib.Path(__file__).resolve().parents[2]
|
||||
entry = civ.matrix_of((root / civ.MATRIX_FILE).read_text())["ci"]
|
||||
files = civ.inputs_of(entry, (root / entry["dockerfile"]).read_text())[1]
|
||||
self.assertIn("extensions/molecule/requirements.yml", files)
|
||||
self.assertNotIn("extensions/molecule/requirements.yml", files)
|
||||
|
||||
def test_the_controller_pins_are_inputs_of_the_controller_image(self):
|
||||
root = pathlib.Path(__file__).resolve().parents[2]
|
||||
|
||||
@@ -105,6 +105,7 @@ class FakeRegistry(http.server.BaseHTTPRequestHandler):
|
||||
no_realm = False
|
||||
empty_token = False
|
||||
unknown = False # the repository does not exist yet
|
||||
not_found = None # a 404 body without NAME_UNKNOWN
|
||||
agents = None # a fresh list per test, set in setUp
|
||||
|
||||
def do_GET(self):
|
||||
@@ -128,6 +129,8 @@ class FakeRegistry(http.server.BaseHTTPRequestHandler):
|
||||
b"{}",
|
||||
extra={"WWW-Authenticate": f'Bearer realm="{realm}",service="reg"'},
|
||||
)
|
||||
elif self.not_found is not None:
|
||||
self.reply(404, self.not_found, "text/plain")
|
||||
elif self.unknown:
|
||||
body = {"errors": [{"code": "NAME_UNKNOWN", "message": "unknown"}]}
|
||||
self.reply(404, json.dumps(body).encode())
|
||||
@@ -155,6 +158,7 @@ class RegistryClient(unittest.TestCase):
|
||||
def setUp(self):
|
||||
FakeRegistry.refuse = FakeRegistry.refuse_token = FakeRegistry.no_realm = False
|
||||
FakeRegistry.empty_token = FakeRegistry.unknown = False
|
||||
FakeRegistry.not_found = None
|
||||
FakeRegistry.agents = []
|
||||
server = QuietServer(("127.0.0.1", 0), FakeRegistry)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
@@ -176,6 +180,17 @@ class RegistryClient(unittest.TestCase):
|
||||
niv.next_version("0.1", self.registry.tags(), "c", no_label), "0.1.0"
|
||||
)
|
||||
|
||||
def test_a_404_without_name_unknown_is_a_registry_error(self):
|
||||
for body in (
|
||||
b"404 page not found",
|
||||
b'{"errors":[{"code":"NOT_FOUND","message":"no such route"}]}',
|
||||
):
|
||||
with self.subTest(body=body):
|
||||
FakeRegistry.not_found = body
|
||||
with self.assertRaises(niv.RegistryError) as caught:
|
||||
self.registry.tags()
|
||||
self.assertEqual(caught.exception.status, 404)
|
||||
|
||||
def test_a_missing_manifest_is_still_a_registry_error(self):
|
||||
FakeRegistry.unknown = True
|
||||
with self.assertRaises(niv.RegistryError) as caught:
|
||||
|
||||
+7
-6
@@ -1,6 +1,7 @@
|
||||
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Tests for scripts/run_molecule_in_ci_image.sh with stub tools in place of the ci image's.
|
||||
"""Tests for scripts/run_molecule_in_controller.sh with stub tools in place of the molecule-controller
|
||||
image's.
|
||||
|
||||
Run with: python3 -m unittest discover -s tests/scripts
|
||||
"""
|
||||
@@ -13,7 +14,7 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
REPO = pathlib.Path(__file__).resolve().parents[2]
|
||||
SCRIPT = REPO / "scripts" / "run_molecule_in_ci_image.sh"
|
||||
SCRIPT = REPO / "scripts" / "run_molecule_in_controller.sh"
|
||||
|
||||
# Each stub appends its name, arguments and the paths it saw to STUB_LOG; STUB_FAIL_<name> fails it.
|
||||
STUB = """#!/usr/bin/env bash
|
||||
@@ -49,7 +50,7 @@ echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH" \\
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which("bash"), "bash is required")
|
||||
class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
class RunMoleculeInControllerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="kamino-runci-")).resolve()
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
@@ -105,7 +106,7 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
result = self.run_script()
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
(check,) = self.calls("sha256sum")
|
||||
self.assertIn("args=--quiet -c /opt/ci-pins.sha256 ", check)
|
||||
self.assertIn("args=--quiet -c /opt/molecule-pins.sha256 ", check)
|
||||
self.assertEqual(self.calls("python"), [])
|
||||
self.assertEqual(self.calls("ansible-galaxy"), [])
|
||||
self.assertEqual(len(self.calls("ansible")), 1)
|
||||
@@ -132,8 +133,8 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
)
|
||||
(pip,) = self.calls("pip")
|
||||
self.assertIn(
|
||||
"args=install --quiet --require-hashes -r requirements-dev.lock"
|
||||
" -r requirements-dev.txt ",
|
||||
"args=install --quiet --require-hashes -r requirements-molecule.lock"
|
||||
" -r requirements-molecule.txt ",
|
||||
pip,
|
||||
)
|
||||
galaxy = self.calls("ansible-galaxy")
|
||||
@@ -355,7 +355,7 @@ class RunMoleculeScenariosTest(unittest.TestCase):
|
||||
|
||||
def test_the_default_time_limit_is_inside_the_job_timeout(self):
|
||||
# a limit past the job's own would let a hang take the job and every log with it
|
||||
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["molecule"][
|
||||
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["scenarios"][
|
||||
"timeout-minutes"
|
||||
]
|
||||
limit = re.findall(r"MOLECULE_SCENARIO_TIMEOUT:-(\d+)\}", SCRIPT.read_text())
|
||||
@@ -502,7 +502,7 @@ class ScenarioPlatformsTest(unittest.TestCase):
|
||||
|
||||
def test_the_sweep_spares_containers_younger_than_the_job_timeout(self):
|
||||
# a shorter bound would remove the containers of a run still going
|
||||
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["molecule"][
|
||||
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["scenarios"][
|
||||
"timeout-minutes"
|
||||
]
|
||||
run = step_run("Remove the containers earlier runs left")
|
||||
@@ -519,12 +519,130 @@ class LanesInputTest(unittest.TestCase):
|
||||
# yaml reads the `on:` key as True
|
||||
lanes = workflow[True]["workflow_dispatch"]["inputs"]["lanes"]
|
||||
self.assertEqual((lanes["type"], lanes["default"]), ("string", ""))
|
||||
steps = workflow["jobs"]["molecule"]["steps"]
|
||||
steps = workflow["jobs"]["scenarios"]["steps"]
|
||||
step = next(s for s in steps if s.get("name") == "Run the scenarios")
|
||||
self.assertEqual(step["env"]["MOLECULE_LANES"], "${{ inputs.lanes }}")
|
||||
self.assertRegex(step["run"], r"docker run [^<]*-e MOLECULE_LANES\b")
|
||||
|
||||
|
||||
class WorkflowJobsTest(unittest.TestCase):
|
||||
"""A pull request that selects no scenario takes no Molecule runner slot."""
|
||||
|
||||
JOBS = yaml.safe_load(WORKFLOW.read_text())["jobs"]
|
||||
|
||||
def result(self, select, scenarios, selected):
|
||||
"""The exit code of the result job's check for those needs results and that selection."""
|
||||
(step,) = self.JOBS["result"]["steps"]
|
||||
env = dict(
|
||||
os.environ,
|
||||
SELECT_RESULT=select,
|
||||
SCENARIOS_RESULT=scenarios,
|
||||
SELECTED=selected,
|
||||
)
|
||||
return subprocess.run(
|
||||
# act runs a job container's step with sh when the step sets no shell
|
||||
["sh", "-e", "-c", step["run"]],
|
||||
check=False,
|
||||
env=env,
|
||||
capture_output=True,
|
||||
).returncode
|
||||
|
||||
def written_output(self, selected):
|
||||
"""The `scenarios` output select's run step writes for that selector output."""
|
||||
step = next(s for s in self.JOBS["select"]["steps"] if s.get("id") == "select")
|
||||
block = step["run"].split("|| exit 1\n", 1)[1]
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
out = pathlib.Path(tmp, "output")
|
||||
subprocess.run(
|
||||
["sh", "-e", "-c", 'selected="$1"\n' + block, "sh", selected],
|
||||
check=True,
|
||||
env=dict(os.environ, GITHUB_OUTPUT=str(out)),
|
||||
)
|
||||
lines = out.read_text().splitlines()
|
||||
# GITHUB_OUTPUT's `name<<delimiter` form: the value is every line up to the delimiter
|
||||
name, delim = lines[0].split("<<", 1)
|
||||
self.assertEqual((name, lines[-1]), ("scenarios", delim))
|
||||
self.assertNotIn(delim, lines[1:-1])
|
||||
return "\n".join(lines[1:-1])
|
||||
|
||||
def test_select_writes_none_for_an_empty_selection(self):
|
||||
self.assertEqual(self.written_output(""), "none")
|
||||
|
||||
def test_select_writes_the_selection_one_directory_per_line(self):
|
||||
selected = "extensions/molecule/image-smoke\nroles/a/molecule/default"
|
||||
self.assertEqual(self.written_output(selected), selected)
|
||||
|
||||
def test_three_jobs_each_on_its_runner(self):
|
||||
self.assertEqual(
|
||||
{name: job["runs-on"] for name, job in self.JOBS.items()},
|
||||
{
|
||||
"select": "kamino-docker",
|
||||
"scenarios": ["kamino-molecule"],
|
||||
"result": "kamino-docker",
|
||||
},
|
||||
)
|
||||
|
||||
def test_only_the_scenarios_job_runs_on_the_host(self):
|
||||
# select and result need no Docker daemon, so they take no Molecule runner slot
|
||||
self.assertIn("container", self.JOBS["select"])
|
||||
self.assertIn("container", self.JOBS["result"])
|
||||
self.assertNotIn("container", self.JOBS["scenarios"])
|
||||
|
||||
def test_every_job_has_the_fork_guard(self):
|
||||
guard = (
|
||||
"github.repository == 'mortis/kamino' && "
|
||||
"(github.event_name != 'pull_request' || "
|
||||
"github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
)
|
||||
self.assertEqual(self.JOBS["select"]["if"], guard)
|
||||
for name, job in self.JOBS.items():
|
||||
self.assertTrue(job["if"].endswith(guard), name)
|
||||
|
||||
def test_the_scenarios_run_only_for_a_selection(self):
|
||||
job = self.JOBS["scenarios"]
|
||||
self.assertEqual(job["needs"], "select")
|
||||
# false for `none` and for an empty or missing output alike
|
||||
self.assertTrue(
|
||||
job["if"].startswith(
|
||||
"needs.select.outputs.scenarios != 'none' && "
|
||||
"needs.select.outputs.scenarios != '' &&"
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
self.JOBS["select"]["outputs"]["scenarios"],
|
||||
"${{ steps.select.outputs.scenarios }}",
|
||||
)
|
||||
step = next(s for s in job["steps"] if s.get("name") == "Run the scenarios")
|
||||
self.assertEqual(
|
||||
step["env"]["SELECTED"], "${{ needs.select.outputs.scenarios }}"
|
||||
)
|
||||
self.assertIn('run_molecule_in_controller.sh <<< "$SELECTED"', step["run"])
|
||||
|
||||
def test_the_result_runs_whatever_the_others_ended_as(self):
|
||||
job = self.JOBS["result"]
|
||||
self.assertEqual(job["needs"], ["select", "scenarios"])
|
||||
self.assertTrue(job["if"].startswith("always() &&"))
|
||||
|
||||
def test_the_result_passes_a_run_or_a_none_selection_only(self):
|
||||
self.assertEqual(
|
||||
self.result("success", "success", "roles/a/molecule/default"), 0
|
||||
)
|
||||
self.assertEqual(self.result("success", "skipped", "none"), 0)
|
||||
# an empty output was lost, not an empty selection
|
||||
self.assertNotEqual(self.result("success", "skipped", ""), 0)
|
||||
self.assertNotEqual(
|
||||
self.result("success", "skipped", "roles/a/molecule/default"), 0
|
||||
)
|
||||
self.assertNotEqual(
|
||||
self.result("success", "failure", "roles/a/molecule/default"), 0
|
||||
)
|
||||
self.assertNotEqual(
|
||||
self.result("success", "cancelled", "roles/a/molecule/default"), 0
|
||||
)
|
||||
self.assertNotEqual(self.result("failure", "skipped", "none"), 0)
|
||||
self.assertNotEqual(self.result("skipped", "skipped", "none"), 0)
|
||||
|
||||
|
||||
class ScenarioSequenceTest(unittest.TestCase):
|
||||
"""A role scenario previews the fresh host and the configured host with molecule's check step."""
|
||||
|
||||
|
||||
@@ -206,6 +206,23 @@ class SelectTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(chosen, [])
|
||||
|
||||
def test_a_ci_pin_bump_in_lint_or_build_selects_nothing(self):
|
||||
chosen, _reason = self.select(
|
||||
[".gitea/workflows/lint.yml", ".gitea/workflows/build.yml"]
|
||||
)
|
||||
self.assertEqual(chosen, [])
|
||||
|
||||
def test_lint_requirements_select_nothing(self):
|
||||
# requirements-dev.* pin Lint's tools; Molecule's come from requirements-molecule.*.
|
||||
chosen, _reason = self.select(["requirements-dev.txt", "requirements-dev.lock"])
|
||||
self.assertEqual(chosen, [])
|
||||
|
||||
def test_molecule_requirements_select_everything(self):
|
||||
# An ansible-core or molecule bump there changes the tools every scenario runs with.
|
||||
for path in ("requirements-molecule.txt", "requirements-molecule.lock"):
|
||||
chosen, _reason = self.select([path])
|
||||
self.assertEqual(chosen, ALL, path)
|
||||
|
||||
def test_ignored_does_not_mask_a_role(self):
|
||||
chosen, _reason = self.select(["docs/x.md", "roles/docker/tasks/main.yml"])
|
||||
self.assertEqual(chosen, ["roles/docker/molecule/default"])
|
||||
@@ -660,8 +677,31 @@ class WorkflowPinsTest(unittest.TestCase):
|
||||
return self.pin(key).split("@sha256:")[0] + "@sha256:" + "0" * 64
|
||||
|
||||
def test_the_workflow_has_each_pin_where_the_selector_looks(self):
|
||||
for key in ("CI_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"):
|
||||
self.assertEqual(self.edited(self.pin(key), self.bumped(key)), {key}, key)
|
||||
for key in ("CONTROLLER_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"):
|
||||
old, new = (
|
||||
f"{key}: >-\n {v}" for v in (self.pin(key), self.bumped(key))
|
||||
)
|
||||
self.assertEqual(self.edited(old, new), {key}, key)
|
||||
|
||||
def test_the_workflow_runs_in_the_controller_image_not_ci(self):
|
||||
# A ci pin bump must touch only Lint and Build, which IGNORED lists (ADR 0003).
|
||||
self.assertIn("/mortis/molecule-controller:", self.pin("CONTROLLER_IMAGE"))
|
||||
self.assertNotIn("/mortis/ci:", self.WORKFLOW)
|
||||
|
||||
def test_every_controller_pin_is_the_same(self):
|
||||
# container.image cannot read env, so the select and result jobs repeat CONTROLLER_IMAGE
|
||||
jobs = yaml.safe_load(self.WORKFLOW)["jobs"]
|
||||
pins = [
|
||||
jobs["select"]["container"]["image"],
|
||||
self.pin("CONTROLLER_IMAGE"),
|
||||
jobs["result"]["container"]["image"],
|
||||
]
|
||||
self.assertEqual(len(set(pins)), 1, pins)
|
||||
self.assertEqual(self.WORKFLOW.count("/mortis/molecule-controller:"), len(pins))
|
||||
# Renovate moves all three, which the selector reads as "any other change": every
|
||||
# scenario, as for CONTROLLER_IMAGE alone.
|
||||
bumped = self.WORKFLOW.replace(pins[0], self.bumped("CONTROLLER_IMAGE"))
|
||||
self.assertIsNone(sel.pin_changes(self.WORKFLOW, bumped))
|
||||
|
||||
def test_comments_and_blank_lines_change_nothing(self):
|
||||
self.assertEqual(self.edited("# Behavioural tests", "# Other words"), set())
|
||||
@@ -772,8 +812,9 @@ class SelectByPinTest(unittest.TestCase):
|
||||
def test_comments_only_select_nothing(self):
|
||||
self.assertEqual(self.select(set()), [])
|
||||
|
||||
def test_the_ci_image_or_no_analysis_selects_everything(self):
|
||||
self.assertEqual(self.select({"CI_IMAGE", "MOLECULE_IMAGE"}), ALL)
|
||||
def test_the_controller_image_or_no_analysis_selects_everything(self):
|
||||
self.assertEqual(self.select({"CONTROLLER_IMAGE"}), ALL)
|
||||
self.assertEqual(self.select({"CONTROLLER_IMAGE", "MOLECULE_IMAGE"}), ALL)
|
||||
self.assertEqual(self.select(None), ALL)
|
||||
|
||||
def test_pins_do_not_narrow_another_file(self):
|
||||
|
||||
Reference in new issue
Block a user