Skip to content

Commit 9caa070

Browse files
committed
test(queue): cover branchless PR intake
1 parent cf01495 commit 9caa070

1 file changed

Lines changed: 71 additions & 1 deletion

File tree

‎test/sweep-workflow.test.ts‎

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,77 @@ test("planned background reviews allow safe content-cache reuse without weakenin
26272627
assert.doesNotMatch(eventReviewJob, /--planned-automatic-review/);
26282628
});
26292629

2630-
test("sweep event reviews and target fanout avoid storm amplification", () => {
2630+
test("legacy event field serializer preserves branchless issue and PR intake", () => {
2631+
const workflow = YAML.parse(readText(".github/workflows/sweep.yml")) as {
2632+
jobs: Record<string, { steps: Array<{ name?: string; run?: string }> }>;
2633+
};
2634+
const run = workflow.jobs["legacy-event-queue-intake"]?.steps.find(
2635+
(step) => step.name === "Enqueue legacy event through the durable control plane",
2636+
)?.run;
2637+
assert.ok(run);
2638+
const script = run.match(/node <<'NODE'\n([\s\S]*?)\nNODE\n/)?.[1];
2639+
assert.ok(script);
2640+
2641+
const serialize = (payload: Record<string, unknown>): string[] => {
2642+
const output = execFileSync(process.execPath, ["-"], {
2643+
encoding: "utf8",
2644+
env: { ...process.env, CLIENT_PAYLOAD: JSON.stringify(payload) },
2645+
input: script,
2646+
});
2647+
const fields = output.split("\0");
2648+
assert.equal(fields.pop(), "");
2649+
return fields;
2650+
};
2651+
2652+
assert.deepEqual(
2653+
serialize({
2654+
item_kind: "issue",
2655+
target_repo: "openclaw/openclaw",
2656+
source_event: "issues",
2657+
source_action: "opened",
2658+
}),
2659+
["openclaw/openclaw", "", "0"],
2660+
);
2661+
assert.deepEqual(
2662+
serialize({
2663+
item_kind: "pull_request",
2664+
target_repo: "openclaw/clawhub",
2665+
item_number: 3273,
2666+
source_event: "pull_request_target",
2667+
source_action: "opened",
2668+
supersedes_in_progress: false,
2669+
}),
2670+
["openclaw/clawhub", "", "0"],
2671+
);
2672+
assert.deepEqual(
2673+
serialize({
2674+
item_kind: "pull_request",
2675+
target_repo: "openclaw/clawhub",
2676+
source_event: "pull_request",
2677+
source_action: "edited",
2678+
queue_claim: {
2679+
installation_id: 1,
2680+
source_head_sha: "a".repeat(40),
2681+
source_base_sha: "b".repeat(40),
2682+
source_is_draft: false,
2683+
source_content_revision: "c".repeat(64),
2684+
},
2685+
}),
2686+
["openclaw/clawhub", "", "1"],
2687+
);
2688+
assert.deepEqual(
2689+
serialize({
2690+
item_kind: "pull_request",
2691+
target_repo: "openclaw/clawhub",
2692+
target_branch: "main",
2693+
source_event: "issue_comment",
2694+
source_action: "created",
2695+
}),
2696+
["openclaw/clawhub", "main", "0"],
2697+
);
2698+
});
2699+
2700+
test("sweep issue and PR event reviews and target fanout avoid storm amplification", () => {
26312701
const workflow = readText(".github/workflows/sweep.yml");
26322702
const legacyIntakeBlock = workflow.slice(
26332703
workflow.indexOf("legacy-event-queue-intake:"),

0 commit comments

Comments
 (0)