diff --git a/.gitea/workflows/AGENTS.md b/.gitea/workflows/AGENTS.md index 2abc3de..f607f81 100644 --- a/.gitea/workflows/AGENTS.md +++ b/.gitea/workflows/AGENTS.md @@ -53,8 +53,7 @@ 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 diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index d49b4a9..a24716b 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -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 diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index c88fae1..a669b44 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -6,8 +6,7 @@ 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 +64,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". diff --git a/docs/images/ci.md b/docs/images/ci.md index a6076f1..30052ab 100644 --- a/docs/images/ci.md +++ b/docs/images/ci.md @@ -10,13 +10,12 @@ runs in the [`molecule-controller`](molecule-controller.md) image instead 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 @@ -28,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`. @@ -61,8 +60,8 @@ jobs: pre-commit run --all-files --show-diff-on-failure ``` -`/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 diff --git a/extensions/molecule/requirements.yml b/extensions/molecule/requirements.yml index 02597c2..1c2afb1 100644 --- a/extensions/molecule/requirements.yml +++ b/extensions/molecule/requirements.yml @@ -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 diff --git a/images/ci/Dockerfile b/images/ci/Dockerfile index bbef22f..a9a4d06 100644 --- a/images/ci/Dockerfile +++ b/images/ci/Dockerfile @@ -13,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). @@ -27,8 +28,8 @@ # - Python 3.11, 3.13 and PYTHON_VERSION as python 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. @@ -66,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 @@ -99,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 @@ -178,7 +175,7 @@ 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 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" \ @@ -186,7 +183,7 @@ LABEL org.opencontainers.image.title="ci" \ 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.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 (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \ + 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 (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 \ @@ -203,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; \ diff --git a/requirements-dev.lock b/requirements-dev.lock index da503b0..110618c 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -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 @@ -1207,12 +1202,6 @@ mdurl==0.1.2 \ molecule==26.11.1 \ --hash=sha256:34035f2852f1c0461539051ec1dd2398492c1e4f370ba507b81a781f322e4147 \ --hash=sha256:dcd147fb60bb66c060e0bf6a3eaa18f34433a18254a6f56f25ac254fb7980f64 - # via - # -r requirements-dev.txt - # molecule-plugins -molecule-plugins==26.11.0 \ - --hash=sha256:194be2c43d950545cc699ab19f1a55b26853809e6e8c855ea1a42edacf5c7ee7 \ - --hash=sha256:513808288b7027c465b124e66a2a31002c7c907b2fea9002f63ee90bb2d0ef84 # 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 diff --git a/requirements-dev.txt b/requirements-dev.txt index e321e6e..065ec2e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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,8 +12,9 @@ pre-commit==4.7.0 antsibull-changelog==0.38.0 galaxy-importer==0.4.44 reuse==6.3.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 -molecule-plugins[docker]==26.11.0 # 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. proxmoxer==2.3.0 diff --git a/tests/scripts/test_check_image_versions.py b/tests/scripts/test_check_image_versions.py index 91f926f..afe3dc1 100644 --- a/tests/scripts/test_check_image_versions.py +++ b/tests/scripts/test_check_image_versions.py @@ -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]