Skip to content

ci: split the Python tests over five shards instead of four - #2547

Merged
vahid-ahmadi merged 1 commit into
mainfrom
ci/test-shards-5
Oct 21, 2026
Merged

vahid-ahmadi merged 1 commit into
mainfrom
ci/test-shards-5

Conversation

@vahid-ahmadi

Copy link
Copy Markdown
Collaborator

Summary

Split the Python test job over five shards instead of four. The timeout stays at 60 minutes.

The shard count is defined in one place: the shard matrix in .github/workflows/test-suite.yaml. --shard takes ${{ matrix.shard }}/${{ strategy.job-total }}, so N follows the matrix. Test / Result needs the whole Python job and reads every outcomes-*.jsonl, so it needs no list of shards. The release workflow (versioning.yaml) calls the same reusable workflow. Comments in pr_code_changes.yaml and the Makefile, and docs/engineering/skills/testing.md, now say five shards and K/5.

Evidence

Checks

  • --shard handles N = 5. On this branch I collected all 7,750 Python tests without --shard, then collected --shard K/5 for K = 1 to 5. Every test is in exactly one shard, and the union equals the full set. Shard sizes: 1,504, 1,590, 1,567, 1,554 and 1,535 (with four shards: 1,949, 1,934, 1,927 and 1,940). A separate SHA-256 assignment matched what pytest selected for every test.
  • policyengine_uk/tests/code_health/test_ci_test_shards.py: 46 passed. No test asserts the shard count.
  • Required checks: the main ruleset requires Test / Result and Lint only (read from rules/branches/main; classic branch protection has no required checks). The check names change from Test / Python K/4 to Test / Python K/5, which are not required, so the ruleset needs no change.
  • No changelog fragment: this changes CI only, and a fragment would trigger a release.

The shards split by test count, not by time. If one slow test module lands in one shard, that shard stays the longest; the CI run on this PR will show the split.

Reproducer: n/a: CI configuration only; model source and dependencies are unchanged
axiom: n/a: CI configuration only

🤖 Generated with Claude Code

Shard 1/4 took 50 to 52 minutes on unrelated pull requests on 20 and 21
October, against a 60-minute timeout, and #1855 hit the timeout twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@juaristi22 juaristi22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at c0c010d49b77ddfb8f403c36a47c5b80afcce71d.

The fifth shard is picked up throughout: strategy.job-total supplies N to the existing hash partition, and Result waits for the whole Python matrix and checks every outcome log against the full collection. PR, merge-queue, main and release callers keep using the reusable workflow. The required contexts remain Test / Result and Lint.

Validation: 20 focused static/metadata assertions passed, and git diff --check passed. Exact-commit CI passed all five Python shards and the aggregate result in both the source-tree and release-wheel runs; lint and YAML passed too. The slowest source shard took 39m05s and the slowest release shard 42m16s, below the unchanged 60-minute timeout. No findings or material evidence gaps. The full model suite was not rerun locally for this CI-only change.

@vahid-ahmadi
vahid-ahmadi added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit ce0ee44 Oct 21, 2026
32 checks passed
@vahid-ahmadi
vahid-ahmadi deleted the ci/test-shards-5 branch October 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants