ci: shard the semantic and Linux jobs behind their required gate names (CI-SHARD-SEMANTIC-LINUX) #3354

Open
MoonEyes wants to merge 3 commits from upstream-pr/3354 into main
MoonEyes commented 2026-12-03 15:53:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T15:53:17Z.


Claimed in the coordination issue as: CI-SHARD-SEMANTIC-LINUX (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7383898498)

Depends on: #3351 (stacked: the base is its branch, retarget to main once it lands)

What and why

After #3351 the Windows check job runs in 120 to 251 s. The critical path is now semantic-tests (254 to 416 s of translator tests) and linux-python-and-viewer (stdlib loop 223 to 365 s, pytest 56 to 92 s), measured on 7 recent runs.

  • scripts/run_semantic_tests.py: new --shard K/N. Units are top-level modules or packages (a package is never split), assigned greedily by size, largest first; with -j 1 and N>1 it refuses (error 2). On tests/semantic: 4 shards of 139 to 141 files, about 2.14 MB each.
  • .github/workflows/ci.yml: semantic-tests and linux-python-and-viewer become gate jobs (same pattern as check in #3351: needs, if: !cancelled() && docs-only != 'true', fail unless every shard is success). The real work moves to semantic-shards (4) and linux-shards (3). Each Linux shard runs one third of the pytest files and one third of the stdlib loop (--shard); the viewer tests run on shard 0 only.
  • The Linux stdlib loop is only split, not dropped: Linux has numpy, spirv-tools and llvm and runs POSIX tests skipped on Windows, so identical coverage with the Windows loop cannot be shown.
  • tests/test_ci_registration.py: new ShardedJobsTest (matrix size equals the N of K/N, fail-fast: false, each gate waits for its shards and refuses anything but success); the loop test drops every *_SHARD variable (same leak as the one fixed in #3351).

Expected gain, estimated and not yet measured on CI: semantic-tests about 300-415 s to about 100-130 s; linux-python-and-viewer about 295-470 s to about 150-200 s.

Tested

  • Red then green: with the old run_semantic_tests.py the new ShardTest fails (3 failures, 2 errors); with the old ci.yml 10 assertions fail; all pass with this change.
  • test_ci_registration (23), test_run_semantic_tests (40), test_docs_* (57), check_no_game_data.py: pass. Sharding coverage run on the real tree: 560 modules, union of the 4 shards equals the whole, no duplicate; 41 pytest files split 14/14/13.
  • A separate read-only reviewer agent audited the diff and found no blocking issue.
  • Not verified here: gate behaviour in real docs-only and merge_group runs (read from the YAML only), per-shard wall time (balanced by size, not by duration), and the ruleset's handling of the new matrix job names.
  • Risks: 7 jobs instead of 2, so more runner minutes (one tool install per shard).

GPUs tested: n/a

AI-assisted: yes (Claude Code, reviewed by a separate read-only reviewer agent)

Checklist

  • Based on current main through #3351 and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md: n/a

Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5629959230 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3354). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T15:53:17Z. --- Claimed in the coordination issue as: CI-SHARD-SEMANTIC-LINUX (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7383898498) Depends on: #3351 (stacked: the base is its branch, retarget to `main` once it lands) ### What and why After #3351 the Windows `check` job runs in 120 to 251 s. The critical path is now `semantic-tests` (254 to 416 s of translator tests) and `linux-python-and-viewer` (stdlib loop 223 to 365 s, pytest 56 to 92 s), measured on 7 recent runs. - `scripts/run_semantic_tests.py`: new `--shard K/N`. Units are top-level modules or packages (a package is never split), assigned greedily by size, largest first; with `-j 1` and N>1 it refuses (error 2). On `tests/semantic`: 4 shards of 139 to 141 files, about 2.14 MB each. - `.github/workflows/ci.yml`: `semantic-tests` and `linux-python-and-viewer` become gate jobs (same pattern as `check` in #3351: `needs`, `if: !cancelled() && docs-only != 'true'`, fail unless every shard is `success`). The real work moves to `semantic-shards` (4) and `linux-shards` (3). Each Linux shard runs one third of the pytest files and one third of the stdlib loop (`--shard`); the viewer tests run on shard 0 only. - The Linux stdlib loop is only split, not dropped: Linux has numpy, spirv-tools and llvm and runs POSIX tests skipped on Windows, so identical coverage with the Windows loop cannot be shown. - `tests/test_ci_registration.py`: new `ShardedJobsTest` (matrix size equals the N of K/N, `fail-fast: false`, each gate waits for its shards and refuses anything but `success`); the loop test drops every `*_SHARD` variable (same leak as the one fixed in #3351). Expected gain, estimated and not yet measured on CI: `semantic-tests` about 300-415 s to about 100-130 s; `linux-python-and-viewer` about 295-470 s to about 150-200 s. ### Tested - Red then green: with the old `run_semantic_tests.py` the new `ShardTest` fails (3 failures, 2 errors); with the old `ci.yml` 10 assertions fail; all pass with this change. - `test_ci_registration` (23), `test_run_semantic_tests` (40), `test_docs_*` (57), `check_no_game_data.py`: pass. Sharding coverage run on the real tree: 560 modules, union of the 4 shards equals the whole, no duplicate; 41 pytest files split 14/14/13. - A separate read-only reviewer agent audited the diff and found no blocking issue. - Not verified here: gate behaviour in real docs-only and merge_group runs (read from the YAML only), per-shard wall time (balanced by size, not by duration), and the ruleset's handling of the new matrix job names. - Risks: 7 jobs instead of 2, so more runner minutes (one tool install per shard). GPUs tested: n/a AI-assisted: yes (Claude Code, reviewed by a separate read-only reviewer agent) ### Checklist - [x] Based on current `main` through #3351 and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [ ] A new translator rule is in the contract table of `docs/design.md`: n/a --- _Generated by [Claude Code](https://claude.ai/code)_
merzleckeier commented 2026-12-03 17:09:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T17:09:27Z.


Reviewed 667a0a0 merged with main at fba6f09. With SPIR-V Tools required, the four semantic shards ran 6,796 tests across 561 files, matching the unsharded run. All five runs passed. I also ran the exact old and new Linux selection steps with a capture shim. The shards retained all 41 pytest selections (14/14/13) and all 670 standalone files (224/223/223), with no duplicates. The gate scripts accepted success and rejected failure, cancelled, and skipped.

One small coverage gap in tests/test_ci_registration.py:397: shard_problems accepts a single matching LINUX_SHARD assignment anywhere in the job. Renaming just the pytest step’s env key leaves the check green, and each pytest shard then falls back to 0/1 and runs the full list. Checking the assignment per step would catch this regression. The current workflow sets both correctly.

The local CI-registration and runner suites passed. I did not run a hosted merge-group or docs-only event. Review assisted by OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7386053328 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3354#issuecomment-7386053328). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T17:09:27Z. --- Reviewed `667a0a0` merged with `main` at `fba6f09`. With SPIR-V Tools required, the four semantic shards ran 6,796 tests across 561 files, matching the unsharded run. All five runs passed. I also ran the exact old and new Linux selection steps with a capture shim. The shards retained all 41 pytest selections (14/14/13) and all 670 standalone files (224/223/223), with no duplicates. The gate scripts accepted `success` and rejected `failure`, `cancelled`, and `skipped`. One small coverage gap in `tests/test_ci_registration.py:397`: `shard_problems` accepts a single matching `LINUX_SHARD` assignment anywhere in the job. Renaming just the pytest step’s env key leaves the check green, and each pytest shard then falls back to `0/1` and runs the full list. Checking the assignment per step would catch this regression. The current workflow sets both correctly. The local CI-registration and runner suites passed. I did not run a hosted merge-group or docs-only event. Review assisted by OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3354:upstream-pr/3354'
git switch 'upstream-pr/3354'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3354'
git switch 'upstream-pr/3354'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3354'
git switch 'upstream-pr/3354'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3354'
git switch 'main'
git merge --squash 'upstream-pr/3354'
git switch 'main'
git merge --ff-only 'upstream-pr/3354'
git switch 'main'
git merge 'upstream-pr/3354'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3354
No description provided.