From 4fb9b5b1683dc6fb7f548157451b05e7c5d45919 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 6 Nov 2026 10:57:24 +0200 Subject: [PATCH] ci: the release job installs the test extra instead of restating it Pushing v2.4.0 failed. Every release test job died 0.85s in with `ModuleNotFoundError: No module named 'hypothesis'` while collecting `tests/biology/test_pass_isolation.py`, and `-x` turned that into one line of output. Nothing was published: the publish job needs the test job, so sdist, wheels and the PyPI upload were all skipped and the version number is still free. The cause is dependency drift with a long fuse. `build-wheels.yml` installed `pytest pandas` by name and then the built wheel with the `[mcp]` extra alone, while `test.yml` installs it with `[test,mcp]`. That hand-written list was accurate until a test module imported something outside it. `hypothesis` entered `tests/support/pipelines/registry.py` on 2026-10-31, so every release has been broken since -- invisibly, because no release was attempted between then and now, and because the suite CI actually runs was green the whole time. So the release job now installs the extras rather than restating them: `[test]` is where pytest, pandas, hypothesis, pytest-xdist and airr are declared, and `pyproject.toml` stays the only place that knows the list. A pin in the CI contract enforces it, since the thing that makes this class of bug expensive is that a tag is the first place it shows. It asserts the release job installs the wheel with `[test]` and names no test dependency by hand. Verified by pointing it at the pre-fix workflow: it fails and quotes the offending line. --- .github/workflows/build-wheels.yml | 24 +++++++++---- tests/support/meta/test_ci_contract.py | 50 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index f0d15db6..32f59ca7 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -108,21 +108,31 @@ jobs: print(f'Patched {path} -> $VERSION') " - - name: Install maturin + test deps + - name: Install maturin run: | python -m pip install --upgrade pip - pip install "maturin>=1.5,<2.0" pytest pandas + pip install "maturin>=1.5,<2.0" - name: Build & install GenAIRR wheel run: maturin build --release --out dist - - name: Install built wheel (with [mcp] extra for the test suite) + - name: Install built wheel (with the [test,mcp] extras) shell: bash run: | - # Install the wheel with the [mcp] extra so the MCP test file - # gets fastmcp and runs in CI. Without this, tests/components/mcp/test_mcp_server.py - # would call pytest.importorskip('fastmcp') and silently skip. + # The extras are the single source of truth for what the suite + # needs: [test] carries pytest, pandas, hypothesis, pytest-xdist + # and airr, and [mcp] carries fastmcp so the MCP test file runs + # here instead of calling pytest.importorskip('fastmcp') and + # silently skipping. + # + # This step used to hand-list `pytest pandas` and then install the + # wheel with [mcp] alone. The list drifted the moment a test + # module imported anything else: `hypothesis` arrived on + # 2026-10-31 and every release job from then on died at collection + # with ModuleNotFoundError, which `-x` turns into a one-line + # failure 0.85s in. Install the extras and the drift cannot recur. + # `test.yml` installs the same way. WHEEL=$(ls dist/genairr-*.whl) - pip install "${WHEEL}[mcp]" + pip install "${WHEEL}[test,mcp]" - name: Run pytest run: pytest tests/ -x -q diff --git a/tests/support/meta/test_ci_contract.py b/tests/support/meta/test_ci_contract.py index c5212cd6..46961d57 100644 --- a/tests/support/meta/test_ci_contract.py +++ b/tests/support/meta/test_ci_contract.py @@ -69,3 +69,53 @@ def test_ci_runs_on_every_pull_request_whatever_its_base(): f"`pull_request` is filtered by branch ({offending}), so a pull " f"request based on anything else gets no checks at all -- not a " f"failure, not a pending run, nothing to notice") + + +def _release_workflow() -> list[str]: + """The lines of the release workflow.""" + return (paths.repo_root() / ".github" / "workflows" / "build-wheels.yml").read_text( + encoding="utf-8").splitlines() + + +def test_the_release_workflow_installs_the_declared_test_extra(): + """A hand-written dependency list in the release job drifts silently, and + the drift only shows up when you tag. + + `build-wheels.yml` installed `pytest pandas` by name and then the built + wheel with the `[mcp]` extra alone. That matched the suite's needs until a + test module imported something else. `hypothesis` arrived in + `tests/support/pipelines/registry.py` on 2026-10-31; from then on every + release test job died at collection with `ModuleNotFoundError`, which + `pytest -x` reports as a single failure 0.85s in. Nothing else noticed, + because `test.yml` installs the wheel with `[test,mcp]` and was green + throughout -- so the break was invisible until `v2.4.0` was pushed, and + the first evidence was a failed release. + + The extras in `pyproject.toml` are the one place that knows what the + suite needs. The release job must install them rather than restate them. + """ + lines = _release_workflow() + + wheel_installs = [line for line in lines + if "pip install" in line and "${WHEEL}" in line] + assert wheel_installs, ( + "the release workflow no longer installs the built wheel by path; " + "this pin cannot see what extras the test job gets") + missing = [line.strip() for line in wheel_installs if "[test" not in line] + assert missing == [], ( + "the release job installs the built wheel without the [test] extra:\n " + + "\n ".join(missing) + + "\n\nThe extra is what carries pytest, pandas, hypothesis, " + "pytest-xdist and airr. Without it the suite fails at collection " + "when a test module imports any of them -- and only when you tag.") + + restated = [line.strip() for line in lines + if "pip install" in line + and any(f" {pkg}" in line + for pkg in ("pytest", "pandas", "hypothesis")) + and "${WHEEL}" not in line] + assert restated == [], ( + "the release workflow names test dependencies by hand:\n " + + "\n ".join(restated) + + "\n\nInstall them through the wheel's [test] extra instead, so " + "pyproject.toml stays the only place that knows the list.")