49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""Release artifacts must not masquerade as something they are not.
|
|
|
|
* No ``SHA256SUMS`` at the repository root: the only checksum manifest ever
|
|
kept there described the 2026-08-01 blueprint package, not the working
|
|
tree, and now lives under ``docs/archive/blueprint-package/``.
|
|
* Any ``dist/ragcore-v<version>.zip`` directly under ``dist/`` must carry the
|
|
current release version; stale local zips belong in ``dist/archive/``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def _current_version() -> str:
|
|
with (REPO_ROOT / "pyproject.toml").open("rb") as handle:
|
|
return str(tomllib.load(handle)["project"]["version"])
|
|
|
|
|
|
def test_no_stale_checksum_manifest_at_the_repository_root() -> None:
|
|
assert not (REPO_ROOT / "SHA256SUMS").exists(), (
|
|
"a root SHA256SUMS looks like it validates the working tree; archive it under "
|
|
"docs/archive/ or regenerate it as part of a real release"
|
|
)
|
|
archived = REPO_ROOT / "docs" / "archive" / "blueprint-package" / "SHA256SUMS"
|
|
assert archived.is_file()
|
|
assert (archived.parent / "README.md").is_file(), "the archived manifest must be explained"
|
|
|
|
|
|
def test_top_level_dist_archives_match_the_current_version() -> None:
|
|
dist = REPO_ROOT / "dist"
|
|
if not dist.is_dir():
|
|
return
|
|
version = _current_version()
|
|
pattern = re.compile(r"^ragcore-v(?P<version>\d+\.\d+\.\d+)\.zip$")
|
|
stale = [
|
|
path.name
|
|
for path in dist.iterdir()
|
|
if path.is_file() and (match := pattern.match(path.name)) and match["version"] != version
|
|
]
|
|
assert not stale, (
|
|
f"dist/ holds artifacts of another release than {version}: {stale}; move them to "
|
|
"dist/archive/ (see dist/README.md)"
|
|
)
|