[jsweep] Clean add_workflow_run_comment.cjs#23208
Conversation
- Rename block-scoped switch variables to 'number' (removes verbose issueNumber/issueNumberForComment/prNumber/prNumberForReviewComment) - Add 4 edge-case tests: activation-comments disabled, issue_comment missing number, custom GH_AW_WORKFLOW_NAME, no workflow-id marker without env var (15 → 19 tests) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Cleans up add_workflow_run_comment.cjs (GitHub Script context) and extends test coverage for activation comment creation on issues/PRs/discussions.
Changes:
- Simplified per-
switch-case variable naming by usingnumberwithin block scopes. - Added edge-case tests for disabled activation comments, missing
issue_commentissue number, and custom workflow name in comment body.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actions/setup/js/add_workflow_run_comment.cjs | Refactors event-specific number variables in main() without changing behavior. |
| actions/setup/js/add_workflow_run_comment.test.cjs | Adds 3 new describe blocks (4 additional tests total mentioned in PR) covering early-exit, missing payload number, and custom workflow name rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| afterEach(() => { | ||
| delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES; | ||
| }); |
There was a problem hiding this comment.
This afterEach hook relies on Vitest globals while the file otherwise uses named imports from vitest. For consistency (and to avoid surprises if globals is ever turned off), either import afterEach alongside beforeEach, or move the GH_AW_SAFE_OUTPUT_MESSAGES cleanup into the top-level beforeEach env reset and drop this afterEach entirely.
|
@copilot review comments and fix https://github.com/github/gh-aw/actions/runs/23660418751/job/68928865391 |
|
@copilot review comments and fix https://github.com/github/gh-aw/actions/runs/23660418751/job/68928865391 |
… drop afterEach Agent-Logs-Url: https://github.com/github/gh-aw/sessions/259ea2e7-66d2-4c80-b079-60dc1dda2956 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 33992e7 — moved Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
- #23284
pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools:
github:
min-integrity: approved # merged | approved | unapproved | none💥 [THE END] — Illustrated by Smoke Claude
| case "issues": { | ||
| const issueNumber = context.payload?.issue?.number; | ||
| if (!issueNumber) { | ||
| const number = context.payload?.issue?.number; |
There was a problem hiding this comment.
Good rename from issueNumber to number — the variable is now consistent across all event handler cases, reducing cognitive overhead when reading the switch block.
| @@ -423,4 +424,55 @@ describe("add_workflow_run_comment", () => { | |||
| expect(mockCore.setOutput).toHaveBeenCalledWith("comment-repo", "testowner/testrepo"); | |||
| }); | |||
There was a problem hiding this comment.
Good addition: the activationComments: false test ensures the early-exit path is covered. The env cleanup in afterEach (line 53) should handle GH_AW_SAFE_OUTPUT_MESSAGES — confirmed it's now deleted there too.
Summary
Cleaned
add_workflow_run_comment.cjs— a github-script context file that creates activation comments with workflow run links on issues, PRs, and discussions.Changes
Code Cleanup
switchstatement: renamedissueNumber,issueNumberForComment,prNumber,prNumberForReviewComment→ all tonumberwithin their respectivecaseblocks. Since each is block-scoped ({ }), there's no ambiguity and the names are cleaner.Test Improvements (15 → 19 tests)
Added 4 edge-case tests covering previously untested paths:
main() - activation comments disabled: Verifies that whenGH_AW_SAFE_OUTPUT_MESSAGESsetsactivationComments: false, the function exits early without making any API calls.main() - issue_comment missing number: VerifiesERR_NOT_FOUNDis set when theissue_commentevent payload lacks an issue number (parallel to the existingissuestest, but theissue_commentpath was untested).addCommentWithWorkflowLink() - custom workflow name: Verifies thatGH_AW_WORKFLOW_NAMEenv var is reflected in the comment body.Validation
npm run format:cjs— no changes needednpm run lint:cjs— all files use Prettier code stylenpm run typecheck— no type errorsnpm run test:js— all 19 tests pass✨ PR Review Safe Output Test - Run 23673676254
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: