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
2 changes: 1 addition & 1 deletion actions/setup/js/handle_noop_message.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function ensureAgentRunsIssue() {
};
}
} catch (error) {
core.warning(`Error searching for no-op runs issue: ${getErrorMessage(error)}`);
throw new Error(`Failed to search for existing no-op runs issue: ${getErrorMessage(error)}`);
}

// Create no-op runs issue if it doesn't exist
Expand Down
30 changes: 30 additions & 0 deletions actions/setup/js/handle_noop_message.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,36 @@ This issue helps you:
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not create no-op runs issue"));
});

it("should not create issue when search throws (prevents duplicate issues)", async () => {
process.env.GH_AW_WORKFLOW_NAME = "Test Workflow";
process.env.GH_AW_RUN_URL = "https://github.com/test-owner/test-repo/actions/runs/789";
process.env.GH_AW_NOOP_MESSAGE = "All checks passed";
process.env.GH_AW_AGENT_CONCLUSION = "success";

// Create agent output file with only noop outputs
const outputFile = path.join(tempDir, "agent_output.json");
fs.writeFileSync(
outputFile,
JSON.stringify({
items: [{ type: "noop", message: "All checks passed" }],
})
);
process.env.GH_AW_AGENT_OUTPUT = outputFile;

// Mock search failure (e.g. transient API error)
mockGithub.rest.search.issuesAndPullRequests.mockRejectedValue(new Error("API rate limit exceeded"));

const { main } = await import("./handle_noop_message.cjs?t=" + Date.now());
await main();

// Search error should be caught and logged as a warning (via ensureAgentRunsIssue throw → main catch)
expect(mockCore.warning).toHaveBeenCalledWith(expect.stringContaining("Could not create no-op runs issue"));
// Issue must NOT be created to prevent duplicates
expect(mockGithub.rest.issues.create).not.toHaveBeenCalled();
// Comment must NOT be posted
expect(mockGithub.rest.issues.createComment).not.toHaveBeenCalled();
});

it("should extract run ID from URL correctly", async () => {
process.env.GH_AW_WORKFLOW_NAME = "Test";
process.env.GH_AW_RUN_URL = "https://github.com/owner/repo/actions/runs/987654321";
Expand Down
Loading