diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index f0d15db..32f59ca 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 c5212cd..46961d5 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.")