Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a60fb6407e |
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 molecule-controller image
|
||||
# Per-task timings, to see what a scenario's time goes to; ansible.posix is in the ci image
|
||||
# and in requirements.yml, so the controller always has these callbacks.
|
||||
callbacks_enabled: ansible.posix.profile_tasks, ansible.posix.timer
|
||||
callback_profile_tasks:
|
||||
|
||||
@@ -82,10 +82,9 @@ issue.
|
||||
`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 `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.
|
||||
(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.
|
||||
- **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.
|
||||
@@ -128,14 +127,10 @@ 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
|
||||
`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_ci_image.sh`, and the selector's tests for which pin files select what.
|
||||
`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`.
|
||||
- **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
|
||||
|
||||
@@ -11,12 +11,11 @@ name: Molecule
|
||||
# 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 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.
|
||||
# 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:
|
||||
@@ -58,18 +57,17 @@ jobs:
|
||||
# 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, 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.0@sha256:d4ab16d58851eead751c8f0bada8edd76c9e5dcd5c2acaa1ac93c5f6035b29e2
|
||||
# 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
|
||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||
# one locally.
|
||||
MOLECULE_IMAGE: >-
|
||||
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.11@sha256:e7389be9c397ec50fcf7d433c99cb9da7b16b149384aaa543e3c21a3ada1a4e1
|
||||
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.12@sha256:5f96ae95e16e205cc433607bab31307b36633ad73468aa7bdc57f4bbddb1c571
|
||||
# The same for Ubuntu 26.04, the release the hosts are moving to; used by
|
||||
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
|
||||
MOLECULE_IMAGE_2604: >-
|
||||
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.7@sha256:86ee99fe77ab4c9af3911570ae7238ce525375cfaf923e9656860606c47488df
|
||||
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.8@sha256:96496c7fb35e6091d08b057e53ba603256d07483769f27c19582d336ddc11173
|
||||
# Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-<name>`
|
||||
# with the label net.rkdr.mortis.molecule-run, and the one molecule runs in.
|
||||
KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}
|
||||
@@ -165,7 +163,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 \
|
||||
"$CONTROLLER_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
|
||||
"$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
|
||||
|
||||
# A cancelled run can leave its containers running when the docker client is killed.
|
||||
- name: Remove this run's containers
|
||||
|
||||
+9
-12
@@ -113,16 +113,13 @@ 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 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.
|
||||
- **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.
|
||||
- **Planned reduction:** none for now.
|
||||
+10
-7
@@ -1,9 +1,7 @@
|
||||
# ci
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## What is in it
|
||||
|
||||
@@ -61,20 +59,25 @@ 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
|
||||
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` and `gitea-release-key.yml`
|
||||
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.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` and
|
||||
`gitea-release-key.yml`.
|
||||
- Pin `ci:<version>@sha256:<digest>`; the digest decides what is pulled. Consumers: `lint.yml`, `build.yml`,
|
||||
`molecule.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).
|
||||
|
||||
|
||||
@@ -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`.
|
||||
|
||||
`.gitea/workflows/molecule.yml` is its consumer: it pins the image as `CONTROLLER_IMAGE`, and
|
||||
`scripts/run_molecule_in_ci_image.sh` runs the pin check inside it. Read the workflow for the full command.
|
||||
No workflow consumes it yet; the Molecule workflow still runs in the [`ci`](ci.md) image until its first pin is made
|
||||
by hand.
|
||||
|
||||
## 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 molecule-controller image provides.
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the ci 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 molecule-controller image provides.
|
||||
nothing runs privileged. The docker driver needs molecule's docker plugin, which the ci 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`).
|
||||
|
||||
+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 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
|
||||
- **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
|
||||
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.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# 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).
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
@@ -178,16 +177,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 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 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, 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.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 and Build workflows run in it, so a job only checks out the code and runs." \
|
||||
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. 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.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."
|
||||
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PRE_COMMIT_HOME=/opt/pre-commit \
|
||||
|
||||
+3
-3
@@ -79,12 +79,12 @@
|
||||
},
|
||||
{
|
||||
"customType": "regex",
|
||||
"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.",
|
||||
"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.",
|
||||
"managerFilePatterns": [
|
||||
"/^\\.gitea/workflows/molecule\\.yml$/"
|
||||
],
|
||||
"matchStrings": [
|
||||
"(?: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})"
|
||||
"(?: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})"
|
||||
],
|
||||
"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, 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.",
|
||||
"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.",
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# The Molecule workflow's run inside the molecule-controller image, from the checkout root: when a
|
||||
# pin file differs from the image's, install the pull request's pins into $AC_ROOT/pins (/opt is not
|
||||
# writable for the runner user) and put them first, then check that the scenarios on stdin load this
|
||||
# checkout and run them. CI_BASE_PYTHON is a test seam.
|
||||
# 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.
|
||||
#
|
||||
# AC_ROOT=<dir holding ansible_collections> scripts/run_molecule_in_ci_image.sh < scenario-dirs
|
||||
set -euo pipefail
|
||||
@@ -13,12 +13,12 @@ set -euo pipefail
|
||||
selected="$(cat)"
|
||||
pins="$AC_ROOT/pins"
|
||||
extra_collections=""
|
||||
if sha256sum --quiet -c /opt/molecule-pins.sha256; then
|
||||
echo "The pin files match the molecule-controller image; using the baked tools."
|
||||
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 molecule-controller image; installing the pinned tools and collections for this run."
|
||||
echo "::warning::a pin file differs from the ci image; installing the pinned tools and collections for this run."
|
||||
"${CI_BASE_PYTHON:-/opt/venv/bin/python}" -m venv "$pins/venv"
|
||||
"$pins/venv/bin/pip" install --quiet --require-hashes -r requirements-molecule.lock -r requirements-molecule.txt
|
||||
"$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
|
||||
|
||||
@@ -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 controller image has no docker CLI: python3 is the one molecule runs on, with PyYAML
|
||||
# 103 s a full run. The ci 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 CONTROLLER_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 CI_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+)(CONTROLLER_IMAGE|MOLECULE_IMAGE|MOLECULE_IMAGE_2604): >-")
|
||||
PIN_KEY = re.compile(r"(\s+)(CI_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 "CONTROLLER_IMAGE" not in pins:
|
||||
if path == WORKFLOW and pins is not None and "CI_IMAGE" not in pins:
|
||||
image_pins = pins
|
||||
for pin in pins:
|
||||
by_image.update(naming(all_scenarios, pin, root))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# 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 molecule-controller
|
||||
image's.
|
||||
"""Tests for scripts/run_molecule_in_ci_image.sh with stub tools in place of the ci image's.
|
||||
|
||||
Run with: python3 -m unittest discover -s tests/scripts
|
||||
"""
|
||||
@@ -106,7 +105,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/molecule-pins.sha256 ", check)
|
||||
self.assertIn("args=--quiet -c /opt/ci-pins.sha256 ", check)
|
||||
self.assertEqual(self.calls("python"), [])
|
||||
self.assertEqual(self.calls("ansible-galaxy"), [])
|
||||
self.assertEqual(len(self.calls("ansible")), 1)
|
||||
@@ -133,8 +132,8 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
)
|
||||
(pip,) = self.calls("pip")
|
||||
self.assertIn(
|
||||
"args=install --quiet --require-hashes -r requirements-molecule.lock"
|
||||
" -r requirements-molecule.txt ",
|
||||
"args=install --quiet --require-hashes -r requirements-dev.lock"
|
||||
" -r requirements-dev.txt ",
|
||||
pip,
|
||||
)
|
||||
galaxy = self.calls("ansible-galaxy")
|
||||
|
||||
@@ -206,23 +206,6 @@ 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"])
|
||||
@@ -677,14 +660,9 @@ 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 ("CONTROLLER_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"):
|
||||
for key in ("CI_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"):
|
||||
self.assertEqual(self.edited(self.pin(key), self.bumped(key)), {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_comments_and_blank_lines_change_nothing(self):
|
||||
self.assertEqual(self.edited("# Behavioural tests", "# Other words"), set())
|
||||
self.assertEqual(self.edited("\njobs:\n", "\n\n\njobs:\n"), set())
|
||||
@@ -794,9 +772,8 @@ class SelectByPinTest(unittest.TestCase):
|
||||
def test_comments_only_select_nothing(self):
|
||||
self.assertEqual(self.select(set()), [])
|
||||
|
||||
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)
|
||||
def test_the_ci_image_or_no_analysis_selects_everything(self):
|
||||
self.assertEqual(self.select({"CI_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