Skip to content

ci: keep Bundle Size job green on transient GitHub comment failures - #1795

Merged
thymikee merged 3 commits into
mainfrom
claude/affectionate-sutherland-9afef9
Aug 18, 2026
Merged

ci: keep Bundle Size job green on transient GitHub comment failures#1795
thymikee merged 3 commits into
mainfrom
claude/affectionate-sutherland-9afef9

Conversation

@thymikee

@thymikee thymikee commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

On PR #1789 (run 32050847506) the size measurement and job summary completed, then --post-comment got a 503 No server is currently available from the GitHub comments API during an incident and the whole Bundle Size lane went red. The lane's real job had already succeeded; only the cosmetic comment write failed.

scripts/size-report.mjs --post-comment is now best-effort against transient GitHub failures, and idempotent under retry:

  • Retry wraps the whole list → write cycle (retryTransient(() => syncGitHubComment(...))), 4 attempts with 1s/2s/4s backoff on 5xx / 429 / network error. Because every attempt re-lists first, a create whose response was lost but landed server-side is reconciled into a PATCH of the marker comment on the next attempt — no duplicate POST (addresses the review comment).
  • If it still fails, TransientGitHubError is caught at the top: ::warning:: annotation, one-line note appended to $GITHUB_STEP_SUMMARY, exit 0.
  • Any other non-OK status (401/403/404/422…) throws immediately, no retry — misconfiguration still fails the job.
  • assertGitHubWriteResponse removed; it guarded only this comment write, the sole GitHub write in the file.
  • SIZE_REPORT_RETRY_BASE_MS env override so the regression tests do not sleep through real backoff.

size.yml needs no change: it already appends the full report to $GITHUB_STEP_SUMMARY before the comment step, so the numbers were never lost — only the comment.

Validation

New scripts/__tests__/size-report-post-comment.test.ts (registered in the unit-core project) spawns the real script with a --imported fetch stub driven by a per-call response script, and asserts on exit code, stdout/stderr, $GITHUB_STEP_SUMMARY, and the exact sequence of HTTP calls:

test asserts
uncertain-create reconciliation GET, POST(net error), GET(marker now present), PATCH /42 — no second POST
transient exhaustion 503×4::warning:: on stdout, note in step summary, exit 0, one list call per attempt
fatal 4xx GET 200, POST 401 → nonzero exit, Failed to create PR comment: 401, no ::warning::, no retry

Planted red evidence (script swapped, tests run, script restored):

  • main's script → reconciliation ✗ (throws on the net error), exhaustion ✗ (exit 1 on 503), fatal-4xx ✓ (guard: fatality preserved).
  • Previous PR head (request-level retry) → reconciliation ✗ with exactly the reported defect: actual POST, POST vs expected POST, PATCH /42. (The exhaustion test on that head only timed out at 5s because it lacked the backoff override — harness artifact, not behavioral evidence.)

Local gates on the final head: oxfmt --check, oxlint --deny-warnings, fallow audit --base 302019563 (✓ no issues; the earlier CRAP/cyclomatic finding on attemptGitHubRequest is gone — retry/classify are split into retryTransient/backoffOrRethrow and githubRequest/fetchOrTransient/githubStatusError), vitest run --project unit-core scripts/__tests__/size-report-post-comment.test.ts (3/3), and standalone tsc --strict on the test file. The earlier Analyze (python) failure was CodeQL init dying on the same GitHub 503 outage, not this change.

The size measurement and job summary had already succeeded on PR #1789
(run 32050847506) when the PR comment write got a 503 during a GitHub
incident and failed the whole lane.

--post-comment now retries 5xx / 429 / network errors (4 attempts,
1s/2s/4s backoff) on both the list and write calls. If it still fails,
it prints a ::warning::, appends a note to $GITHUB_STEP_SUMMARY, and
exits 0. Other 4xx (bad token, missing permissions) stay fatal.
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 2.26 MB 2.26 MB 0 B
JS gzip 744.4 kB 744.4 kB 0 B
npm tarball 863.7 kB 863.7 kB 0 B
npm unpacked 3.01 MB 3.01 MB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.2 ms 21.0 ms -0.2 ms
CLI --help 51.6 ms 54.2 ms +2.7 ms

Top changed chunks: no changes in the largest emitted chunks.

@thymikee

Copy link
Copy Markdown
Member Author

Request changes: The retry wrapper blindly reissues the initial POST after a network/5xx failure. That request may have succeeded server-side before its response was lost, so retries can create duplicate marker comments. Make creation idempotent or reconcile after an uncertain create rather than repeating POST unchanged. The exact head also fails required Fallow Code Quality because attemptGitHubRequest exceeds complexity/CRAP thresholds. Add focused committed regressions for transient exhaustion (warn + exit 0), fatal 4xx (nonzero), and uncertain-create reconciliation, with planted/reverted red evidence. Please also use the required ## Summary / ## Validation body structure. Bundle Size passes normally; CodeQL Python 503 appears infrastructural, but Fallow is a real blocker.

…egressions

Retry now wraps the whole list -> write cycle rather than each request, so a
create whose response was lost (network error / 5xx) is re-listed on the next
attempt and turned into a PATCH of the marker comment instead of a duplicate
POST. Splits the retry/classify helpers under the fallow complexity gate.

Adds scripts/__tests__/size-report-post-comment.test.ts (unit-core): spawns the
real script against a stubbed fetch and pins uncertain-create reconciliation,
transient exhaustion (warn + exit 0), and fatal 4xx (nonzero, no retry).
SIZE_REPORT_RETRY_BASE_MS lets the tests skip real backoff.
@thymikee

Copy link
Copy Markdown
Member Author

Addressed in 303c47e:

  • Duplicate-POST on uncertain create — retry now wraps the whole list → write cycle instead of each request, so a lost create response is reconciled into a PATCH of the marker comment on the next attempt (syncGitHubComment re-lists every time). No POST is ever repeated unchanged.
  • Fallow — retry/classify are split under the thresholds; fallow audit --base 302019563 is ✓ locally on this head.
  • Committed regressionsscripts/__tests__/size-report-post-comment.test.ts (unit-core): reconciliation (asserts exact GET, POST, GET, PATCH /42 call sequence), transient exhaustion (warn + exit 0 + step-summary note), fatal 4xx (nonzero, no retry). Red evidence in the PR body: on main 2/3 fail; on the previous head the reconciliation test fails with exactly POST, POST vs POST, PATCH.
  • PR body rewritten in ## Summary / ## Validation form.

🤖 Addressed by Claude Code

@thymikee

Copy link
Copy Markdown
Member Author

Re-reviewed exact head 303c47e. The prior retry blocker is resolved: retries now re-list before writing, the lost-POST regression proves GET→POST→GET→PATCH, fatal/transient outcomes are covered, and Fallow is green. One remaining scope blocker: commit 2baae3 also changes 45 byte-exact Maestro conformance corpus YAML files only through quote/newline formatter churn. Those files are unrelated to the size-comment fix and should be reverted from this PR (PR #1803 addresses the formatter sweep itself). iOS Smoke is still pending; other exact-head checks pass.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Aug 18, 2026
@thymikee
thymikee merged commit 04613ae into main Aug 18, 2026
28 of 29 checks passed
@thymikee
thymikee deleted the claude/affectionate-sutherland-9afef9 branch August 18, 2026 09:35
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-18 09:36 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant