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
4 changes: 1 addition & 3 deletions actions/setup/js/add_copilot_reviewer.cjs

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

4 changes: 1 addition & 3 deletions actions/setup/js/assign_issue.cjs

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

4 changes: 1 addition & 3 deletions actions/setup/js/checkout_pr_branch.cjs

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

4 changes: 1 addition & 3 deletions actions/setup/js/create_agent_task.cjs

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

4 changes: 1 addition & 3 deletions actions/setup/js/push_repo_memory.cjs

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

4 changes: 1 addition & 3 deletions pkg/workflow/js/add_copilot_reviewer.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,4 @@ Successfully added Copilot as a reviewer to PR #${prNumber}.
}
}

main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
module.exports = { main };
22 changes: 14 additions & 8 deletions pkg/workflow/js/add_copilot_reviewer.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ describe("add_copilot_reviewer", () => {
};
});

// Helper function to run the script with main() call
async function runScript() {
const { main } = await import("./add_copilot_reviewer.cjs?" + Date.now());
await main();
}

it("should fail when PR_NUMBER is not set", async () => {
delete process.env.PR_NUMBER;

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.setFailed).toHaveBeenCalledWith("PR_NUMBER environment variable is required but not set");
expect(mockGithub.rest.pulls.requestReviewers).not.toHaveBeenCalled();
Expand All @@ -77,7 +83,7 @@ describe("add_copilot_reviewer", () => {
it("should fail when PR_NUMBER is empty", async () => {
process.env.PR_NUMBER = " ";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.setFailed).toHaveBeenCalledWith("PR_NUMBER environment variable is required but not set");
expect(mockGithub.rest.pulls.requestReviewers).not.toHaveBeenCalled();
Expand All @@ -86,7 +92,7 @@ describe("add_copilot_reviewer", () => {
it("should fail when PR_NUMBER is not a valid number", async () => {
process.env.PR_NUMBER = "not-a-number";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Invalid PR_NUMBER"));
expect(mockGithub.rest.pulls.requestReviewers).not.toHaveBeenCalled();
Expand All @@ -95,7 +101,7 @@ describe("add_copilot_reviewer", () => {
it("should fail when PR_NUMBER is zero", async () => {
process.env.PR_NUMBER = "0";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Invalid PR_NUMBER"));
expect(mockGithub.rest.pulls.requestReviewers).not.toHaveBeenCalled();
Expand All @@ -104,7 +110,7 @@ describe("add_copilot_reviewer", () => {
it("should fail when PR_NUMBER is negative", async () => {
process.env.PR_NUMBER = "-1";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Invalid PR_NUMBER"));
expect(mockGithub.rest.pulls.requestReviewers).not.toHaveBeenCalled();
Expand All @@ -113,7 +119,7 @@ describe("add_copilot_reviewer", () => {
it("should add copilot as reviewer when PR_NUMBER is valid", async () => {
process.env.PR_NUMBER = "456";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockGithub.rest.pulls.requestReviewers).toHaveBeenCalledWith({
owner: "testowner",
Expand All @@ -130,7 +136,7 @@ describe("add_copilot_reviewer", () => {
process.env.PR_NUMBER = "123";
mockGithub.rest.pulls.requestReviewers.mockRejectedValueOnce(new Error("API Error"));

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockCore.error).toHaveBeenCalledWith(expect.stringContaining("Failed to add Copilot as reviewer"));
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Failed to add Copilot as reviewer"));
Expand All @@ -139,7 +145,7 @@ describe("add_copilot_reviewer", () => {
it("should trim whitespace from PR_NUMBER", async () => {
process.env.PR_NUMBER = " 789 ";

await import("./add_copilot_reviewer.cjs");
await runScript();

expect(mockGithub.rest.pulls.requestReviewers).toHaveBeenCalledWith({
owner: "testowner",
Expand Down
4 changes: 1 addition & 3 deletions pkg/workflow/js/assign_issue.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,4 @@ Successfully assigned issue #${trimmedIssueNumber} to \`${trimmedAssignee}\`.
}
}

main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
module.exports = { main };
4 changes: 1 addition & 3 deletions pkg/workflow/js/check_workflow_timestamp.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,4 @@ async function main() {
}
}

main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
module.exports = { main };
4 changes: 1 addition & 3 deletions pkg/workflow/js/create_agent_task.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,4 @@ async function main() {
await core.summary.write();
}

main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
module.exports = { main };
3 changes: 2 additions & 1 deletion pkg/workflow/js/create_agent_task.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe("create_agent_task.cjs", () => {
const scriptPath = require("path").join(process.cwd(), "create_agent_task.cjs");
delete require.cache[require.resolve(scriptPath)];
try {
(require(scriptPath), await new Promise(resolve => setTimeout(resolve, 50)));
const { main } = require(scriptPath);
await main();
} catch (error) {}
};
(describe("basic functionality", () => {
Expand Down
4 changes: 1 addition & 3 deletions pkg/workflow/js/push_repo_memory.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,4 @@ async function main() {
}
}

main().catch(error => {
core.setFailed(`Unexpected error: ${error instanceof Error ? error.message : String(error)}`);
});
module.exports = { main };