Skip to content

ci(macos): split the macOS suite into three shards under the same 20-minute cap - #6983

Merged
lidge-jun merged 1 commit into
devfrom
codex/6978-macos-shard-budget-261012
Oct 12, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/6978-macos-shard-budget-261012

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

The macOS test shards (macos 1/2, macos 2/2) had grown to their 20-minute job limit. Full dispatch run 38214884055 cancelled macos 2/2 at the cap with 68 of its 1,118 files left, and every test it had run was passing. This splits the macOS suite into three shards and keeps the 20-minute cap.

Where the time went. I parsed the shard and control logs of the seventeen workflow_dispatch runs on dev from 2026-10-04 to 10-12 with parseJobLog from scripts/ci/test-durations.ts.

2026-10-04 (37239784344) 2026-10-12 (38214884055)
Files selected 2,077 2,236
Unsharded control, test step 1,696 s 2,170 s
Slower macOS half, test step 867 s ≥1,155 s (cancelled)

Across all seventeen control runs the fitted trend is about +22 s of test time and +25 files per day (about 1.2% a day; individual runs range from 1,687 s to 2,170 s, so the two endpoints overstate it). The problem is the suite outgrowing two halves, not one misbehaving shard. Two smaller effects add to it. Runner variance moves the same recorded file set between 636 s and 864 s per shard. The shard balancer also uses a duration table from 2026-09-23 where 678 files have no row and weigh 157 ms, while on macOS they average about 0.7 s, so two shards predicted at 683 s each can differ by up to about 190 s in one run. That table is filed separately as #6982, because refreshing it also changes Linux and Windows shard membership.

Why three shards and not a longer cap. Replaying the exact assignment algorithm against measured per-file macOS times reproduces the cancellation: the slow half needed 1,205 s of tests, plus about 55 s of setup, which is more than 20 minutes. The same replay puts the slowest of three shards at 635–796 s across the last five runs, about 14.2 minutes with setup, which leaves about 5.8 minutes under the 20-minute cap. That is a replay estimate, not a completed run. The hosted dispatch below is the actual measurement.

#4905/#5028 sized the unsharded control's cap from a measured complete run because sharding that lane would remove its purpose. This lane is the reverse case. It was sharded so macOS stays off the critical path, and it runs in the main/preview push runs that release.yml gates on. Keeping two shards at 25–30 minutes would leave a 21-minute or longer macOS leg on that path, and the leg would keep growing with the suite. By the rule in tests/helpers/test-budget.ts, a budget goes up only when the wait is intrinsic to what is being tested, and this wait comes from suite size. Keeping 20 minutes also means a wedged shard (#4956) is cut off just as early as before.

What does not change. Failure handling is untouched. scripts/ci/run-bun-test-batches.sh still fails a shard on the first assertion failure, process timeout or Bun crash, with no retry and no exclusions. The aggregate ci gate checks platform-macos at the job level, release.yml requires a successful push-event run, and no ruleset on dev/main/preview lists a required status check. So the check name changing from macos N/2 to macos N/3 affects no gate.

Changes:

  • .github/workflows/ci.yml (platform-macos only): check name macos ${{ matrix.shard }}/3, matrix.shard: [1, 2, 3], TEST_SHARD: ${{ matrix.shard }}/3, and the comment rationale. timeout-minutes: 20 is unchanged.
  • tests/ci-workflows/ci-workflows.test.ts: pins the three-shard matrix and /3, and asserts that the check-name divisor and the TEST_SHARD divisor both equal the matrix length.
  • tests/ci-workflows/macos-serial-lanes.test.ts: reads the shard count from the workflow matrix instead of hard-coding 2, checks ownership across every shard, and injects assertion and crash failures into the shard that owns the target file. With three shards the serial target moves to shard 3, so injecting into shard 1 would have made those cases vacuous.
  • structure/ops/docs-and-release.md, structure/overview.md: shard names 1/3, 2/3 and 3/3.

Refs #6978

Verification

  • bun run typecheck: exit 0

  • bun test --isolate --timeout 60000 ./tests/ci-workflows/: 1536 pass, 3 skip (Windows-only), 0 fail across 80 files, exit 0

  • After the final comment fix: ci-workflows, macos-serial-lanes, ci-review-lanes and ci-scope-reduction tests passed (196 pass, 0 fail, exit 0)

  • bun run structure:check passed; bun run privacy:scan passed

  • actionlint .github/workflows/ci.yml: only the three SC2016 infos that origin/dev already reports in the aggregate job script; no new diagnostics

  • Ablation: reverting only the check name to /2 fails ci-workflows.test.ts at the new divisor assertion

  • The full local bun run test was not run. This change touches only workflow shape, its contract tests and docs, and the suite the workflow runs is the hosted dispatch below.

  • Hosted, exact head 736e7bf04e. Both runs completed all three macOS shards successfully:

    Shard PR run 38222137968: job / test step lane=all dispatch 38222141865: job / test step
    1/3 14.0 min / 13m17s 14.2 min / 13m19s
    2/3 15.1 min / 14m05s 15.4 min / 14m23s
    3/3 12.3 min / 11m15s 10.6 min / 9m47s

    The slowest shard takes 15.4 minutes, 4.6 minutes under the 20-minute cap, so the cap is 30% above the measured duration. On the PR run, the measured per-shard times were 795/842/672 s against the replay's 796/740/657 s for the same files. The extra time on 2/3 is spread across several integration files, which matches the runner variance seen on dev. Shard 2/3 was the heaviest in both runs, which is the imbalance [Bug][CI]: shard duration table is three weeks stale and under-weights 678 unrecorded test files #6982 addresses. The macOS jobs waited 22–30 minutes for runners in these runs, which is also why this stops at three shards instead of four.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. This edits a GitHub Actions workflow, which AGENTS.md places behind explicit security review. The workflow change is limited to the platform-macos matrix (shard list, check name, TEST_SHARD divisor) and its comments. It adds or changes no permission, secret, action reference, trigger, runner label, if: condition or timeout. An independent review compared the parsed workflow against dev and found only those three semantic changes.

…minute cap

The two macOS shards reached their 20-minute job limit with tests still
passing: run 38214884055 cancelled macos 2/2 with 68 of 1118 files left.
Across seventeen dev dispatches (2026-10-04..10-12) the slower half's test
step grew from 867s to 1155s while the unsharded control grew from 1696s to
2170s, so the suite outgrew two halves rather than one shard misbehaving.

Replaying the duration assignment against those runs' measured per-file
times reproduces the cancel (1205s of tests on the slow half) and puts the
slowest of three shards at 635-796s, about 14 minutes with setup. The cap
stays 20 so a wedged shard (#4956) is cut off as early as before; failure
handling in run-bun-test-batches.sh is unchanged.

The contract tests now pin the three-shard matrix, check that the check
name and TEST_SHARD divisor match the matrix length, and run the batch
ownership fixture at the workflow's real divisor with failures injected
into the shard that owns the target file.

Refs #6978
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 12, 2026 08:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T08:14:50.947614Z 736e7bf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ac66a3ee-a24a-4509-96cf-d9ded6341a8c

📥 Commits

Reviewing files that changed from the base of the PR and between a0191a1 and 736e7bf.


📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • structure/ops/docs-and-release.md
  • structure/overview.md
  • tests/ci-workflows/ci-workflows.test.ts
  • tests/ci-workflows/macos-serial-lanes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.



📝 Walkthrough
📝 Walkthrough

Walkthrough

The macOS CI matrix now runs three shards instead of two. Documentation and workflow tests use the updated shard count. The control shard, batch size, worker count, and timeout remain unchanged.

Changes

macOS CI Sharding

Layer / File(s) Summary
Three-shard matrix and documented selection
.github/workflows/ci.yml, structure/ops/docs-and-release.md, structure/overview.md
The macOS workflow and documentation specify three shards. The control shard and existing batch settings remain unchanged.
Tests follow the workflow shard matrix
tests/ci-workflows/ci-workflows.test.ts, tests/ci-workflows/macos-serial-lanes.test.ts
Workflow assertions derive the shard count from the matrix. Serial-lane tests run across the actual shards or select the shard that owns each target file.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: luvs01


Merge Risk: ⚪ Minimal · up to 736e7

The three-shard configuration appears ready to merge after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: increasing the macOS CI suite from two shards to three while retaining the 20-minute job cap.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (3 skipped: 3 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed the complete five-file diff at 736e7bf04e570974c0217b37c7de136c00a03b38 against a0191a1b6fd921a6e5a9d12cb123c8df88b023e7 for workflow correctness and regression behavior. Matrix [1,2,3], job-name /3 and TEST_SHARD /3 move together; the 20-minute cap, process shape, failure verdict, triggers and permissions remain unchanged.

Independent bounded Linux/Bun 1.4.0 execution of macos-serial-lanes.test.ts with pattern every actual workflow|same basenames|assertion failure stops: 4 pass, 0 fail, 71 assertions; 22 filtered out. This runs the real workflow batch command and shell selection with synthetic files/fake Bun children, checking each file once across all three shards, basename collisions and injected assertion failures in the owning shard. Disposable homes; verified CPU 75%, RAM high/max 1280/1536 MiB, swap 0, tasks 64, nice 10, finite deadline. It is not a real macOS timing or full-suite receipt.

I closed my independently prepared headroom-only alternative #6985 unmerged after discovering this broader evidence-backed approach. Exact-head hosted PR run 38222137968 and full dispatch 38222141865 are still queued at this check; replay estimates are not their results. No new scan or dispatch was initiated by this review, and this ordinary correctness review does not stand in for the explicit independent workflow-boundary review required by policy.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration into dev (actor @lidge-jun, admin), merged as 03a9d31; head 736e7bf04e bound with --match-head-commit, no unresolved threads. Explicit workflow security review by GPT-6.1-Sol high (different family from the Claude builder): PASS. Only the platform-macos matrix, job name and TEST_SHARD change semantically; permissions, action refs, secrets, triggers, concurrency and the 20-minute cap are unchanged. Running the real batch runner selection on the merged tree assigned all 2,238 files exactly once (746/745/747). No executable consumer keys on the old macos N/2 names, and no ruleset requires them. Exact-head runs 38222137968 (PR) and 38222141865 (dispatch) completed all three shards in 10:36 to 15:25. Focused ci-workflows tests 257/0, typecheck, structure and privacy 0.

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

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants