fix(release): package runtime SQL migrations
Publish verified container image / verify (push) Canceled after 0s
Publish verified container image / publish (push) Canceled after 0s

This commit is contained in:
Hermes Agent
2026-08-10 17:39:12 +09:00
parent 46904621ff
commit 90b72863a2
7 changed files with 117 additions and 10 deletions
+31 -2
View File
@@ -20,6 +20,9 @@ CANARY = b"TREX_SECRET_CANARY_DO_NOT_SHIP"
COMMIT_RE = re.compile(r"^[0-9a-f]{40}$")
DIGEST_RE = re.compile(r"(?:^|\s)digest:\s*(sha256:[0-9a-f]{64})(?:\s|$)")
IMAGE_ID_RE = re.compile(r"^sha256:[0-9a-f]{64}$")
DEFAULT_MIGRATION_DIR = (
Path(__file__).resolve().parents[1] / "trex_core" / "adapters" / "persistence" / "sql"
)
MAX_ARCHIVE_DEPTH = 8
MAX_ARCHIVE_MEMBERS = 200_000
MAX_ARCHIVE_EXTRACTED_BYTES = 2 * 1024 * 1024 * 1024
@@ -174,13 +177,39 @@ SMOKE_PROBES: tuple[tuple[str, ...], ...] = (
)
def canonical_migration_names(migration_dir: Path = DEFAULT_MIGRATION_DIR) -> tuple[str, ...]:
names = tuple(sorted(path.name for path in migration_dir.glob("*.sql") if path.is_file()))
if not names:
raise ValueError("canonical migration inventory is empty")
return names
def migration_inventory_code(expected: tuple[str, ...]) -> str:
return (
"from trex_core.adapters.persistence.migrate import migration_files;"
f"expected={expected!r};"
"actual=tuple(path.name for path in migration_files());"
"assert expected and actual == expected, 'installed migration inventory mismatch'"
)
def _ensure_result_clean(result: Result) -> None:
if CANARY in (result.stdout + result.stderr).encode():
raise ValueError("canary marker found on a scanned surface")
def smoke_image(image: str, runner: Runner, timeout: int = 30) -> None:
for index, probe in enumerate(SMOKE_PROBES):
def smoke_image(
image: str,
runner: Runner,
timeout: int = 30,
migration_dir: Path = DEFAULT_MIGRATION_DIR,
) -> None:
expected_migrations = canonical_migration_names(migration_dir)
probes = (
*SMOKE_PROBES,
("python", "-I", "-c", migration_inventory_code(expected_migrations)),
)
for index, probe in enumerate(probes):
name = f"trex-core-smoke-{os.getpid()}-{index}"
command = [
"docker",