Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46356 +/- ##
=======================================
Coverage 85.66% 85.67%
=======================================
Files 3111 3111
Lines 214938 214962 +24
Branches 50908 50915 +7
=======================================
+ Hits 184136 184171 +35
+ Misses 27381 27376 -5
+ Partials 3421 3415 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The unsharded unit-test job had grown to ~40 minutes of tests on a 2-core runner (pytest-xdist only gets two workers), so with setup, the scoped coverage gates and uploads it was hitting the 45-minute timeout on ordinary variance even when every test passed. Split the suite by test file across a 3-way matrix with a small pytest plugin (tests/pytest_shard.py): each file hashes to one shard, so module-scoped fixtures and --dist loadfile behave as before, and the shards together run every test once. The SDK tests and the scoped 100% coverage gates run on shard 1 only. Each shard uploads coverage and its own JUnit artifact; unit-tests-required already aggregates the matrix, so branch protection is unchanged. Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ecbcf44 to
cf627d3
Compare
|
Closing this one. Sharding got the unit tests back to about 15 minutes of wall time, but it cost roughly 5 to 13 extra runner-minutes per run (about 41 total across the three shards vs. 28 to 36 for the single job), and we're trying to free up runners, not use more. Most of the extra wasn't setup either... each shard repeats collection and app startup, and the split by file is uneven. I also tried sharing the The single job is still well inside the 45-minute limit, so the timeouts look like slow-runner outliers for now. If they keep happening, skipping this job on PRs that don't touch Python is probably the cheaper win. |
SUMMARY
unit-tests (current)has started hitting its 45-minute timeout with every test passing. On #46262, all 39,979 unit tests passed in 40:12, then the scoped coverage gates ran and the job was cancelled at 45 minutes, during the Codecov upload. #46108 proposed raising the timeout to 60, but the suite keeps growing and the runner gives pytest-xdist only 2 workers, so a bigger timeout just buys time.This splits the suite across a 3-way matrix instead:
tests/pytest_shard.py, a small dependency-free pytest plugin (-p tests.pytest_shard --num-shards N --shard-id K). Each test file hashes (crc32 of its path) to exactly one shard, so module-scoped fixtures and--dist loadfilebehave as in a full run. Every xdist worker computes the same selection, and the shards together run each test once. An out-of-range--shard-idis a usage error.shard: [1, 2, 3]in the matrix withfail-fast: false. The SDK tests and the scoped 100% coverage gates run on shard 1 only. JUnit artifacts are named per shard (junit-results-current-<shard>), which the report workflow'sjunit-results-*pattern already picks up. Each shard uploads its coverage, and Codecov merges uploads for the same commit and flags.unit-tests-requiredalready aggregates the matrix result.Estimated from #46262's JUnit timings (72 serial minutes across 951 files), the three shards get about 22, 20 and 30 serial minutes, so roughly 11, 10 and 15 minutes of tests on two workers. Shard 1 adds about 3.5 minutes of coverage gates, so each job should land around 15-17 minutes instead of 40+. Hashing by file isn't perfectly balanced, but it needs no stored timing data and stays stable as files are added.
Follow-ups worth considering (not in this PR):
appis module-scoped andapp_contextis autouse). Across ~1,000 modules that's roughly 25 of the run's ~80 worker-minutes. A shared app for modules that don't parametrizeappwould cut that a lot, but it needs care around tests that mutate config.sql/andsemantic_layers/tests (~3 minutes) only to measure their own coverage..codecov.ymlstill hasafter_n_builds: 4from 2021, well below the current number of uploads.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (CI only).
TESTING INSTRUCTIONS
unit-tests (current, N)jobs, each well under the timeout, andunit-tests-requiredgreen.pytest tests/unit_tests/pytest_shard_test.py-n 2 --dist loadfile, the three shards ran 40, 18 and 22 of the 80 tests, with no duplicates.ADDITIONAL INFORMATION
An alternative to #46108's timeout bump.
🤖 Generated with Claude Code