feat: add post-run Gitea lifecycle (#5)

This commit is contained in:
-Puter
2026-07-24 02:05:30 +05:30
parent 7974bd5f3e
commit a17d53cb41
16 changed files with 1281 additions and 7 deletions

View File

@@ -217,4 +217,63 @@ describe("projectEvents", () => {
const events = await eventsForProject(t, projectId);
expect(events.some((e) => e.kind === "agent.completed")).toBe(false);
});
test("Gitea lifecycle persists PR metadata in an event and artifact", async () => {
const t = convexTest({ schema, modules });
const projectId = await createTestProject(t);
const issueId = await t
.withIdentity(identityA)
.mutation(api.projectIssues.create, {
body: "A representative issue body long enough to pass validation",
projectId,
title: "Representative issue",
});
await t.mutation(api.agentWorkspace.ensureRun, {
daemonId: "daemon-1",
issueId,
token: FLUE_DB_TOKEN,
});
await t.mutation(api.agentWorkspace.recordGiteaLifecycle, {
baseBranch: "main",
branch: "work/issue-1",
commitSha: "abc123",
issueId,
pullRequest: {
baseBranch: "main",
branch: "work/issue-1",
number: 5,
status: "open",
url: "https://git.openputer.com/puter/zopu-code/pulls/5",
},
status: "pull_request_open",
token: FLUE_DB_TOKEN,
});
const events = await eventsForProject(t, projectId);
const event = events.find(
(item) => item.kind === "gitea.pull_request.created"
);
expect(event?.data).toMatchObject({
branch: "work/issue-1",
commitSha: "abc123",
pullRequest: {
number: 5,
status: "open",
},
status: "pull_request_open",
});
const artifacts = await t.query((ctx) =>
ctx.db
.query("projectArtifacts")
.withIndex("by_project_and_path", (q) =>
q.eq("projectId", projectId).eq("path", "artifacts.md")
)
.unique()
);
expect(artifacts?.content).toContain(
"https://git.openputer.com/puter/zopu-code/pulls/5"
);
});
});