Skip to content

[jsweep] Clean add_workflow_run_comment.cjs#23208

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
jsweep/add-workflow-run-comment-469d40b1a3d771d2
Draft

[jsweep] Clean add_workflow_run_comment.cjs#23208
github-actions[bot] wants to merge 1 commit intomainfrom
jsweep/add-workflow-run-comment-469d40b1a3d771d2

Conversation

@github-actions
Copy link
Contributor

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

  • Simplified block-scoped variable names in the switch statement: renamed issueNumber, issueNumberForComment, prNumber, prNumberForReviewComment → all to number within their respective case blocks. 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:

  1. main() - activation comments disabled: Verifies that when GH_AW_SAFE_OUTPUT_MESSAGES sets activationComments: false, the function exits early without making any API calls.
  2. main() - issue_comment missing number: Verifies ERR_NOT_FOUND is set when the issue_comment event payload lacks an issue number (parallel to the existing issues test, but the issue_comment path was untested).
  3. addCommentWithWorkflowLink() - custom workflow name: Verifies that GH_AW_WORKFLOW_NAME env var is reflected in the comment body.

Validation

  • ✅ Formatting: npm run format:cjs — no changes needed
  • ✅ Linting: npm run lint:cjs — all files use Prettier code style
  • ✅ Type checking: npm run typecheck — no type errors
  • ✅ Tests: npm run test:js — all 19 tests pass

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 29, 2026, 4:39 AM UTC

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants