feat: add gitea agentic runtime control plane
This commit is contained in:
Binary file not shown.
62
tests/integration/test_runtime_flow.py
Normal file
62
tests/integration/test_runtime_flow.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from engine.devops_agent.compiler import compile_workflow
|
||||
from engine.devops_agent.runtime import run_issue_comment_workflow
|
||||
from engine.devops_agent.spec import load_workflow_spec
|
||||
from engine.devops_agent.validator import validate_workflow_spec
|
||||
|
||||
|
||||
class FakeProvider:
|
||||
def __init__(self) -> None:
|
||||
self.comments: list[dict[str, object]] = []
|
||||
|
||||
def parse_issue_comment_event(self, payload: dict[str, object]) -> dict[str, object]:
|
||||
repository = payload["repository"]
|
||||
issue = payload["issue"]
|
||||
comment = payload["comment"]
|
||||
return {
|
||||
"repo": repository["full_name"],
|
||||
"issue_number": issue["number"],
|
||||
"comment_body": comment["body"],
|
||||
}
|
||||
|
||||
def get_issue(self, repo: str, issue_number: int) -> dict[str, object]:
|
||||
return {
|
||||
"number": issue_number,
|
||||
"title": "Fix issue delivery flow",
|
||||
"body": "The agent should post evidence back to the issue.",
|
||||
"state": "open",
|
||||
"repo": repo,
|
||||
}
|
||||
|
||||
def post_issue_comment(self, repo: str, issue_number: int, body: str) -> dict[str, object]:
|
||||
record = {
|
||||
"repo": repo,
|
||||
"issue_number": issue_number,
|
||||
"body": body,
|
||||
}
|
||||
self.comments.append(record)
|
||||
return {"id": len(self.comments), **record}
|
||||
|
||||
|
||||
def test_runtime_executes_flow_and_writes_evidence() -> None:
|
||||
spec = load_workflow_spec(Path("workflows/gitea-issue-delivery.md"))
|
||||
assert validate_workflow_spec(spec) == []
|
||||
lock = compile_workflow(spec)
|
||||
payload = json.loads(Path("tests/fixtures/gitea/comment_event.json").read_text(encoding="utf-8"))
|
||||
provider = FakeProvider()
|
||||
|
||||
artifact = run_issue_comment_workflow(
|
||||
lock=lock,
|
||||
provider=provider,
|
||||
event_payload=payload,
|
||||
output_dir=Path(".tmp/runtime-flow-test"),
|
||||
)
|
||||
|
||||
assert artifact["result"] == "success"
|
||||
assert artifact["plan_state"]["status"] == "pending_review"
|
||||
assert provider.comments
|
||||
assert Path(artifact["artifact_path"]).exists()
|
||||
Reference in New Issue
Block a user