[jsweep] Clean add_workflow_run_comment.cjs#23208
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[jsweep] Clean add_workflow_run_comment.cjs#23208github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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