Repository navigation
Add generated footer to status comment updates #51165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
339bb7e
bdb4d42
953d215
4dd5675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ const { sanitizeContent } = require("./sanitize_content.cjs"); | |
| const { ERR_VALIDATION } = require("./error_codes.cjs"); | ||
| const { parseBoolTemplatable } = require("./templatable.cjs"); | ||
| const { resolveTopLevelDiscussionCommentId } = require("./github_api_helpers.cjs"); | ||
| const { assembleMarkdownBodyParts } = require("./markdown_body_helpers.cjs"); | ||
|
|
||
| /** | ||
| * Collect generated asset URLs from safe output jobs | ||
|
|
@@ -258,6 +259,24 @@ async function main() { | |
| }); | ||
| } | ||
|
|
||
| // Append the generated footer (attribution + XML marker) | ||
| const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE ?? ""; | ||
| const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL ?? ""; | ||
| const triggeringIssueNumber = context.payload?.issue?.number; | ||
| const triggeringPRNumber = context.payload?.pull_request?.number; | ||
| const triggeringDiscussionNumber = context.payload?.discussion?.number; | ||
| const markdownParts = assembleMarkdownBodyParts({ | ||
| includeFooter: true, | ||
| workflowName, | ||
| runUrl, | ||
| workflowSource, | ||
| workflowSourceURL, | ||
| triggeringIssueNumber, | ||
| triggeringPRNumber, | ||
| triggeringDiscussionNumber, | ||
| }); | ||
| message += "\n\n" + markdownParts.footer; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/codebase-design] The footer is appended to 💡 Suggested fixMirror the const sanitizedMessage = sanitizeContent(message);
const fullMessage = sanitizedMessage + "\n\n" + markdownParts.footer;
// then use fullMessage in all three code pathsThis ensures the XML traceability markers are never passed through the sanitizer. @copilot please address this. |
||
|
|
||
| // Add "needs-review" label when detection produced a warning | ||
| if (detectionConclusion === "warning") { | ||
| await tryAddNeedsReviewLabel(commentRepo); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,7 +331,7 @@ const mockCore = { | |
| (process.env.GH_AW_SAFE_OUTPUT_JOBS = JSON.stringify({ create_issue: "issue_url" })), | ||
| await eval(`(async () => { ${notifyCommentScript}; await main(); })()`)); | ||
| const callArgs = mockGithub.request.mock.calls[0][1]; | ||
| expect(callArgs.body).toMatch(/completed successfully!$/); | ||
| expect(callArgs.body).toContain("completed successfully!"); | ||
| }), | ||
| it("should handle empty safe output jobs gracefully", async () => { | ||
| ((process.env.GH_AW_COMMENT_ID = "123456"), | ||
|
|
@@ -340,7 +340,7 @@ const mockCore = { | |
| (process.env.GH_AW_AGENT_CONCLUSION = "success"), | ||
| await eval(`(async () => { ${notifyCommentScript}; await main(); })()`)); | ||
| const callArgs = mockGithub.request.mock.calls[0][1]; | ||
| expect(callArgs.body).toMatch(/completed successfully!$/); | ||
| expect(callArgs.body).toContain("completed successfully!"); | ||
| })); | ||
| }), | ||
| describe("when safe_outputs job fails", () => { | ||
|
|
@@ -373,5 +373,25 @@ const mockCore = { | |
| await eval(`(async () => { ${notifyCommentScript}; await main(); })()`), | ||
| expect(mockGithub.request).toHaveBeenCalledWith("PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}", expect.objectContaining({ body: expect.stringContaining("completed successfully!") }))); | ||
| })); | ||
| }), | ||
| describe("footer in status comment", () => { | ||
| it("should include the generated footer in the updated comment body", async () => { | ||
| ((process.env.GH_AW_COMMENT_ID = "123456"), | ||
| (process.env.GH_AW_RUN_URL = "https://github.com/owner/repo/actions/runs/123"), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] The two new footer tests share identical env setup and differ only in @copilot please address this. |
||
| (process.env.GH_AW_WORKFLOW_NAME = "test-workflow"), | ||
| (process.env.GH_AW_AGENT_CONCLUSION = "success"), | ||
| await eval(`(async () => { ${notifyCommentScript}; await main(); })()`)); | ||
| const callArgs = mockGithub.request.mock.calls[0][1]; | ||
| expect(callArgs.body).toMatch(/Generated by \[test-workflow\]/); | ||
|
|
||
| }), | ||
| it("should include the generated footer even when agent fails", async () => { | ||
| ((process.env.GH_AW_COMMENT_ID = "123456"), | ||
| (process.env.GH_AW_RUN_URL = "https://github.com/owner/repo/actions/runs/123"), | ||
| (process.env.GH_AW_WORKFLOW_NAME = "test-workflow"), | ||
| (process.env.GH_AW_AGENT_CONCLUSION = "failure"), | ||
| await eval(`(async () => { ${notifyCommentScript}; await main(); })()`)); | ||
| const callArgs = mockGithub.request.mock.calls[0][1]; | ||
| expect(callArgs.body).toMatch(/Generated by \[test-workflow\]/); | ||
| }); | ||
| })); | ||
| })); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/codebase-design]
GH_AW_WORKFLOW_SOURCEandGH_AW_WORKFLOW_SOURCE_URLare re-read fromprocess.envhere, butworkflowNameandrunUrlwere already read at lines 114–115 from the same source. Consider reading all workflow env vars together near the top ofmain()for consistency and to make the full set of dependencies obvious at a glance.@copilot please address this.