Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions actions/setup/js/route_slash_command.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ async function appendRoutingSummary(existingCommands, selectedCommand) {
.map(command => `/${command.trim()}`)
.sort();

const existingCommandsText = normalizedCommands.length ? normalizedCommands.join(", ") : "<none>";
const selectedCommandText = selectedCommand ? `/${selectedCommand}` : "<none>";
const selectedCommandText = selectedCommand ? `\`/${selectedCommand}\`` : "`<none>`";
const existingCommandsList = normalizedCommands.map(command => `- \`${command}\``).join("\n");

try {
summary.addHeading("Agentic Commands Router", 3).addRaw(`- Existing commands: ${existingCommandsText}`, true).addEOL().addRaw(`- Selected command: ${selectedCommandText}`, true).addEOL();
summary.addHeading("Agentic Commands Router", 3).addRaw(`- Selected command: ${selectedCommandText}`, true).addEOL().addRaw(`- Configured commands: ${normalizedCommands.length}`, true).addEOL();
if (existingCommandsList) {
summary.addEOL().addRaw(`<details><summary>Configured commands</summary>\n\n${existingCommandsList}\n\n</details>`, true).addEOL();
}
await summary.write({ overwrite: false });
} catch (error) {
core.warning(`Failed to write centralized routing details to step summary: ${String(error)}`);
Expand Down Expand Up @@ -286,7 +289,7 @@ function isDisabledWorkflowDispatchError(error) {
return false;
}

return message.includes("workflow is disabled") || message.includes("workflow was disabled");
return message.includes("workflow is disabled") || message.includes("workflow was disabled") || message.includes("disabled workflow");
}

async function main() {
Expand Down
41 changes: 37 additions & 4 deletions actions/setup/js/route_slash_command.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ describe("route_slash_command", () => {
const awContext = JSON.parse(dispatchCalls[0].inputs.aw_context);
expect(awContext.command_name).toBe("archie");
expect(awContext.desired_ai_reaction).toBe("eyes");
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Existing commands: /archie", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: /archie", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: `/archie`", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Configured commands: 1", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("<details><summary>Configured commands</summary>\n\n- `/archie`\n\n</details>", true);
expect(summaryMock.write).toHaveBeenCalledWith({ overwrite: false });
});

Expand All @@ -170,8 +171,9 @@ describe("route_slash_command", () => {

await main();

expect(summaryMock.addRaw).toHaveBeenCalledWith("- Existing commands: /archie", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: <none>", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: `<none>`", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("- Configured commands: 1", true);
expect(summaryMock.addRaw).toHaveBeenCalledWith("<details><summary>Configured commands</summary>\n\n- `/archie`\n\n</details>", true);
expect(summaryMock.write).toHaveBeenCalledWith({ overwrite: false });
});

Expand Down Expand Up @@ -347,6 +349,37 @@ describe("route_slash_command", () => {
expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Skipping workflow 'ci-doctor.lock.yml' because it is disabled."));
});

it("ignores disabled workflow_dispatch failures for disabled label routes", async () => {
globals.github.rest.actions.createWorkflowDispatch = vi.fn(async params => {
if (params.workflow_id === "smoke-otel-backends.lock.yml") {
throw Object.assign(new Error("Cannot trigger a 'workflow_dispatch' on a disabled workflow"), {
status: 422,
response: { status: 422, data: { message: "Cannot trigger a 'workflow_dispatch' on a disabled workflow" } },
});
}
dispatchCalls.push(params);
});
globals.context.eventName = "pull_request";
globals.context.payload = {
action: "labeled",
label: { name: "smoke" },
pull_request: { number: 23 },
};
process.env.GH_AW_LABEL_ROUTING = JSON.stringify({
smoke: [
{ workflow: "smoke-copilot", events: ["pull_request"] },
{ workflow: "smoke-otel-backends", events: ["pull_request"] },
],
});

await main();

expect(dispatchCalls).toHaveLength(1);
expect(dispatchCalls[0].workflow_id).toBe("smoke-copilot.lock.yml");
expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Skipping workflow 'smoke-otel-backends.lock.yml' because it is disabled."));
expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Completed decentralized label routing for 'smoke'."));
});

it("skips centralized routing when PR is closed at workflow start", async () => {
globals.context.eventName = "pull_request";
globals.context.payload = { action: "ready_for_review", pull_request: { number: 12, state: "closed" } };
Expand Down
Loading