Skip to content

Split CLI test shard into three CI partitions (Fixes #3185) - #3197

Merged
acoliver merged 3 commits into
mainfrom
issue3185
Aug 9, 2026
Merged

Split CLI test shard into three CI partitions (Fixes #3185)#3197
acoliver merged 3 commits into
mainfrom
issue3185

Conversation

@acoliver

@acoliver acoliver commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Splits the existing logical CLI test shard into three deterministic physical GitHub Actions matrix legs so CLI-affected pull requests no longer wait on one roughly 12-minute test job.

All 682 currently discovered CLI test files remain structurally discovered before partitioning. Sorted round-robin assignment produces inventories of 228, 227, and 227 files, while unpartitioned local and nightly execution remains unchanged.

Dive Deeper

  • Keeps the logical shard name as cli, preserving affected-shard selection, completeness guards, and the required Test aggregator.
  • Expands cli into physical identities 1of3, 2of3, and 3of3; non-CLI rows carry 1of1.
  • Passes partition identity through LLXPRT_CLI_TEST_PARTITION and selects files only after complete discovery.
  • Rejects malformed, noncanonical, unsafe, out-of-range, and explicitly empty partitions before any test worker starts.
  • Preserves one Bun process per test file, existing concurrency and timeout handling, JUnit generation, and canonical complete local execution.
  • Adds behavioral tests over temporary fixtures, selector output, actual workflow YAML, and the real CLI inventory.
  • Includes partition identity in matrix job, test reporter, and fork artifact names so each JUnit result remains distinct and consumable.

The implementation plan and evidence ledger are in project-plans/issue3185/plan.md. Authoritative candidate-head wall-clock evidence will be appended after at least three successful GitHub Actions runs on this identical implementation.

Reviewer Test Plan

  1. Run the focused behavior suite:

    bun test packages/cli/test/run-bun-tests.test.ts scripts/tests/affected-test-shards.test.ts scripts/tests/affected-test-shards-partition.test.ts scripts/tests/ci-test-shard-partition.test.ts
    
  2. Verify complete and unique test-file ownership:

    bun scripts/check-test-file-coverage.ts
    npm run lint:test-shards
    
  3. Exercise each physical CLI partition:

    LLXPRT_CLI_TEST_PARTITION=1of3 bun scripts/test.ts --shard cli
    LLXPRT_CLI_TEST_PARTITION=2of3 bun scripts/test.ts --shard cli
    LLXPRT_CLI_TEST_PARTITION=3of3 bun scripts/test.ts --shard cli
    
  4. Confirm an unpartitioned CLI run still executes the full inventory:

    bun scripts/test.ts --shard cli
    
  5. Inspect the Actions matrix for three distinct CLI jobs and distinct JUnit reporter names. Confirm the required Test aggregator waits for every selected matrix leg.

Local evidence:

  • Focused behavior suite: 156 passed, 0 failed.
  • Physical inventories: 228/682, 227/682, and 227/682 files.
  • Aggregate partition cases: 8835 passed, 0 failed, 5 pre-existing skipped, 13 todo; identical to the canonical complete CLI run.
  • Test-file coverage guard: zero uncovered and zero doubly executed files.
  • Logical shard guard: all 16 workspaces remain covered by six logical shards.
  • Format, lint, typecheck, build, and the stepfun-37 real-model smoke test passed.

Full-suite local caveat: repeated exact npm run test executions completed all workspaces but returned failure because different packages/agents child processes hit the existing 180-second watchdog under local macOS process contention. Every reported agents file passed promptly when rerun alone, no agents file is changed here, and the CLI suite itself completed 682/682 files with the case totals above. Candidate-head GitHub Actions remains the required merge gate and authoritative performance environment.

Testing Matrix

🍏 🪟 🐧
npm run ⚠️ focused gates pass; full-suite caveat above CI pending
npx - - -
Docker - - -
Podman - - -
Seatbelt - - -

Linked issues / bugs

Fixes #3185

Part of #2702

Summary by CodeRabbit

  • Performance

    • CLI tests now run across three parallel partitions in CI, reducing feedback time.
    • Test files are distributed evenly and deterministically across partitions.
  • Bug Fixes

    • Invalid or empty test partition configurations now fail fast with clear validation.
  • Testing

    • Added comprehensive coverage for partition selection, CI wiring, reporting, artifacts, and test completeness.

@github-actions github-actions Bot added the maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run label Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4215bb77-499b-4d67-b672-0f00df183d4a

📥 Commits

Reviewing files that changed from the base of the PR and between 7e1edcf and b1ac552.

📒 Files selected for processing (2)
  • scripts/tests/affected-test-shards-partition.test.ts
  • scripts/tests/ci-secure-store-workflow.test.ts
📝 Walkthrough

Walkthrough

The PR partitions CLI test files into three deterministic subsets. CI expands CLI shards into three matrix rows and passes each partition to the Bun runner. Reports and artifacts include partition identifiers.

Changes

CLI test partitioning

Layer / File(s) Summary
Runner partition selection
packages/cli/run-bun-tests.ts, packages/cli/test/run-bun-tests.test.ts
The runner validates NofM partition identities, selects files round-robin after complete discovery, and limits workers and progress reporting to selected files. Tests cover validation, balance, disjointness, exhaustiveness, and real CLI inventory partitioning.
Physical matrix expansion
scripts/affected-test-shards.ts, scripts/tests/affected-test-shards-partition.test.ts, scripts/tests/affected-test-shards.test.ts
The selector expands cli into three partition rows and keeps other shards at 1of1. Tests validate matrix rows, metadata, uniqueness, and full-run expectations.
CI partition wiring
.github/workflows/ci.yml, scripts/tests/ci-test-shard-partition.test.ts
The workflow passes partition metadata to the runner and includes it in job, report, and fork artifact names. Tests preserve existing commands, paths, and shard conditions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The implementation addresses partitioning requirements, but candidate-head CI timing evidence and the under-10-minute acceptance criterion cannot be verified here. Provide at least three successful candidate-head GitHub Actions runs and record verdict, partition timing, inventory, and coverage evidence, including the excluded plan.md file.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: splitting the CLI test shard into three CI partitions.
Description check ✅ Passed The description includes all required sections, explains the implementation, and provides reviewer steps, testing results, caveats, and linked issues.
Out of Scope Changes check ✅ Passed The workflow, runner, selector, and test changes directly support deterministic CLI test partitioning and do not show unrelated scope.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue3185

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

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Before this change, the CLI test shard ran as a single CI job, so every CLI test file executed in one workflow run. That serialized the entire CLI suite behind one runner slot and made the shard a wall-clock bottleneck in PR validation. After this PR, the affected-test-shards selector emits three matrix entries for the CLI shard, and the Bun test runner filters its discovered files by LLXPRT_CLI_TEST_PARTITION using deterministic round-robin assignment. Each partition now runs a fixed subset of the CLI test files in parallel, cutting the shard’s critical-path time while preserving full coverage across the three runs.

Release Notes

New Features

  • Split the CLI test shard into three CI partitions.
  • Added LLXPRT_CLI_TEST_PARTITION support for deterministic round-robin test selection in CI.
  • Updated GitHub Actions matrix expansion so the CLI shard fans out into three partitioned jobs.

Tests

  • Added behavioral tests for partition parsing, matrix expansion, workflow wiring, and end-to-end CLI test shard partitioning.
  • Updated affected-test-shards and CLI Bun runner tests to cover partition-aware selection and execution.

Documentation

  • Added the implementation plan for splitting the CLI test shard into three CI partitions, including scope, design, verification gates, and triage criteria.

Changes

Layer File(s) Summary
ci .github/workflows/ci.yml, scripts/affected-test-shards.ts, packages/cli/run-bun-tests.ts Implements GitHub Actions matrix partitioning for the CLI test shard, adding LLXPRT_CLI_TEST_PARTITION support and deterministic round-robin test selection in CI.
tests scripts/tests/affected-test-shards-partition.test.ts, scripts/tests/affected-test-shards.test.ts, scripts/tests/ci-test-shard-partition.test.ts, scripts/tests/ci-secure-store-workflow.test.ts, packages/cli/test/run-bun-tests.test.ts Adds and updates behavioral tests covering partition parsing, matrix expansion, workflow wiring, and end-to-end CLI test shard partitioning.
docs project-plans/issue3185/plan.md Documents the plan for splitting the CLI test shard into three CI partitions, including scope, design, verification gates, and triage criteria.

Magnitude

🎯 1 (S)
1048 additions, 42 deletions, 9 changed files across 1 package, 0 acceptance criteria

Related

Pre-merge Checks

Check Status Note
Title Clear and descriptive; states the change (splitting CLI test shard into three CI partitions) and references the fixed issue number.
Description Contains all required template sections: TLDR, Dive Deeper, Reviewer Test Plan, Testing Matrix, and Linked issues / bugs.
Linked Issues Implementation satisfies #3185 acceptance criteria: introduces deterministic 3-way CLI partitioning via LLXPRT_CLI_TEST_PARTITION, preserves all 682 discovered tests with completeness guards, rejects malformed/unsafe inputs, updates CI matrix and artifact naming, and adds comprehensive behavioral and CI-wiring tests. Authoritative candidate-head wall-clock evidence is acknowledged as pending in the PR body.
Out of Scope No out-of-scope changes identified. Note: CI performance evidence and re-baseline update to the parent issue (#2702) are pending candidate-head runs, as explicitly called out in the PR description.

Walkthrough generated by LLxprt PR Review. Planner issue: #2256

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
scripts/affected-test-shards.ts (1)

862-874: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a prototype-safe lookup for the partition count.

SHARD_PARTITION_COUNTS[shard] resolves inherited Object.prototype keys. A shard named constructor or toString would return a function, and Array.from({ length: fn }) yields zero rows, which drops the shard from the matrix silently. Shard names are internal today, so this is defensive only.

♻️ Proposed prototype-safe lookup
   return selectedShards.flatMap((shard) => {
-    const count = SHARD_PARTITION_COUNTS[shard] ?? 1;
+    const count = Object.hasOwn(SHARD_PARTITION_COUNTS, shard)
+      ? SHARD_PARTITION_COUNTS[shard]
+      : 1;
     return Array.from({ length: count }, (_, i) => ({
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/affected-test-shards.ts` around lines 862 - 874, Update buildMatrix’s
partition-count lookup to accept only own properties of SHARD_PARTITION_COUNTS,
falling back to 1 for inherited or absent shard names. Preserve the existing
matrix row generation and partition labels for valid configured counts.
.github/workflows/ci.yml (1)

1091-1096: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider running the CLI smoke test in only one partition leg.

The smoke step condition stays matrix.shard == 'cli', so the step now runs three times instead of once. The step output is identical in every leg. The same applies to npm run lint:test-shards at Line 1041, which is partition-independent.

Issue #3185 targets the critical path, so redundant fixed cost per leg works against the goal. Gate these steps on a single partition if you want the saving.

♻️ Proposed condition change for the smoke step
-        if: matrix.shard == 'cli'
+        if: matrix.shard == 'cli' && matrix.partition == '1of3'

If you prefer to keep per-leg redundancy as a safety net, no change is needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 1091 - 1096, Restrict the CLI smoke
test step identified by “Smoke test CLI entry” to a single CLI matrix partition
instead of every leg, while preserving the CLI-only requirement; apply the same
single-partition gating to the partition-independent npm run lint:test-shards
step.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 1091-1096: Restrict the CLI smoke test step identified by “Smoke
test CLI entry” to a single CLI matrix partition instead of every leg, while
preserving the CLI-only requirement; apply the same single-partition gating to
the partition-independent npm run lint:test-shards step.

In `@scripts/affected-test-shards.ts`:
- Around line 862-874: Update buildMatrix’s partition-count lookup to accept
only own properties of SHARD_PARTITION_COUNTS, falling back to 1 for inherited
or absent shard names. Preserve the existing matrix row generation and partition
labels for valid configured counts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0341ef4d-c9d0-45be-8f39-8d95631c3d73

📥 Commits

Reviewing files that changed from the base of the PR and between 8eaf02d and 7e1edcf.

⛔ Files ignored due to path filters (1)
  • project-plans/issue3185/plan.md is excluded by !project-plans/**
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • packages/cli/run-bun-tests.ts
  • packages/cli/test/run-bun-tests.test.ts
  • scripts/affected-test-shards.ts
  • scripts/tests/affected-test-shards-partition.test.ts
  • scripts/tests/affected-test-shards.test.ts
  • scripts/tests/ci-test-shard-partition.test.ts

Comment thread scripts/tests/affected-test-shards-partition.test.ts Outdated
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview — automatic reviews suspended

Automatic OCR reviews are suspended for this PR after 2 of 2 automatic reviews.

To get more reviews you can:

  • Check the box below to re-enable automatic reviews (resets the counter), or

  • Comment /review, /ocr, or /open-code-review to request a single review on demand.

  • Re-enable automatic reviews


OpenCodeReview — PR #3197

  • Reviewed head SHA: 102bb714516af1d973a9344a321f150cc30e7fee
  • Merge base: 8eaf02df1c1d7c23438f156dbf303129be0ceef2
  • Range: incremental from 7e1edcfbd6c3c4fe25e1e1c797c6e67af78c8b06
  • Range fallback: none
  • Scope: selected 1 file(s), +3/-3; cumulative 9 file(s), +1046/-42
  • Tokens: 71965 total (67100 input, 4865 output, 25984 cache)
  • OCR version: open-code-review v1.8.4 (e78474478) linux/amd64 built at: 2026-08-01T03:27:37Z https://github.com/alibaba/open-code-review
  • Phase: review
  • Exit code: 0
  • Run: https://github.com/vybestack/llxprt-code/actions/runs/31306562073
  • No findings.
  • Artifacts: ocr-review-output contains raw JSON, stdout, stderr, preview, phase, and exit-code diagnostics.
  • WARNING: Changed-file coverage 0/1 preview files covered is below the 90% threshold.

@acoliver

acoliver commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the OCR matrix-test finding in commit b1ac552. The non-CLI case now asserts that buildMatrix(['core']) returns exactly one row before verifying its 1of1 partition identity, so duplicate-row regressions cannot pass unnoticed. Focused test: 7 passed, 0 failed; ESLint, the ESLint policy guard, and formatting also passed.

@acoliver

acoliver commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Candidate CI evidence — target not met

Authoritative runs: https://github.com/vybestack/llxprt-code/actions/runs/31306562738, attempts 1–3, all successful on implementation SHA 102bb71.

Attempt Workflow created → complete Full workflow Required Test verdict
1 09:42:43Z → 09:54:30Z 707s 644s
2 09:55:50Z → 10:06:38Z 648s 637s
3 10:08:01Z → 10:19:46Z 705s 672s
Mean 686.7s (11m27s) 651.0s (10m51s)

This does not satisfy the required mean below 600 seconds.

The CLI split itself is successful and stable:

Partition Job durations across attempts Mean Run shard tests step
1of3 281s / 295s / 296s 260.7s
2of3 288s / 290s / 281s 254.3s
3of3 261s / 244s / 266s 225.3s

Each attempt executed and passed all 682 files as 228/227/227. Each attempt reported the same aggregate CI case inventory: 8,814 passed, 0 failed, 27 pre-existing platform-conditional skipped, and 13 todo (8,854 total). All three partition-specific JUnit publish steps passed with fail-on-empty enabled and distinct reporter names. Local test-file coverage found zero uncovered and zero doubly executed files; the six logical shard definitions still cover all 16 workspaces.

The critical path moved outside CLI. Attempt 2's scripts job took 551s, including 444s in Run shard tests. Attempt 3's scripts job took 572s, while Javascript lint also completed after the 600-second boundary. After the test-only OCR remediation, final SHA b1ac55290871baf56952a4ed6050571fb3c2eb6b had another fully green run, https://github.com/vybestack/llxprt-code/actions/runs/31308353655: CLI jobs were 256–293s, but scripts took 580s and the required Test verdict completed 689s after workflow creation.

All current PR checks are green and the OCR finding was addressed and resolved. The accepted timing criterion remains incomplete. Partitioning or optimizing the unrelated scripts shard and/or Javascript lint would expand the agreed CLI-only scope, so no such change has been made without user direction.

@acoliver
acoliver merged commit b4c6430 into main Aug 9, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer:e2e:ok Trusted contributor; maintainer-approved E2E run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split the CLI test shard to put code-PR CI verdicts under 10 minutes (part of #2702)

1 participant