feat(ship): add stage audit trail and sortable ids
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CREATE = ROOT / "skills/ship/scripts/create_ship.py"
|
||||
NEXT = ROOT / "skills/ship/scripts/next_step.py"
|
||||
NEW_ID = ROOT / "skills/ship/scripts/new_ship_id.py"
|
||||
|
||||
|
||||
def run(script: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run(
|
||||
["python3", str(script), *args],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
|
||||
class ShipStageTests(unittest.TestCase):
|
||||
def test_new_id_is_sortable(self) -> None:
|
||||
result = run(NEW_ID, "--phrase", "dynamic-editor", "--date", "20261014")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(result.stdout.strip(), "20261014-dynamic-editor")
|
||||
|
||||
def test_create_initializes_visible_stage_directories(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
result = run(
|
||||
CREATE,
|
||||
"--project-root", str(root),
|
||||
"--ship-id", "20261014-dynamic-editor",
|
||||
"--kind", "short",
|
||||
"--title", "动态编辑器",
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
ship = root / ".pouch/ship/20261014-dynamic-editor"
|
||||
for name in ("1-spec", "2-develop", "3-test", "4-review", "5-build", "6-publish", "7-deploy"):
|
||||
self.assertTrue((ship / name / "stage.yaml").is_file())
|
||||
self.assertTrue((ship / name / "activity.md").is_file())
|
||||
|
||||
def test_next_step_records_stage_dispatch(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
ship_id = "20261014-dynamic-editor"
|
||||
created = run(
|
||||
CREATE,
|
||||
"--project-root", str(root),
|
||||
"--ship-id", ship_id,
|
||||
"--kind", "short",
|
||||
"--title", "动态编辑器",
|
||||
"--stop-at", "verified",
|
||||
)
|
||||
self.assertEqual(created.returncode, 0, created.stderr)
|
||||
result = run(NEXT, "--project-root", str(root), "--ship-id", ship_id, "--entry", "short")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
doc = json.loads(result.stdout)
|
||||
self.assertEqual(doc["stage"], "1-spec")
|
||||
activity = (root / ".pouch/ship" / ship_id / "1-spec/activity.md").read_text()
|
||||
self.assertIn("write_spec", activity)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user