Files
trex-core/tests/release/test_package_distribution.py
T
Hermes Agent 90b72863a2
Publish verified container image / verify (push) Canceled after 0s
Publish verified container image / publish (push) Canceled after 0s
fix(release): package runtime SQL migrations
2026-08-10 17:39:12 +09:00

50 lines
1.3 KiB
Python

from __future__ import annotations
import shutil
import subprocess
import zipfile
from pathlib import Path
REPO = Path(__file__).resolve().parents[2]
MIGRATION_PACKAGE_PREFIX = "trex_core/adapters/persistence/sql/"
def test_built_wheel_contains_exact_canonical_migration_inventory(tmp_path: Path):
source = tmp_path / "source"
source.mkdir()
shutil.copy2(REPO / "pyproject.toml", source / "pyproject.toml")
shutil.copytree(REPO / "trex_core", source / "trex_core")
output = tmp_path / "dist"
subprocess.run(
[
"uv",
"build",
"--wheel",
"--no-build-logs",
"--no-create-gitignore",
"--out-dir",
str(output),
str(source),
],
check=True,
capture_output=True,
text=True,
)
wheels = list(output.glob("*.whl"))
assert len(wheels) == 1
expected = sorted(
path.relative_to(REPO).as_posix()
for path in (REPO / MIGRATION_PACKAGE_PREFIX).glob("*.sql")
)
assert expected
with zipfile.ZipFile(wheels[0]) as wheel:
actual = sorted(
name
for name in wheel.namelist()
if name.startswith(MIGRATION_PACKAGE_PREFIX) and name.endswith(".sql")
)
assert actual == expected