diff --git a/.altru/LESSONS.md b/.altru/LESSONS.md new file mode 100644 index 0000000..2b7b4a0 --- /dev/null +++ b/.altru/LESSONS.md @@ -0,0 +1,2 @@ +# LESSONS - PostQuantum +- v0.2.0 shipped packages named 0.1.0 -> pyproject.toml had its own static version while the release check compared the tag only with __version__ -> version now read from src/pqdocket/__init__.py (hatch dynamic version); release evidence fails if an artifact name lacks the version; CI builds the package on every PR. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e80fac..2cba1ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,13 @@ jobs: run: mypy src - name: Test run: pytest + - name: Build package and check its version matches the code + run: | + python -m pip install build + python -m build + version=$(python -c "import pqdocket; print(pqdocket.__version__)") + ls dist + for f in dist/*; do case "$f" in *"-$version"*) ;; *) echo "$f does not carry version $version"; exit 1;; esac; done - name: Scan this repository and validate the report against the schema run: | pqdocket scan . --output pqc-report.json diff --git a/pyproject.toml b/pyproject.toml index db681c2..a0ae5c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pqdocket" -version = "0.1.0" +dynamic = ["version"] description = "Evidence-led assurance for post-quantum migration: prove specific claims, not scores" readme = "README.md" requires-python = ">=3.11" @@ -33,3 +33,7 @@ target-version = "py311" [tool.mypy] python_version = "3.11" strict = true + +[tool.hatch.version] +# Single source of truth for the version: src/pqdocket/__init__.py +path = "src/pqdocket/__init__.py" diff --git a/scripts/release_evidence.py b/scripts/release_evidence.py index de51ae3..3e6d618 100644 --- a/scripts/release_evidence.py +++ b/scripts/release_evidence.py @@ -103,6 +103,10 @@ def problems(record: dict[str, Any]) -> list[str]: found.append(f"{tests['failures']} failed, {tests['errors']} errors") if not record["artifacts"]: found.append("no release artifacts found") + version = record["project"]["version"] + for artifact in record["artifacts"]: + if f"-{version}" not in artifact["name"]: + found.append(f"artifact {artifact['name']} does not carry version {version}") if not record["source"]["commit"]: found.append("source commit unknown") if record["source"]["uncommitted_changes"]: diff --git a/src/pqdocket/__init__.py b/src/pqdocket/__init__.py index 9dae9f2..27870c8 100644 --- a/src/pqdocket/__init__.py +++ b/src/pqdocket/__init__.py @@ -1,4 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 """pqdocket: evidence-led assurance for post-quantum migration.""" -__version__ = "0.2.0" +__version__ = "0.2.1" diff --git a/tests/test_release_evidence.py b/tests/test_release_evidence.py index 51c80f3..7d1968a 100644 --- a/tests/test_release_evidence.py +++ b/tests/test_release_evidence.py @@ -21,7 +21,8 @@ def _junit(path: Path, tests: int, failures: int = 0) -> Path: def _dist(tmp_path: Path) -> Path: dist = tmp_path / "dist" dist.mkdir() - (dist / "pqdocket-0.1.0-py3-none-any.whl").write_bytes(b"wheel") + from pqdocket import __version__ + (dist / f"pqdocket-{__version__}-py3-none-any.whl").write_bytes(b"wheel") return dist @@ -54,3 +55,12 @@ def test_missing_artifacts_block_release(tmp_path: Path) -> None: code = release_evidence.main(["--dist", str(tmp_path / "nothing"), "--junit", str(_junit(tmp_path / "j.xml", 5)), "--out", str(tmp_path / "e.json")]) assert code == 1 + + +def test_artifact_with_wrong_version_blocks_release(tmp_path: Path) -> None: + dist = tmp_path / "dist" + dist.mkdir() + (dist / "pqdocket-0.0.1-py3-none-any.whl").write_bytes(b"old") + code = release_evidence.main(["--dist", str(dist), "--junit", + str(_junit(tmp_path / "j.xml", 5)), "--out", str(tmp_path / "e.json")]) + assert code == 1