Files
ruvnet--RuView/python/tombstone/tests/test_tombstone.py
T
ruv f9d99c50d9 feat(adr-117/p5+p-tomb): pip-release workflow + v1.99.0 tombstone wheel
P5 — `.github/workflows/pip-release.yml`:
- cibuildwheel matrix per ADR §5.4: manylinux x86_64 + aarch64,
  macos x86_64 + arm64, win amd64 (5 wheels via abi3-py310 stable
  ABI — one binary per OS/arch covers Python 3.10–3.13)
- Linux aarch64 cross-builds via QEMU; rustup 1.82 pinned in
  CIBW_BEFORE_ALL_LINUX for reproducibility
- Per-wheel smoke test: import wifi_densepose, assert hello()=="ok"
- sdist via `maturin sdist`
- Trigger: workflow_dispatch + push to `v*-pip` tags ONLY (never
  on regular commits — won't accidentally publish)
- TestPyPI dry-run gate via `repository-url: https://test.pypi.org/legacy/`
- Production PyPI publish via Trusted Publisher OIDC (no API tokens
  in GH secrets per ADR §9). Requires one-time PyPI Trusted Publisher
  registration before the first publish can fire.
- Q3 (witness hash v2 — ADR-117 §11.3) flagged in workflow comments
  as a hard gate before the first tag.

P-tomb — `python/tombstone/`:
- Separate `wifi-densepose==1.99.0` sdist+wheel using setuptools
  backend (NOT maturin — tombstone is pure Python, no Rust).
- `src/wifi_densepose/__init__.py` raises ImportError with the
  migration URL on import. Verified locally: 2.7 KB wheel,
  `pip install` then `import wifi_densepose` raises ImportError
  with `pip install wifi-densepose==2.0.0` hint + repo URL.
- 5 unit tests (`tests/test_tombstone.py`) lock the file content
  down: must `raise ImportError`, must contain v2 install hint
  and migration URL, must NOT contain any `def`/`class`/`import`
  beyond the bare `raise` — so a well-intentioned refactor can't
  accidentally bloat the tombstone into a real module that loads
  partway before failing.

Both wheels are published by the same pip-release.yml workflow:
- `v1.99.0-pip` tag → publishes tombstone (or via workflow_dispatch
  with `target: v1-99-tombstone`)
- `v2.X.Y-pip` tag → publishes the v2 wheel matrix

Per ADR-117 §7.3: tag and publish 1.99.0-pip FIRST so the tombstone
claims the "current" slot in pip's resolver, THEN publish 2.0.0-pip.

Test count unchanged in main python/ suite (156/156). Tombstone
sub-suite: 5 passing.

Refs: docs/adr/ADR-117-pip-wifi-densepose-modernization.md §5.4, §7
Refs: #785

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-24 11:39:04 -04:00

51 lines
1.9 KiB
Python

"""ADR-117 §7.2 — Unit test for the v1.99.0 tombstone wheel.
Verifies the *file content* of the tombstone module without actually
importing it (importing it would raise ImportError, which is the
behaviour under test). The CI workflow `pip-release.yml` runs the
real end-to-end install + import test inside an ephemeral venv.
"""
from __future__ import annotations
import pathlib
TOMBSTONE = pathlib.Path(__file__).parent.parent / "src" / "wifi_densepose" / "__init__.py"
def test_tombstone_file_exists() -> None:
assert TOMBSTONE.is_file(), f"tombstone module missing: {TOMBSTONE}"
def test_tombstone_raises_import_error() -> None:
"""The source must call `raise ImportError(...)`. We grep rather
than exec because actually running it would terminate the test."""
src = TOMBSTONE.read_text(encoding="utf-8")
assert "raise ImportError(" in src, "tombstone does not raise ImportError"
def test_tombstone_contains_v2_install_hint() -> None:
src = TOMBSTONE.read_text(encoding="utf-8")
assert "pip install wifi-densepose==2.0.0" in src, (
"tombstone ImportError message must include the v2 pip install hint"
)
def test_tombstone_contains_migration_url() -> None:
src = TOMBSTONE.read_text(encoding="utf-8")
assert "docs/pip-migration.md" in src, (
"tombstone must point users at the migration guide"
)
def test_tombstone_is_minimal() -> None:
"""The whole point of the tombstone is that it's MINIMAL — no
imports, no helper functions, no class definitions. Lock that
down so a well-intentioned refactor doesn't accidentally bloat it
into a real module that loads partway before failing."""
src = TOMBSTONE.read_text(encoding="utf-8")
forbidden = ("def ", "class ", "import wifi_densepose", "import os", "import sys")
for f in forbidden:
assert f not in src, f"tombstone must not contain {f!r} — it should ONLY raise"