Skip to content

Commit e310e35

Browse files
committed
test(model): run one pull request through the real listener and manager in one process
1 parent ddaf9ff commit e310e35

6 files changed

Lines changed: 406 additions & 1 deletion

File tree

‎bun.lock‎

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"packages/*",
99
"e2e",
1010
"tests/chain",
11+
"tests/model",
1112
"vendor/interchange/packages/*",
1213
"vendor/interchange/apps/*",
1314
"vendor/interchange/tests/admin-ui-e2e"
@@ -32,7 +33,7 @@
3233
"test:unit": "bun --conditions=intx-src test --path-ignore-patterns='**/*.dom.test.tsx' --path-ignore-patterns='**/*.postgres.test.ts' ./apps/ ./packages/ ./tooling/",
3334
"test:postgres": "bun --conditions=intx-src test .postgres.test.ts",
3435
"test:dom": "bun --conditions=intx-src test --preload ./apps/web/src/lib/dom-preload.ts .dom.test",
35-
"check": "bun tooling/require-bun.ts && bun tooling/exact-deps-check.ts && bun check --no-script -p tooling && bun check --no-script -p apps/web && bun check --no-script -p apps/extension && bun check --no-script -p apps/extension/tsconfig.background.json && bun check --no-script -p apps/extension/e2e && bun check --no-script -p apps/hub && bun check --no-script -p packages/triage-workflows && bun check --no-script -p packages/triage-manager && bun check --no-script -p packages/triage-judge && bun check --no-script -p packages/pr-code-review && bun check --no-script -p packages/pr-code-review-anthropic && bun check --no-script -p packages/provisioner-test && bun check --no-script -p packages/provisioner-template && bun check --no-script -p packages/provisioner-docker && bun check --no-script -p packages/provisioner-e2b && bun check --no-script -p packages/provisioner-railway && bun check --no-script -p packages/policy-check-action && bun check --no-script -p e2e && bun check --no-script -p tests/chain && bun build --conditions=intx-src --external @ast-grep/napi apps/hub/src/server.ts --target bun --outfile /dev/null",
36+
"check": "bun tooling/require-bun.ts && bun tooling/exact-deps-check.ts && bun check --no-script -p tooling && bun check --no-script -p apps/web && bun check --no-script -p apps/extension && bun check --no-script -p apps/extension/tsconfig.background.json && bun check --no-script -p apps/extension/e2e && bun check --no-script -p apps/hub && bun check --no-script -p packages/triage-workflows && bun check --no-script -p packages/triage-manager && bun check --no-script -p packages/triage-judge && bun check --no-script -p packages/pr-code-review && bun check --no-script -p packages/pr-code-review-anthropic && bun check --no-script -p packages/provisioner-test && bun check --no-script -p packages/provisioner-template && bun check --no-script -p packages/provisioner-docker && bun check --no-script -p packages/provisioner-e2b && bun check --no-script -p packages/provisioner-railway && bun check --no-script -p packages/policy-check-action && bun check --no-script -p e2e && bun check --no-script -p tests/chain && bun check --no-script -p tests/model && bun build --conditions=intx-src --external @ast-grep/napi apps/hub/src/server.ts --target bun --outfile /dev/null",
3637
"test:chain": "bun --conditions=intx-src test --parallel=2 tests/chain",
3738
"lint": "oxlint",
3839
"eval:review": "bun --conditions=intx-src packages/pr-code-review-anthropic/evals/review.eval.ts",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Requires PostgreSQL at localhost:5432 (docs/DEV.md).
2+
import { afterAll, expect, mock, test } from "bun:test";
3+
import { emptyPack, VERDICT_LABELS } from "@corbits/triage-contracts";
4+
import { comments, labelled, OWNER, pullOf, sha } from "../chain/github.ts";
5+
import { modelStack } from "./stack.ts";
6+
7+
const MANAGER_RELEASE = { workflow: { assetId: "ast_triage-manager-github", commitSha: "c0ffee", packageName: "@corbits/triage-manager", entry: "./triage-manager-github.mjs" }, offerings: { ids: ["off_model"], defaultId: "off_model" } };
8+
mock.module(new URL("../../packages/triage-manager/src/release.json", import.meta.url).pathname, () => ({ default: { github: { manager: MANAGER_RELEASE } } }));
9+
10+
const REPO = `${OWNER}/one`;
11+
// Under `ask`, the pr-triage role holds only posting: its labels and its comment.
12+
const stack = await modelStack(REPO, { pack: { ...emptyPack(REPO), checks: { "max-files-changed": { enabled: true } } }, automatic: ["labels", "comment"] });
13+
afterAll(() => stack.stop());
14+
15+
test("one pull request opened runs its listener and manager to one verdict, its label, and no run left live", async () => {
16+
const head = sha("one-1");
17+
await stack.opened(pullOf(1, head));
18+
const ran = await stack.drain();
19+
20+
const writes = stack.github.writesTo(REPO, 1);
21+
expect(stack.github.misses).toEqual([]);
22+
expect(ran.map((run) => run.status)).toEqual(["completed", "completed"]);
23+
expect(comments(writes)).toEqual([expect.stringContaining("**Triage: Pass**")]);
24+
expect(labelled(writes)).toEqual([VERDICT_LABELS.pass]);
25+
expect(await stack.claimOf(1)).toMatchObject({ status: "ended", history: [{ head }] });
26+
expect(await stack.liveManagers()).toEqual([]);
27+
expect(stack.queue).toEqual([]);
28+
expect(await stack.verdicts(1)).toEqual([expect.objectContaining({ head_sha: head, run_status: "completed" })]);
29+
});

‎tests/model/package.json‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@corbits/model-test",
3+
"version": "0.1.0",
4+
"private": true,
5+
"license": "SEE LICENSE IN LICENSE.md",
6+
"type": "module",
7+
"dependencies": {
8+
"@corbits/triage-contracts": "workspace:*",
9+
"@corbits/triage-manager": "workspace:*",
10+
"@intx/agent": "workspace:*",
11+
"@intx/authz": "workspace:*",
12+
"@intx/crypto": "0.5.0",
13+
"@intx/db": "workspace:*",
14+
"@intx/harness": "workspace:*",
15+
"@intx/hub-api": "0.5.0",
16+
"@intx/hub-sessions": "0.5.0",
17+
"@intx/inference": "workspace:*",
18+
"@intx/storage-isogit": "workspace:*",
19+
"@intx/types": "workspace:*",
20+
"@intx/workflow": "workspace:*",
21+
"@intx/workflow-host": "workspace:*",
22+
"drizzle-orm": "catalog:"
23+
},
24+
"description": "Triage's real listener and manager run in one process through Interchange's runLocal, against the hub's own state and a recording fake GitHub"
25+
}

0 commit comments

Comments
 (0)