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 .github/workflows/issue-classifier.lock.yml

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

6 changes: 3 additions & 3 deletions .github/workflows/release.lock.yml

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

2 changes: 1 addition & 1 deletion .github/workflows/stale-repo-identifier.lock.yml

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

2 changes: 1 addition & 1 deletion .github/workflows/super-linter.lock.yml

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

8 changes: 4 additions & 4 deletions pkg/workflow/compiler_safe_outputs_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (c *Compiler) buildConsolidatedSafeOutputsJob(data *WorkflowData, mainJobNa
appTokenSteps := c.buildGitHubAppTokenMintStep(data.SafeOutputs.App, permissions)
// Calculate insertion index: after setup action (if present) and artifact downloads, but before safe output steps
insertIndex := 0

// Count setup action steps (checkout + setup if in dev mode, or just setup)
setupActionRef := c.resolveActionReference("./actions/setup", data)
if setupActionRef != "" {
Expand All @@ -396,10 +396,10 @@ func (c *Compiler) buildConsolidatedSafeOutputsJob(data *WorkflowData, mainJobNa
}
insertIndex += 4 // Setup step (4 lines: name, uses, with, destination)
}

// Add artifact download steps count
insertIndex += len(buildAgentOutputDownloadSteps())

// Add patch download steps if present
if data.SafeOutputs.CreatePullRequests != nil || data.SafeOutputs.PushToPullRequestBranch != nil {
patchDownloadSteps := buildArtifactDownloadSteps(ArtifactDownloadConfig{
Expand All @@ -410,7 +410,7 @@ func (c *Compiler) buildConsolidatedSafeOutputsJob(data *WorkflowData, mainJobNa
})
insertIndex += len(patchDownloadSteps)
}

// Insert app token steps
newSteps := make([]string, 0)
newSteps = append(newSteps, steps[:insertIndex]...)
Expand Down
3 changes: 2 additions & 1 deletion pkg/workflow/js/add_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,5 @@ async function main() {
core.info(`Successfully created ${createdComments.length} comment(s)`);
return createdComments;
}
await main();

module.exports = { main };
57 changes: 30 additions & 27 deletions pkg/workflow/js/add_comment.test.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/workflow/js/add_labels.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ ${labelsListMarkdown}
core.setFailed(`Failed to add labels: ${errorMessage}`);
}
}
await main();

module.exports = { main };
86 changes: 43 additions & 43 deletions pkg/workflow/js/add_labels.test.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/workflow/js/add_reaction_and_edit_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,4 @@ async function addCommentWithWorkflowLink(endpoint, runUrl, eventName) {
}
}

await main();
module.exports = { main };
30 changes: 15 additions & 15 deletions pkg/workflow/js/add_reaction_and_edit_comment.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ const mockCore = {
(global.context.eventName = "issues"),
(global.context.payload.issue = { number: 123 }),
mockGithub.request.mockResolvedValue({ data: { id: 456 } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/123/reactions", expect.objectContaining({ content: "eyes" })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "456"));
}),
it("should reject invalid reaction type", async () => {
((process.env.GH_AW_REACTION = "invalid"),
(global.context.eventName = "issues"),
(global.context.payload.issue = { number: 123 }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.setFailed).toHaveBeenCalledWith(expect.stringContaining("Invalid reaction type: invalid")),
expect(mockGithub.request).not.toHaveBeenCalled());
}));
Expand All @@ -71,7 +71,7 @@ const mockCore = {
(global.context.eventName = "pull_request"),
(global.context.payload = { pull_request: { number: 456 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
mockGithub.request.mockResolvedValueOnce({ data: { id: 789 } }).mockResolvedValueOnce({ data: { id: 999, html_url: "https://github.com/testowner/testrepo/pull/456#issuecomment-999" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/456/reactions", expect.objectContaining({ content: "heart" })),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/456/comments", expect.objectContaining({ body: expect.stringContaining("be settin' sail on this pull request") })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "789"),
Expand All @@ -87,7 +87,7 @@ const mockCore = {
mockGithub.graphql
.mockResolvedValueOnce({ repository: { discussion: { id: "D_kwDOABcD1M4AaBbC", url: "https://github.com/testowner/testrepo/discussions/10" } } })
.mockResolvedValueOnce({ addReaction: { reaction: { id: "MDg6UmVhY3Rpb24xMjM0NTY3ODk=", content: "ROCKET" } } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.graphql).toHaveBeenCalledWith(expect.stringContaining("query"), expect.objectContaining({ owner: "testowner", repo: "testrepo", num: 10 })),
expect(mockGithub.graphql).toHaveBeenCalledWith(expect.stringContaining("mutation"), expect.objectContaining({ subjectId: "D_kwDOABcD1M4AaBbC", content: "ROCKET" })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "MDg6UmVhY3Rpb24xMjM0NTY3ODk="));
Expand All @@ -111,7 +111,7 @@ const mockCore = {
mockGithub.graphql
.mockResolvedValueOnce({ repository: { discussion: { id: "D_kwDOABcD1M4AaBbC", url: "https://github.com/testowner/testrepo/discussions/10" } } })
.mockResolvedValueOnce({ addReaction: { reaction: { id: "MDg6UmVhY3Rpb24xMjM0NTY3ODk=", content: test.expected } } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.graphql).toHaveBeenCalledWith(expect.stringContaining("mutation"), expect.objectContaining({ content: test.expected })));
}));
}),
Expand All @@ -125,15 +125,15 @@ const mockCore = {
repository: { html_url: "https://github.com/testowner/testrepo" },
}),
mockGithub.graphql.mockResolvedValueOnce({ addReaction: { reaction: { id: "MDg6UmVhY3Rpb24xMjM0NTY3ODk=", content: "HEART" } } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.graphql).toHaveBeenCalledWith(expect.stringContaining("mutation"), expect.objectContaining({ subjectId: "DC_kwDOABcD1M4AaBbC", content: "HEART" })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "MDg6UmVhY3Rpb24xMjM0NTY3ODk="));
}),
it("should fail when discussion comment node_id is missing", async () => {
((process.env.GH_AW_REACTION = "eyes"),
(global.context.eventName = "discussion_comment"),
(global.context.payload = { discussion: { number: 10 }, comment: { id: 123 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.setFailed).toHaveBeenCalledWith("Discussion comment node ID not found in event payload"),
expect(mockGithub.graphql).not.toHaveBeenCalled());
}));
Expand All @@ -145,7 +145,7 @@ const mockCore = {
(global.context.eventName = "issues"),
(global.context.payload = { issue: { number: 123 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
mockGithub.request.mockResolvedValueOnce({ data: { id: 456 } }).mockResolvedValueOnce({ data: { id: 789, html_url: "https://github.com/testowner/testrepo/issues/123#issuecomment-789" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/123/reactions", expect.objectContaining({ content: "eyes" })),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/123/comments", expect.objectContaining({ body: expect.stringContaining("be settin' sail on this issue") })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "456"),
Expand All @@ -158,7 +158,7 @@ const mockCore = {
(global.context.eventName = "issue_comment"),
(global.context.payload = { issue: { number: 123 }, comment: { id: 456 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
mockGithub.request.mockResolvedValueOnce({ data: { id: 111 } }).mockResolvedValueOnce({ data: { id: 789, html_url: "https://github.com/testowner/testrepo/issues/123#issuecomment-789" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/123/comments", expect.objectContaining({ body: expect.stringContaining("be settin' sail on this issue comment") })),
expect(mockGithub.request).not.toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/comments/456", expect.anything()),
expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "789"),
Expand All @@ -171,7 +171,7 @@ const mockCore = {
(global.context.eventName = "pull_request_review_comment"),
(global.context.payload = { pull_request: { number: 456 }, comment: { id: 789 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
mockGithub.request.mockResolvedValueOnce({ data: { id: 222 } }).mockResolvedValueOnce({ data: { id: 999, html_url: "https://github.com/testowner/testrepo/pull/456#discussion_r999" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.request).toHaveBeenCalledWith("POST /repos/testowner/testrepo/issues/456/comments", expect.objectContaining({ body: expect.stringContaining("be settin' sail on this pull request review comment") })),
expect(mockGithub.request).not.toHaveBeenCalledWith("POST /repos/testowner/testrepo/pulls/comments/789", expect.anything()),
expect(mockCore.setOutput).toHaveBeenCalledWith("comment-id", "999"),
Expand All @@ -188,7 +188,7 @@ const mockCore = {
.mockResolvedValueOnce({ addReaction: { reaction: { id: "MDg6UmVhY3Rpb24xMjM0NTY3ODk=", content: "EYES" } } })
.mockResolvedValueOnce({ repository: { discussion: { id: "D_kwDOABcD1M4AaBbC" } } })
.mockResolvedValueOnce({ addDiscussionComment: { comment: { id: "DC_kwDOABcD1M4AaBbE", url: "https://github.com/testowner/testrepo/discussions/10#discussioncomment-999" } } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.graphql).toHaveBeenCalledTimes(4),
expect(mockGithub.graphql).toHaveBeenCalledWith(expect.stringContaining("addDiscussionComment"), expect.objectContaining({ dId: "D_kwDOABcD1M4AaBbC", body: expect.stringContaining("be settin' sail on this discussion") })),
expect(mockCore.setOutput).toHaveBeenCalledWith("reaction-id", "MDg6UmVhY3Rpb24xMjM0NTY3ODk="),
Expand All @@ -204,7 +204,7 @@ const mockCore = {
.mockResolvedValueOnce({ addReaction: { reaction: { id: "MDg6UmVhY3Rpb24xMjM0NTY3ODk=", content: "EYES" } } })
.mockResolvedValueOnce({ repository: { discussion: { id: "D_kwDOABcD1M4AaBbC" } } })
.mockResolvedValueOnce({ addDiscussionComment: { comment: { id: "DC_kwDOABcD1M4AaBbE", url: "https://github.com/testowner/testrepo/discussions/10#discussioncomment-789" } } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockGithub.graphql).toHaveBeenCalledWith(
expect.stringContaining("addDiscussionComment"),
expect.objectContaining({ dId: "D_kwDOABcD1M4AaBbC", body: expect.stringContaining("be settin' sail on this discussion comment"), replyToId: "DC_kwDOABcD1M4AaBbC" })
Expand All @@ -219,21 +219,21 @@ const mockCore = {
((process.env.GH_AW_REACTION = "eyes"),
(global.context.eventName = "discussion"),
(global.context.payload = { repository: { html_url: "https://github.com/testowner/testrepo" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.setFailed).toHaveBeenCalledWith("Discussion number not found in event payload"));
}),
it("should handle missing discussion or comment info for discussion_comment", async () => {
((process.env.GH_AW_REACTION = "eyes"),
(global.context.eventName = "discussion_comment"),
(global.context.payload = { discussion: { number: 10 }, repository: { html_url: "https://github.com/testowner/testrepo" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.setFailed).toHaveBeenCalledWith("Discussion or comment information not found in event payload"));
}),
it("should handle unsupported event types", async () => {
((process.env.GH_AW_REACTION = "eyes"),
(global.context.eventName = "push"),
(global.context.payload = { repository: { html_url: "https://github.com/testowner/testrepo" } }),
await eval(`(async () => { ${reactionScript} })()`),
await eval(`(async () => { ${reactionScript}; await main(); })()`),
expect(mockCore.setFailed).toHaveBeenCalledWith("Unsupported event type: push"));
}));
}));
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflow/js/add_reviewer.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ ${reviewersListMarkdown}
}
}

await main();
module.exports = { main };
Loading