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
99 changes: 3 additions & 96 deletions .github/workflows/smoke-call-workflow.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions actions/setup/js/check_command_position.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ async function main() {
const eventName = context.eventName;

try {
// For labeled events (label-command triggers), skip the command position check.
// The label name itself is the trigger, not a slash command in the body.
// Label name matching is enforced by the workflow-level `if:` condition
// (e.g. github.event.label.name == 'cloclo'), so no additional filtering
// is needed here regardless of which labels are configured.
if (context.payload?.action === "labeled") {
core.info(`Event ${eventName} with action 'labeled' does not require command position check`);
core.setOutput("command_position_ok", "true");
core.setOutput("matched_command", "");
return;
}

if (eventName === "issues") {
text = context.payload.issue?.body || "";
} else if (eventName === "pull_request") {
Expand Down
24 changes: 24 additions & 0 deletions actions/setup/js/check_command_position.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,29 @@ const mockCore = {
(mockContext.payload = { comment: { body: "/discuss-bot analyze this" } }),
await eval(`(async () => { ${checkCommandPositionScript}; await main(); })()`),
expect(mockCore.setOutput).toHaveBeenCalledWith("command_position_ok", "true"));
}),
it("should pass for labeled issues event (label-command trigger)", async () => {
process.env.GH_AW_COMMANDS = JSON.stringify(["cloclo"]);
mockContext.eventName = "issues";
mockContext.payload = { action: "labeled", label: { name: "cloclo" }, issue: { body: "This is a regular issue body" } };
await eval(`(async () => { ${checkCommandPositionScript}; await main(); })()`);
expect(mockCore.setOutput).toHaveBeenCalledWith("command_position_ok", "true");
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("does not require command position check"));
}),
it("should pass for labeled pull_request event (label-command trigger)", async () => {
process.env.GH_AW_COMMANDS = JSON.stringify(["cloclo"]);
mockContext.eventName = "pull_request";
mockContext.payload = { action: "labeled", label: { name: "cloclo" }, pull_request: { body: "PR body without command" } };
await eval(`(async () => { ${checkCommandPositionScript}; await main(); })()`);
expect(mockCore.setOutput).toHaveBeenCalledWith("command_position_ok", "true");
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("does not require command position check"));
}),
it("should pass for labeled discussion event (label-command trigger)", async () => {
process.env.GH_AW_COMMANDS = JSON.stringify(["cloclo"]);
mockContext.eventName = "discussion";
mockContext.payload = { action: "labeled", label: { name: "cloclo" }, discussion: { body: "Discussion body without command" } };
await eval(`(async () => { ${checkCommandPositionScript}; await main(); })()`);
expect(mockCore.setOutput).toHaveBeenCalledWith("command_position_ok", "true");
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("does not require command position check"));
}));
}));
Loading