CI / Rust Checks (pull_request) Failing after 13m41s
CI / UI Checks (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Deploy (pull_request) Skipped
Community Release / release (push) Failing after 13m33s
Recovery delivery of the accumulated, TL-accepted Epic 3 work that had never been
committed to Git (stories 3.6-3.17, see the crank board). Story 3.18 is not accepted
yet and is deliberately excluded: its logging surface, its capability registration,
its oracle projections and its tests are not part of this tree.
Accepted scope
- 3.6 typed static Resource Drafts; 3.7 publication and exact binding of static
Resource Versions; 3.8 MCP discovery/read and revocation of static Resources;
- 3.9 Resource import/export in API and UI plus TLS dependency maintenance;
3.10 REST-backed Resource templates; 3.11 shared REST read runtime and the MCP
revision/capability foundation;
- 3.12 parameterised Prompt Drafts with preview; 3.13 Prompt publication and exact
version binding to Agents; 3.14 MCP prompts; 3.15 Prompt import/export;
- 3.16 composite Prompts with published Resources (dependency content scan plus
dynamic read through the accepted 3.11 runtime, admin preview and MCP prompts/get);
- 3.17 bounded MCP completion suggestions from typed published schemas and the
resources/list admission fix for bound template publications.
Accepted evidence being reused (unchanged code paths)
- 3.16 candidate: core 7, admin-api 22, registry 4, mcp-server 4, UI 6; one final
`just verify` run 1651 passed / 0 failed / 2 ignored.
- 3.17 candidate: full run 1672 passed / 0 failed / 2 ignored, QA targeted reruns and
a real MCP Inspector 2.12.0 client smoke.
Delivery engineering in this commit
- CI: one event per change (feature branches are gated by their pull request, push
runs only on main), story events run the changed packages, the full workspace suite
stays the feature/release gate; no cache/sharding without a measured runner check.
- Release: the packaged archives, checksums and SBOM are now uploaded to the Gitea
release entry of the tag instead of dying with the runner workspace.
Not included on purpose: Story 3.18 work, build caches, runtime databases, local
credentials and scratch evidence.
Refs: crank kanban t_e39d7263; baseline 1b6db09bd1.
139 lines
5.4 KiB
Python
139 lines
5.4 KiB
Python
"""AT-3 (release durability): the artifacts of a tag land on the Gitea release, idempotently."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import importlib.util
|
|
import io
|
|
import json
|
|
import sys
|
|
import tempfile
|
|
import threading
|
|
import unittest
|
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
SCRIPT = ROOT / "scripts" / "publish-gitea-release.py"
|
|
|
|
|
|
def load_module():
|
|
spec = importlib.util.spec_from_file_location("publish_gitea_release", SCRIPT)
|
|
assert spec is not None and spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
sys.modules[spec.name] = module
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
class Stub:
|
|
def __init__(self) -> None:
|
|
self.release_assets: list[dict] = []
|
|
self.created = False
|
|
self.uploaded: list[str] = []
|
|
self.created_payload: dict = {}
|
|
|
|
def handler(self):
|
|
stub = self
|
|
|
|
class Handler(BaseHTTPRequestHandler):
|
|
def log_message(self, format, *args): # noqa: A002 - base class signature
|
|
return
|
|
|
|
def _reply(self, status: int, payload: dict) -> None:
|
|
body = json.dumps(payload).encode("utf-8")
|
|
self.send_response(status)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.send_header("Content-Length", str(len(body)))
|
|
self.end_headers()
|
|
self.wfile.write(body)
|
|
|
|
def do_GET(self):
|
|
if self.path.endswith("/releases/tags/v1.2.3") and stub.created:
|
|
self._reply(200, {"id": 7, "assets": stub.release_assets})
|
|
else:
|
|
self._reply(404, {"message": "not found"})
|
|
|
|
def do_POST(self):
|
|
length = int(self.headers.get("Content-Length") or 0)
|
|
body = self.rfile.read(length)
|
|
if self.path.endswith("/releases"):
|
|
stub.created = True
|
|
stub.created_payload = json.loads(body)
|
|
self._reply(201, {"id": 7, "assets": []})
|
|
return
|
|
if "/releases/7/assets?name=" in self.path:
|
|
name = self.path.rsplit("name=", 1)[1]
|
|
stub.uploaded.append(name)
|
|
stub.release_assets.append(
|
|
{"name": name, "browser_download_url": f"http://stub/assets/{name}"}
|
|
)
|
|
self._reply(201, {"name": name, "browser_download_url": f"http://stub/assets/{name}"})
|
|
return
|
|
self._reply(404, {"message": "not found"})
|
|
|
|
return Handler
|
|
|
|
|
|
class PublishGiteaReleaseTests(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.module = load_module()
|
|
self.stub = Stub()
|
|
self.server = ThreadingHTTPServer(("127.0.0.1", 0), self.stub.handler())
|
|
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
|
self.thread.start()
|
|
self.api = f"http://127.0.0.1:{self.server.server_address[1]}"
|
|
self.tmp = tempfile.TemporaryDirectory()
|
|
self.dist = Path(self.tmp.name)
|
|
(self.dist / "crank-community-admin-api-v1.2.3.tar.gz").write_bytes(b"admin")
|
|
(self.dist / "crank-community-v1.2.3-checksums.txt").write_text("deadbeef admin.tar.gz\n")
|
|
(self.dist / "nested").mkdir()
|
|
(self.dist / "nested" / "admin-api").write_bytes(b"raw")
|
|
self.notes = self.dist / "RELEASE-NOTES.md"
|
|
self.notes.write_text("## v1.2.3\n", encoding="utf-8")
|
|
|
|
def tearDown(self) -> None:
|
|
self.server.shutdown()
|
|
self.server.server_close()
|
|
self.tmp.cleanup()
|
|
|
|
def publish(self) -> tuple[int, str]:
|
|
output = io.StringIO()
|
|
with contextlib.redirect_stdout(output), contextlib.redirect_stderr(output):
|
|
code = self.module.publish(
|
|
self.api,
|
|
"bsodfather/crank",
|
|
"v1.2.3",
|
|
"Crank Community v1.2.3",
|
|
self.notes,
|
|
self.dist,
|
|
True,
|
|
"stub-token-never-printed",
|
|
)
|
|
return code, output.getvalue()
|
|
|
|
def test_release_is_created_with_notes_and_every_top_level_artifact(self) -> None:
|
|
code, output = self.publish()
|
|
self.assertEqual(code, 0, output)
|
|
self.assertEqual(self.stub.created_payload["tag_name"], "v1.2.3")
|
|
self.assertTrue(self.stub.created_payload["prerelease"])
|
|
self.assertEqual(self.stub.created_payload["body"], "## v1.2.3\n")
|
|
self.assertEqual(
|
|
self.stub.uploaded,
|
|
["crank-community-admin-api-v1.2.3.tar.gz", "crank-community-v1.2.3-checksums.txt"],
|
|
"every top-level artifact and nothing from the nested build dir",
|
|
)
|
|
self.assertNotIn("stub-token-never-printed", output, "the token must never reach the log")
|
|
|
|
def test_second_run_reuses_the_release_and_skips_existing_assets(self) -> None:
|
|
self.assertEqual(self.publish()[0], 0)
|
|
uploaded_first = list(self.stub.uploaded)
|
|
code, output = self.publish()
|
|
self.assertEqual(code, 0, output)
|
|
self.assertEqual(self.stub.uploaded, uploaded_first, "a rerun must not upload duplicates")
|
|
self.assertEqual(output.count("skip existing asset"), 2, output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|