From aaaf0e8ecc15b6aa57743028f0f307b0012165da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Miralles=20Ranca=C3=B1o?= <68760931+FlagshipDev@users.noreply.github.com> Date: Fri, 14 Aug 2026 10:37:11 +0200 Subject: [PATCH] Three action bumps taken upstream, and the image bump declined with a measurement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four Dependabot pull requests (#27–#30) had been open here since 12 August, all four green. Three are worth taking and one breaks the image — and **none of them could survive where they were opened**, which is the part worth saying. This repository is derived. The publish step makes it exactly equal to the source tree, and every file those four touch comes from there — the `Dockerfile` and four of the workflows are copied, and `.github/workflows/ci.yml` is *generated* from the source repository's own CI. Merging one here is a change that lives until the next publication and then disappears without a word, and Dependabot reopens it. So the bumps were applied upstream and arrive by the ordinary route. **Taken**, each SHA checked against the tag it claims to be, through the API rather than trusted from the diff: * `actions/checkout` v4 → **v7.0.1** * `actions/setup-python` v5 → **v7.0.0** * `actions/upload-artifact` v4 → **v7.0.1** The third is taken on weaker evidence and this says so: it appears only in `scorecard.yml`, which by a decision written into that file runs on `push: main` and weekly and never on a pull request — so #28 being green proved nothing about the bump inside it. It is taken because the next push to `main` exercises it and a failure there is loud rather than silent. **Declined:** `python:3.12-slim` → `3.14-slim`. `requires-python` is `>=3.12,<3.13` and the build stage installs with the base image's interpreter, so the image does not build: ``` ERROR: Package 'hullwork' requires a different Python: 3.14.7 not in '<3.13,>=3.12' ``` Its checks were green because no workflow that runs on a pull request builds the image — only the release and edge workflows do, on a tag and on a schedule. The first sign would have been a release failing. The Dockerfile already said *"Dependabot proposes the bump; a human takes it"*, which is a rule that depends on the human being awake. There is now a test tying the base image of **both stages** to `requires-python`, so the same proposal fails in `gates` in three seconds instead of at the next release. It reads both files and restates neither — verified by rewriting it to hard-code the version, which fails. Three reintroductions, three caught. Signed-off-by: Javier Miralles Rancaño <68760931+FlagshipDev@users.noreply.github.com> --- .forgejo/workflows/ci.yml | 6 +- .github/workflows/ci.yml | 6 +- .github/workflows/codeql.yml | 2 +- .github/workflows/edge.yml | 2 +- .github/workflows/release.yml | 4 +- .github/workflows/scorecard.yml | 4 +- ...test_the_image_runs_a_python_we_support.py | 87 +++++++++++++++++++ 7 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 tests/test_the_image_runs_a_python_we_support.py diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index acca729..dc020c3 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -27,8 +27,8 @@ jobs: gates: runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: { python-version: "3.12" } # **Installed from `uv.lock`, not resolved fresh** (item 149). `pip install -e ".[dev]"` @@ -93,7 +93,7 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: { fetch-depth: 0 } - name: every commit carries a sign-off run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acca729..dc020c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,8 @@ jobs: gates: runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: { python-version: "3.12" } # **Installed from `uv.lock`, not resolved fresh** (item 149). `pip install -e ".[dev]"` @@ -93,7 +93,7 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: { fetch-depth: 0 } - name: every commit carries a sign-off run: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 522a1f2..38dce30 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -37,7 +37,7 @@ jobs: # The one write this needs, and it writes findings rather than code. security-events: write steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: github/codeql-action/init@c3400c2f38909e0dcf3c3a41f2030a8217be5d3e # v3 with: languages: python diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index 69f47c8..beaccfb 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -51,7 +51,7 @@ jobs: id-token: write attestations: write steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Push edge and the commit id: image diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1965be3..e682048 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,8 +47,8 @@ jobs: id-token: write attestations: write steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: { python-version: "3.12" } # **The tag is the version, and it has to agree with the package.** A release whose image says diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 801559b..fda5ca2 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -46,7 +46,7 @@ jobs: # What `publish_results` signs with. No key of ours, same as the release attestations. id-token: write steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -60,7 +60,7 @@ jobs: # The SARIF is kept as a run artefact rather than uploaded: readable when somebody wants the # detail, and not sitting permanently in the tab meant for code defects. - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: scorecard-results path: results.sarif diff --git a/tests/test_the_image_runs_a_python_we_support.py b/tests/test_the_image_runs_a_python_we_support.py new file mode 100644 index 0000000..d8af9b0 --- /dev/null +++ b/tests/test_the_image_runs_a_python_we_support.py @@ -0,0 +1,87 @@ +"""The base image and `requires-python` are one fact in two files. Item 254. + +Dependabot proposed `python:3.12-slim` → `3.14-slim` and **every check on that pull request was +green**, because no workflow that runs on a pull request builds the image — only `release.yml` and +`edge.yml` do, on a tag and on a schedule. The image does not build: + + ERROR: Package 'hullwork' requires a different Python: 3.14.7 not in '<3.13,>=3.12' + +So the first sign would have been a release failing, or a nightly nobody reads. + +The Dockerfile already said *"Dependabot proposes the bump; a human takes it"*, and item 017 is the +answer to that: **a guardrail that depends on somebody remembering is not a guardrail.** This one +takes three seconds and runs on every pull request. + +Verified by reintroducing the defect it covers. +""" + +from __future__ import annotations + +import re +import tomllib +from pathlib import Path + +from packaging.specifiers import SpecifierSet +from packaging.version import Version + +HERE = Path(__file__).resolve().parent.parent + +#: `FROM python:-slim@sha256:…`, in either stage. The digest is what makes the build +#: reproducible (Scorecard, Pinned-Dependencies) and the tag beside it is what a reader believes, so +#: the tag is what this reads: a digest that disagreed with its own comment would be a different +#: defect and one no test can see from here. +_BASE = re.compile(r"^FROM\s+python:(\d+\.\d+)-slim", re.M) + + +def _supported() -> SpecifierSet: + with (HERE / "pyproject.toml").open("rb") as source: + return SpecifierSet(tomllib.load(source)["project"]["requires-python"]) + + +def test_every_stage_builds_on_a_python_this_package_supports() -> None: + """**Both stages, not only the first.** The build stage is where `pip install` refuses, so a + test that read one `FROM` would catch the bump that breaks the build and miss the one that ships + a runtime whose interpreter cannot import the virtualenv the build stage produced. + """ + found = _BASE.findall((HERE / "Dockerfile").read_text(encoding="utf-8")) + + assert len(found) >= 2, f"the Dockerfile has {len(found)} python stages; it had two" + supported = _supported() + for version in found: + assert Version(version) in supported, ( + f"the image is built on python {version}, which is outside this package's " + f"requires-python ({supported}). `pip install .` refuses, so the image does not build " + f"— and no workflow that runs on a pull request would have told you." + ) + + +def test_the_guard_reads_both_files_rather_than_restating_either() -> None: + """**No copy of the supported version anywhere in this file's code.** A test that hard-codes + what it is checking is a third place the fact lives, and the one nobody updates: it would keep + passing against a `requires-python` that had moved, which is the failure this file exists to + prevent wearing the other hat. + + Asserted over the code rather than the whole file, because the prose above quotes a measured + error message and a rule that forbids naming a version in a sentence forbids explaining + anything. The first version of this test failed on its own docstring, which is the distinction + arriving the hard way. + """ + import ast + + tree = ast.parse(Path(__file__).read_text(encoding="utf-8")) + prose = { + said + for node in [tree, *ast.walk(tree)] + if isinstance(node, ast.Module | ast.ClassDef | ast.FunctionDef) + and (said := ast.get_docstring(node, clean=False)) is not None + } + written = [ + node.value + for node in ast.walk(tree) + if isinstance(node, ast.Constant) and isinstance(node.value, str) + and node.value not in prose + and re.fullmatch(r"\d+\.\d+(\.\d+)?", node.value.strip()) + ] + + assert not written, f"this test writes {written} into its code instead of reading it" + assert "requires-python" in (HERE / "pyproject.toml").read_text(encoding="utf-8")