Skip to content

[jsweep] Clean update_pull_request_branches.cjs#40246

Merged
pelikhan merged 2 commits into
mainfrom
signed/jsweep/update-pull-request-branches-43cdd844c91ef0d3
Jun 19, 2026
Merged

[jsweep] Clean update_pull_request_branches.cjs#40246
pelikhan merged 2 commits into
mainfrom
signed/jsweep/update-pull-request-branches-43cdd844c91ef0d3

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Clean-up pass on the update_pull_request_branches action script: modernises the PR-iteration loop and expands test coverage for previously untested edge cases.


Changes

actions/setup/js/update_pull_request_branches.cjs — refactor (low impact, non-breaking)

  • Replaced index-based for loop with a destructured for...of using .entries().
  • Removed the intermediate pullNumber variable; the PR number is now bound directly in the loop header.
  • No behavioural change — purely a readability/style improvement.

actions/setup/js/update_pull_request_branches.test.cjs — tests added (low impact, non-breaking)

Four new test cases added:

# Scenario Assertion
1 Closed PR Filtered out — no update attempted
2 mergeable: null (GitHub "pending" state) Treated as non-mergeable; skipped gracefully
3 Non-object error thrown Handled non-fatally; loop continues
4 HTTP 404 status error Handled non-fatally; loop continues

Risk Assessment

Dimension Assessment
Breaking change No
Behaviour change No
Test coverage delta ↑ +4 cases
Rollback complexity Trivial

Commit Log

SHA Message
f3475869e jsweep: clean update_pull_request_branches.cjs
b216daa22 Merge branch main into signed/jsweep/update-pull-request-branches-43cdd844c91ef0d3

Generated by PR Description Updater for issue #40246 · 50 AIC · ⌖ 6.8 AIC · ⊞ 4.5K ·

- Replace indexed for-loop with for...of entries() in main()
- Add 4 new test cases (17 total, up from 13):
  - Skips closed pull requests
  - Skips PRs with mergeable: null (pending computation)
  - Does not treat non-object errors as non-fatal
  - Does not treat 404 status errors as non-fatal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 19, 2026 06:05
Copilot AI review requested due to automatic review settings June 19, 2026 06:05
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #40246 does not have the 'implementation' label and has 0 new lines of code in business logic directories (≤100 threshold). Neither enforcement condition is met.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR performs a small cleanup pass on update_pull_request_branches.cjs (a github-script entrypoint) and expands the unit test suite to cover additional edge cases around mergeability filtering and non-fatal error classification.

Changes:

  • Refactors the update loop in main() to use for...of mergeablePullRequests.entries() instead of an indexed for loop.
  • Adds 4 test cases covering closed PRs, mergeable: null, non-object errors, and non-422 status errors.
Show a summary per file
File Description
actions/setup/js/update_pull_request_branches.cjs Refactors the PR update iteration loop for clarity while preserving behavior.
actions/setup/js/update_pull_request_branches.test.cjs Adds new test coverage for mergeability filtering and non-fatal error detection edge cases.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@pelikhan pelikhan merged commit 258604b into main Jun 19, 2026
15 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 19, 2026

@github-actions github-actions Bot left a comment

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.

No blocking issues found.

The for...of entries() refactor is semantically identical to the indexed loop — correct async sequencing, correct sleep guard, correct types. The four new tests each cover a real edge case previously untested (closed state, mergeable: null, non-object throws, non-422 status codes); all assertions are well-targeted.

Review notes
  • Loop refactor: entries() produces [index, value] tuples; i still gates the sleep — behavior unchanged.
  • isNonFatalUpdateBranchError: the typeof === 'object' && error !== null guard correctly prevents 'status' in error from throwing on primitives before falling through to the message check.
  • mergeable=null test: String(null) === 'null' matches the log template — assertion is accurate.

🔎 Code quality review by PR Code Quality Reviewer · 62.7 AIC · ⌖ 6.8 AIC · ⊞ 5.1K

@github-actions github-actions Bot left a comment

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.

Skills-Based Review 🧠

Applied /tdd — approving with one minor test-style note.

📋 Key Themes & Highlights

Key Themes

  • Multi-assertion test: isNonFatalUpdateBranchError primitive-input test bundles 3 input types in one it(). Consider it.each for better failure isolation (non-blocking).

Positive Highlights

  • for...of entries() idiom swap is behaviorally equivalent and cleaner — the index i still correctly controls the sleep delay
  • ✅ New tests fill genuine untested paths: closed-PR filtering, mergeable: null pending state, primitive/null inputs to isNonFatalUpdateBranchError, and non-whitelisted 404 status codes
  • ✅ Arrange/Act/Assert structure is consistent across all four new tests
  • ✅ All 17 tests pass with format, lint, and typecheck gates green before submission

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 48.1 AIC · ⌖ 7.11 AIC · ⊞ 6.9K

expect(moduleUnderTest.isNonFatalUpdateBranchError("some string error")).toBe(false);
expect(moduleUnderTest.isNonFatalUpdateBranchError(null)).toBe(false);
expect(moduleUnderTest.isNonFatalUpdateBranchError(42)).toBe(false);
});

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.

[/tdd] Three distinct primitive inputs (string, null, number) are asserted in a single it() block — if the first assertion fails, the other two inputs go untested in that run.

💡 Consider it.each for better failure isolation
it.each([
  ["some string error"],
  [null],
  [42],
])("does not treat %s as a non-fatal error", (input) => {
  expect(moduleUnderTest.isNonFatalUpdateBranchError(input)).toBe(false);
});

This is a minor style note — the current approach still validates the behaviour correctly, and all cases fail fast on the same function.

@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 4 new test(s): 4 design, 0 implementation, 0 guideline violation(s). All 4 new tests enforce behavioral contracts with edge-case coverage.

📊 Metrics & Test Classification (4 tests analyzed)
Metric Value
New/modified tests analyzed 4
✅ Design tests (behavioral contracts) 4 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 4 (100%)
Duplicate test clusters 0
Test inflation detected YES (34:1 test:prod lines; −10 pts)
🚨 Coding-guideline violations 0
Test File Classification Issues Detected
skips closed pull requests when filtering mergeable pull requests update_pull_request_branches.test.cjs:210 ✅ Design
skips pull requests where mergeable is null (GitHub pending computation) update_pull_request_branches.test.cjs:222 ✅ Design
does not treat non-object errors as non-fatal update_pull_request_branches.test.cjs:233 ✅ Design
does not treat 404 status errors as non-fatal update_pull_request_branches.test.cjs:239 ✅ Design

Go: 0 (*_test.go); JavaScript: 4 (*.test.cjs). Other languages detected but not scored.

Inflation note: The production change is a minor loop refactor (+1 line), while 4 new edge-case tests add 34 lines — intentional test-gap filling rather than speculative inflation.

Mocking: vi.mock("./github_rate_limit_logger.cjs") and global.core/global.github/global.context stubs are all external I/O / GitHub Actions runtime — acceptable targets per guidelines.

Verdict

Check passed. 0% implementation tests (threshold: 30%). All 4 new tests verify observable behavioral contracts: closed-PR skipping, null-mergeable skipping, non-object error rejection, and 404 error rejection — each covering a real edge case that could silently misbehave without the test.

References:

🧪 Test quality analysis by Test Quality Sentinel · 70.2 AIC · ⌖ 8.2 AIC · ⊞ 8.3K ·

@github-actions github-actions Bot left a comment

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.

✅ Test Quality Sentinel: 90/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%).

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