Skip to content

The agent that grows with you

ci: run the Python suite and the macOS lane as two slices each

teknium1093f8d448094
diff --git a/.github/workflows/tests-os.yml b/.github/workflows/tests-os.yml
index 9f4ae1cb26a..451003c9ade 100644
--- a/.github/workflows/tests-os.yml
+++ b/.github/workflows/tests-os.yml
@@ -72,9 +72,16 @@ jobs:
fail-fast: false
matrix:
include:
- - name: macOS-only tests
+ # Two slices on the free standard runner (3 cores, 3 workers): one lane ran
+ # ~7.5 min and became the slowest required job once the Linux suite split.
+ - name: macOS-only tests (1/2)
runner: macos-latest
marker: macos
+ slice: 1/2
+ - name: macOS-only tests (2/2)
+ runner: macos-latest
+ marker: macos
+ slice: 2/2
- name: Windows-only tests
runner: windows-latest-32-core
marker: windows
@@ -175,6 +182,7 @@ jobs:
# These files spawn nested PowerShell trees. CPU-count parallelism
# starves cold child startup before the fixture's idle deadline.
HERMES_TEST_WORKERS: ${{ matrix.marker == 'windows' && (runner.arch == 'ARM64' && '16' || '16') || '' }}
+ HERMES_TEST_SLICE: ${{ matrix.slice || '' }}
# Belt-and-suspenders with tests/conftest.py's env blanking: no
# test may reach a real provider API.
OPENROUTER_API_KEY: ''
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 5313e197c8a..98a103c22b5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -27,9 +27,18 @@ concurrency:
jobs:
test:
- name: Run tests
+ # Two 32-core slices instead of one box: on one runner the suite is ~10 min of
+ # nearly fully packed work, and a single bigger runner (96-core) scaled ~1.8x for
+ # 3x the price because files contend for the shared machine. Separate machines
+ # scale linearly. run_tests_parallel.py partitions from the checkout alone, so
+ # both slices agree on the split without a planning job.
+ name: Run tests (${{ matrix.slice }}/2)
runs-on: ubuntu-latest-32-core
timeout-minutes: 30
+ strategy:
+ fail-fast: false
+ matrix:
+ slice: [1, 2]
steps:
- name: Checkout code
uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7.0.1
@@ -91,6 +100,7 @@ jobs:
run: |
scripts/run_tests.sh
env:
+ HERMES_TEST_SLICE: ${{ matrix.slice }}/2
HERMES_TEST_WORKERS: 32
HERMES_TEST_FILE_TIMEOUT: 600
# Ensure tests don't accidentally call real APIs
@@ -105,7 +115,9 @@ jobs:
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: test_durations.json
- key: test-durations-${{ github.run_id }}
+ # Per-slice key: each slice's file keeps the restored entries for the other
+ # slice's files and refreshes its own, so the cache stays complete.
+ key: test-durations-${{ github.run_id }}-${{ matrix.slice }}
e2e:
# The core suites spawn real serve / gateway / tui_gateway / MCP / SQLite
diff --git a/scripts/run_tests_parallel.py b/scripts/run_tests_parallel.py
index 21178fd246e..06dae2a51c0 100644
--- a/scripts/run_tests_parallel.py
+++ b/scripts/run_tests_parallel.py
@@ -886,7 +886,10 @@ def _slice_files(
) -> List[Path]:
"""Return the subset of *files* belonging to slice *slice_index*.
- Uses :func:`_compute_lpt_slices` for LPT distribution.
+ Every slice job computes the partition on its own, so it must come only from
+ the checkout: a duration cache restored separately per job can differ (a main
+ push saves a newer one in between) and silently drop or double-run files.
+ Sorted round-robin balances within seconds of timed LPT at this suite size.
``slice_index`` is 1-indexed (1..slice_count) for ergonomics —
``--slice 1/4`` reads more naturally than ``--slice 0/4``.
@@ -900,7 +903,7 @@ def _slice_files(
)
sys.exit(2)
- bucket_files = _compute_lpt_slices(files, slice_count, durations, repo_root)
+ bucket_files = _compute_lpt_slices(sorted(files), slice_count, {}, repo_root)
target = bucket_files[slice_index - 1]
target_dur = sum(
@@ -1276,8 +1279,7 @@ def main() -> int:
test_counts = _approximately_count_tests(files, repo_root)
approx_total_tests = sum(test_counts.values())
- # Apply slicing if requested — distribute files across CI jobs by
- # estimated duration so no one job gets all the slow files.
+ # Apply slicing if requested (partition from the checkout alone; see _slice_files).
if slice_index is not None:
durations = _load_durations(repo_root)
files = _slice_files(files, slice_index, slice_count, durations, repo_root)
diff --git a/tests/scripts/test_run_tests_parallel.py b/tests/scripts/test_run_tests_parallel.py
index c8aa9530318..b9cc90d662b 100644
--- a/tests/scripts/test_run_tests_parallel.py
+++ b/tests/scripts/test_run_tests_parallel.py
@@ -574,3 +574,19 @@ def test_off_host_note_names_platforms_specs_that_exclude_this_host(tmp_path: Pa
off_host.add("posix")
assert {n.split("platforms(")[1].split(")")[0].strip("'") for n in notes} == off_host, proc.stdout
assert all("they run on the" in n for n in notes), proc.stdout
+
+
+def test_slices_partition_the_suite_exactly_even_with_different_duration_caches(capsys) -> None:
+ """Each CI slice job restores its own duration cache; the slices must still cover every file once."""
+ import importlib.util
+
+ spec = importlib.util.spec_from_file_location(
+ "rtp_slices", Path(__file__).resolve().parents[2] / "scripts" / "run_tests_parallel.py")
+ rtp = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(rtp)
+ root = Path("/repo")
+ files = [root / f"tests/t_{i:03d}.py" for i in range(101)]
+ caches = [{f"tests/t_{i:03d}.py": float(i) for i in range(101)}, {"tests/t_000.py": 500.0}, {}]
+ slices = [rtp._slice_files(list(reversed(files)) if i % 2 else files, i % 3 + 1, 3, caches[i % 3], root)
+ for i in range(3)]
+ assert sorted(f for s in slices for f in s) == sorted(files)