Skip to content

[jsweep] Clean add_workflow_run_comment.cjs#23208

Merged
pelikhan merged 2 commits intomainfrom
jsweep/add-workflow-run-comment-469d40b1a3d771d2
Mar 28, 2026
Merged

[jsweep] Clean add_workflow_run_comment.cjs#23208
pelikhan merged 2 commits intomainfrom
jsweep/add-workflow-run-comment-469d40b1a3d771d2

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Mar 27, 2026

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


✨ 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.

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 ·

- 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>
@pelikhan pelikhan marked this pull request as ready for review March 27, 2026 18:00
Copilot AI review requested due to automatic review settings March 27, 2026 18:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 using number within block scopes.
  • Added edge-case tests for disabled activation comments, missing issue_comment issue 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.

Comment on lines +446 to +448
afterEach(() => {
delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES;
});
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review comments and fix https://github.com/github/gh-aw/actions/runs/23660418751/job/68928865391

@pelikhan
Copy link
Copy Markdown
Collaborator

… 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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

@copilot review comments and fix https://github.com/github/gh-aw/actions/runs/23660418751/job/68928865391

Fixed in 33992e7 — moved delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES into the top-level beforeEach env reset and dropped the nested afterEach entirely.

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:

  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js (http block)
  • invalid.example.invalid
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git git conf�� user.name lure tions/setup/js/node_modules/.bin/git -M main /usr/sbin/git git init�� --bare --initial-branch=main k/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/git &#39;/tmp/bare-incregit &#39;/tmp/bare-increadd cal/bin/git git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from pelikhan March 27, 2026 23:26
@pelikhan pelikhan merged commit bbac26f into main Mar 28, 2026
53 checks passed
@pelikhan pelikhan deleted the jsweep/add-workflow-run-comment-469d40b1a3d771d2 branch March 28, 2026 00:54
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 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;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

3 participants