Skip to content

[jsweep] Clean check_skip_if_match.cjs#22596

Merged
pelikhan merged 1 commit intomainfrom
jsweep/check-skip-if-match-14a7764de4c549e7
Mar 24, 2026
Merged

[jsweep] Clean check_skip_if_match.cjs#22596
pelikhan merged 1 commit intomainfrom
jsweep/check-skip-if-match-14a7764de4c549e7

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Cleaned actions/setup/js/check_skip_if_match.cjs to align with the patterns used in its sibling file check_skip_if_no_match.cjs.

Context type: github-script


Changes to check_skip_if_match.cjs

  • Destructure process.env at the top — replaces four individual process.env.X reads with a single destructuring assignment (same style as check_skip_if_no_match.cjs)
  • Destructure API response inlineresponse.data.total_count → direct { data: { total_count: totalCount } } in the await expression

Changes to check_skip_if_match.test.cjs

  • Reformatted from compressed/minified style to idiomatic, readable code with consistent indentation
  • Added edge case: negative GH_AW_SKIP_MAX_MATCHES ("-1") — validates the boundary check rejects negative integers (not just zero/NaN)
  • Test count: 15 → 16 tests

Validation ✅

Check Result
Formatting (npm run format:cjs) ✓ All files pass Prettier
Linting (npm run lint:cjs) ✓ All matched files use Prettier code style
Type checking (npm run typecheck) ✓ No type errors
Tests (npm run test:js --no-file-parallelism) check_skip_if_match.test.cjs16/16 tests passed

Pre-existing failures in assign_issue, mcp_handler_go, frontmatter_hash_github_api, git_helpers, and safe_outputs_tools_loader are unrelated to this change (network/filesystem environment constraints).

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 26, 2026, 4:36 AM UTC

- Destructure process.env at the top (matching check_skip_if_no_match.cjs style)
- Destructure API response directly in the await expression
- Reformat minified test file into readable idiomatic style
- Add missing edge case test: negative GH_AW_SKIP_MAX_MATCHES (-1)
- 15 → 16 test cases total

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 24, 2026 04:46
Copilot AI review requested due to automatic review settings March 24, 2026 04:47
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 check_skip_if_match.cjs and its tests to match the structure/style used by the sibling “no match” script, and expands test coverage for max-match parsing edge cases.

Changes:

  • Refactors check_skip_if_match.cjs to destructure process.env up-front and destructure the GitHub API response inline.
  • Reformats check_skip_if_match.test.cjs into readable, idiomatic test code.
  • Adds a new test case validating negative GH_AW_SKIP_MAX_MATCHES is rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
actions/setup/js/check_skip_if_match.cjs Refactors env/API response reads to match patterns used in sibling implementation.
actions/setup/js/check_skip_if_match.test.cjs Rewrites tests for readability and adds coverage for negative max-matches parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +78 to +80
process.env.GH_AW_WORKFLOW_NAME = "test-workflow";

await eval(`(async () => { ${checkSkipIfMatchScript}; await main(); })()`);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

These tests execute the script via fs.readFileSync + eval, which is brittle and inconsistent with most sibling action tests that require("./<script>.cjs") and call main() directly (e.g. actions/setup/js/check_skip_if_no_match.test.cjs:3). Since check_skip_if_match.cjs exports main, consider switching to require/import + calling main() instead of eval to reduce side effects and simplify the test setup.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +72
originalEnv = {
GH_AW_SKIP_QUERY: process.env.GH_AW_SKIP_QUERY,
GH_AW_WORKFLOW_NAME: process.env.GH_AW_WORKFLOW_NAME,
GH_AW_SKIP_MAX_MATCHES: process.env.GH_AW_SKIP_MAX_MATCHES,
};
const scriptPath = path.join(process.cwd(), "check_skip_if_match.cjs");
checkSkipIfMatchScript = fs.readFileSync(scriptPath, "utf8");
});

afterEach(() => {
if (originalEnv.GH_AW_SKIP_QUERY !== undefined) {
process.env.GH_AW_SKIP_QUERY = originalEnv.GH_AW_SKIP_QUERY;
} else {
delete process.env.GH_AW_SKIP_QUERY;
}
if (originalEnv.GH_AW_WORKFLOW_NAME !== undefined) {
process.env.GH_AW_WORKFLOW_NAME = originalEnv.GH_AW_WORKFLOW_NAME;
} else {
delete process.env.GH_AW_WORKFLOW_NAME;
}
if (originalEnv.GH_AW_SKIP_MAX_MATCHES !== undefined) {
process.env.GH_AW_SKIP_MAX_MATCHES = originalEnv.GH_AW_SKIP_MAX_MATCHES;
} else {
delete process.env.GH_AW_SKIP_MAX_MATCHES;
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The test suite saves/restores GH_AW_SKIP_QUERY/NAME/MAX, but not GH_AW_SKIP_SCOPE. If a developer (or CI) runs tests with GH_AW_SKIP_SCOPE already set (e.g. "none"), several expectations (repo scoping) will fail. Include GH_AW_SKIP_SCOPE in originalEnv and restore/delete it in afterEach (or explicitly delete it in beforeEach) to make the tests hermetic.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 4a8c584 into main Mar 24, 2026
62 checks passed
@pelikhan pelikhan deleted the jsweep/check-skip-if-match-14a7764de4c549e7 branch March 24, 2026 04:53
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.

2 participants