ci: shift checks left (check-json, script tests, image pins) and name the meta-dependency check #527

Merged
Defame1297 merged 5 commits from ci/187-246-shift-left-checks into main 2026-12-06 20:24:43 +00:00
8 changed files with 39 additions and 27 deletions
Showing only changes of commit fac7ed47be - Show all commits

No files matched your search

+5 -6
View File
@@ -50,8 +50,8 @@ issue.
branch name is chosen by the pusher, so this constrains only the bot's own pull requests.
- **Workflows never mention the image namespace this repository's CI must not use** (the string
is in `scripts/check_image_versions.py`). *Why:* this repository's images are built and pulled
only under its own organisation's namespace. *Held:* control: the Lint check's "Check image
pins" step.
only under its own organisation's namespace. *Held:* control: the `check-image-pins` hook,
run by the Lint check.
## Lint and Build
@@ -62,13 +62,12 @@ issue.
*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
set to a dead local port and `no_proxy` empty, for every later step except "Test the repository
scripts", which unsets them for its fake registry on loopback; the slow path keeps network.
set to a dead local port and `no_proxy` empty, for every later step; the slow path keeps
network. The script tests set `no_proxy` to `127.0.0.1` for their fake registry on loopback.
*Why:* a runtime download is a bake-in defect and must fail the job, not silently slow it.
*Held:* control, set by the "Check the baked tooling against the pins" step, for pip, curl, git
over HTTPS and Python's urllib or requests (anything honouring `PIP_NO_INDEX` or the proxy
variables); review for a raw socket or a tool that ignores the proxy variables, and for the
script tests.
variables); review for a raw socket or a tool that ignores the proxy variables.
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
install. *Held:* review.
+3 -12
View File
@@ -78,14 +78,6 @@ jobs:
export PATH="/opt/venv/bin:$PATH"
pre-commit run --all-files --show-diff-on-failure
# Image pins (scripts/check_image_versions.py): a pin in a workflow must name an
# image of the matrix. Not a pre-commit hook: a change to .pre-commit-config.yaml
# is itself an input of the ci image and would force an image rebuild.
- name: Check image pins
run: |
export PATH="/opt/venv/bin:$PATH"
python3 scripts/check_image_versions.py pins
# A pull request from a renovate/ branch may only move version, tag, digest and pin
# lines (scripts/check_bot_pr_diff.py), so the bot's automerge cannot change workflow
# logic or reach the org secrets. The branch name is attacker-controlled: this only
@@ -113,12 +105,11 @@ jobs:
fi
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
# Without the guard: an empty no_proxy would send the fake registry on 127.0.0.1 to the dead proxy.
- name: Test the repository scripts
# The script tests are a pre-push hook (they take minutes), so --all-files above skips them.
- name: Run the script tests hook
run: |
unset PIP_NO_INDEX http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
export PATH="/opt/venv/bin:$PATH"
python3 -m unittest discover -s tests/scripts
pre-commit run --hook-stage pre-push script-tests --all-files --show-diff-on-failure
# The gitleaks hook scans --staged only, which is empty in a clean checkout,
# so scan the PR's commits explicitly with the binary pre-commit built.
+23
View File
@@ -49,6 +49,8 @@ repos:
hooks:
- id: check-toml
stages: ['pre-commit']
- id: check-json
stages: ['pre-commit']
- id: check-merge-conflict
stages: ['pre-commit']
@@ -114,6 +116,27 @@ repos:
require_serial: true
stages: ['pre-push']
# Pre-push only: the suite takes minutes. Lint runs it by id. The uncreatable GIT_DIR makes a
# git fixture that keeps the caller's GIT_* fail instead of writing to this repository.
- id: script-tests
name: A script change passes its tests in tests/scripts (scripts/AGENTS.md)
description: python3 -m unittest discover -s tests/scripts
entry: env GIT_DIR=/dev/null/not-a-repo python3 -m unittest discover -s tests/scripts
language: system
files: ^(scripts/|tests/scripts/|roles/[^/]+/meta/)
pass_filenames: false
stages: ['pre-push']
# always_run: its inputs span workflows, Dockerfiles and docs/images, and it fails on a missing one.
- id: check-image-pins
name: Image pins name an image of the image.yml matrix, which has its job image, labels and docs (images/AGENTS.md)
description: python3 scripts/check_image_versions.py pins
entry: python3 scripts/check_image_versions.py pins
language: system
pass_filenames: false
always_run: true
stages: ['pre-commit']
# SECURITY.md's accepted risks rest on the Collection shipping roles only. It sits before
# ansible-lint, whose fail_fast would otherwise hide this message.
- id: refuse-plugins
+3 -3
View File
@@ -11,7 +11,7 @@ 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`
(without its Docker driver: Lint's "Test the repository scripts" step runs the tests that import it), and
(without its Docker driver: Lint's run of the `script-tests` hook 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
@@ -20,7 +20,7 @@ Ubuntu 26.04 with:
(`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
keep layers small. The local hooks (`reuse-lint`,
`antsibull-changelog-lint`, `ansible-lint`) are `language: system`: they run from `/opt/venv`, which is why
`antsibull-changelog-lint`, `ansible-lint`, `script-tests`, `check-image-pins`) are `language: system`: they run from `/opt/venv`, which is why
that directory must be on `PATH` (it is, in the image).
- **`ansible-test sanity` virtualenvs**, primed in `/root/.ansible/test`, and Python 3.11, 3.13 and 3.14 as
`python3.11` / `python3.13` / `python3.14` (python-build-standalone, installed with uv) next to the distribution's
@@ -63,7 +63,7 @@ jobs:
`/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
`PIP_NO_INDEX`), 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`
are the real consumers.
+1 -2
View File
@@ -63,8 +63,7 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
image; a job downloads at run time only on the slow path (a pull request that changes a pin
file). *Why:* a run that downloads is slower and depends on the network. *Held:* control: on
the fast path Lint and Build cut the network by environment, so a download through pip or a
proxy-honouring client fails the job; review for a raw socket, for the script tests, which keep
network, and for Molecule.
proxy-honouring client fails the job; review for a raw socket and for Molecule.
- **Each Dockerfile upgrades the base image's packages in its first apt layer.** *Why:* Ubuntu
publishes package updates before it refreshes the base image. *Held:* review.
- **Recorded speed:** a speed optimisation that adds machinery states its measured saving where
+1 -1
View File
@@ -15,7 +15,7 @@
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
# 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-dev uses.
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
# molecule is there for Lint's run of the script-tests hook, 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`
+1 -1
View File
@@ -12,7 +12,7 @@ pre-commit==4.7.0
antsibull-changelog==0.38.0
galaxy-importer==0.4.45
reuse==6.3.0
# molecule without its Docker driver: Lint's "Test the repository scripts" step imports it in
# molecule without its Docker driver: Lint's run of the script-tests hook 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),
+2 -2
View File
@@ -12,8 +12,8 @@ rules for scripts (prefer a standard tool, comment length) are in
- **A script change comes with its test in `tests/scripts/`** (`test_<script>.py`), in the same
pull request. Run them with `python3 -m unittest discover -s tests/scripts`.
*Why:* a script decides whether a pull request passes, so an untested change can wave through
what it should stop. *Held:* control: the Lint check's "Test the repository scripts" step runs
the tests; review for whether the change is tested at all.
what it should stop. *Held:* control: the `script-tests` pre-push hook runs the
tests, and the Lint check runs it again; review for whether the change is tested at all.
- **A line added to `tests/sanity/ignore-common.txt` is a last resort and carries its reason** as
a trailing `# ...` comment. Fix the finding first. A finding of one ansible-core version only
goes in a committed `ignore-<MAJOR.MINOR>.txt`, which the Build job appends.