Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

patch: add configurable pytest and Playwright CI shards (#2068)

Ali Khokhar4007c87eb137
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e5031ffb..b7a174af 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -1,15 +1,16 @@
-# Branch protection: require every status check this workflow reports, for example:
+# Branch protection: require these stable checks, not individual shard jobs:
# Ban suppressions and legacy annotations
# ruff-format, ruff-check, ty
# Version policy
-# pytest (Linux), pytest (Windows), pytest (macOS)
-# playwright (Linux), playwright (Windows), playwright (macOS)
+# pytest, playwright
# GitHub may prefix with the workflow name (e.g. "CI / ruff-format"); use the names the branch protection UI offers after a run.
name: CI
env:
CI_UV_VERSION: "0.12.13"
+ CI_PYTEST_SHARDS: "2"
+ CI_PLAYWRIGHT_SHARDS: "3"
UV_MALWARE_CHECK: "1"
UV_PREVIEW_FEATURES: "malware-check"
@@ -74,22 +75,38 @@ jobs:
- name: Run
run: ${{ matrix.run }}
- pytest:
- name: pytest (${{ matrix.os }})
+ prepare-shards:
+ name: Prepare test shards
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ outputs:
+ pytest_matrix: ${{ steps.matrix.outputs.pytest_matrix }}
+ playwright_matrix: ${{ steps.matrix.outputs.playwright_matrix }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ ref: ${{ github.event.pull_request.head.sha || github.ref }}
+ repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+
+ - name: Generate test matrices
+ id: matrix
+ run: |
+ python scripts/ci_shards.py \
+ --pytest-shards "$CI_PYTEST_SHARDS" \
+ --playwright-shards "$CI_PLAYWRIGHT_SHARDS" >> "$GITHUB_OUTPUT"
+
+ pytest-shards:
+ name: pytest (${{ matrix.os }}, shard ${{ matrix.shard }}/${{ matrix.shards }})
+ needs: prepare-shards
runs-on: ${{ matrix.runner }}
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: false
- matrix:
- include:
- - os: Linux
- runner: ubuntu-latest
- - os: Windows
- runner: windows-latest
- - os: macOS
- runner: macos-latest
+ matrix: ${{ fromJSON(needs.prepare-shards.outputs.pytest_matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
@@ -105,24 +122,21 @@ jobs:
prepare-node: "true"
- name: Run pytest
- run: uv run --locked pytest -v --tb=short -o thread_dump_timeout=15 --durations=50
+ run: >-
+ uv run --locked pytest -v --tb=short -o thread_dump_timeout=15 --durations=50
+ --splits ${{ matrix.shards }} --group ${{ matrix.shard }}
+ --splitting-algorithm=least_duration
- playwright:
- name: playwright (${{ matrix.os }})
+ playwright-shards:
+ name: playwright (${{ matrix.os }}, shard ${{ matrix.shard }}/${{ matrix.shards }})
+ needs: prepare-shards
runs-on: ${{ matrix.runner }}
timeout-minutes: 15
permissions:
contents: read
strategy:
fail-fast: false
- matrix:
- include:
- - os: Linux
- runner: ubuntu-latest
- - os: Windows
- runner: windows-latest
- - os: macOS
- runner: macos-latest
+ matrix: ${{ fromJSON(needs.prepare-shards.outputs.playwright_matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
@@ -145,12 +159,46 @@ jobs:
-o thread_dump_timeout=10 --durations=20
--tracing=retain-on-failure --screenshot=only-on-failure
--full-page-screenshot --output=test-results
+ --splits ${{ matrix.shards }} --group ${{ matrix.shard }}
+ --splitting-algorithm=least_duration
- name: Upload Playwright failure artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
- name: playwright-results-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
+ name: playwright-results-${{ runner.os }}-${{ runner.arch }}-shard-${{ matrix.shard }}-of-${{ matrix.shards }}-${{ github.run_id }}-${{ github.run_attempt }}
path: test-results/
if-no-files-found: ignore
retention-days: 7
+
+ pytest-summary:
+ name: pytest
+ needs: [prepare-shards, pytest-shards]
+ if: ${{ always() }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ steps:
+ - name: Require successful preparation and every shard
+ env:
+ PREPARATION_RESULT: ${{ needs.prepare-shards.result }}
+ SHARDS_RESULT: ${{ needs.pytest-shards.result }}
+ run: |
+ test "$PREPARATION_RESULT" = success && test "$SHARDS_RESULT" = success
+
+ playwright-summary:
+ name: playwright
+ needs: [prepare-shards, playwright-shards]
+ if: ${{ always() }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ steps:
+ - name: Require successful preparation and every shard
+ env:
+ PREPARATION_RESULT: ${{ needs.prepare-shards.result }}
+ SHARDS_RESULT: ${{ needs.playwright-shards.result }}
+ run: |
+ test "$PREPARATION_RESULT" = success && test "$SHARDS_RESULT" = success
diff --git a/e2e/conftest.py b/e2e/conftest.py
index 2d633428..0ba57745 100644
--- a/e2e/conftest.py
+++ b/e2e/conftest.py
@@ -10,7 +10,7 @@ from pathlib import Path
import pytest
import uvicorn
-from playwright.sync_api import Page
+from playwright.sync_api import Page, expect
from e2e.artifacts import failure_artifacts_recorder as failure_artifacts_recorder
from e2e.code_support import CodeControl
@@ -51,6 +51,12 @@ from free_claude_code.runtime.provider_manager import ProviderRuntimeManager
from tests.web_tools_support import StubWebToolsClient
[email protected](scope="session", autouse=True)
+def browser_assertion_timeout() -> None:
+ # Windows CI can finish UI hydration just beyond Playwright's five-second default.
+ expect.set_options(timeout=10_000)
+
+
class _ModelListingProvider(BaseProvider):
def __init__(
self,
diff --git a/e2e/test_api_key_lists.py b/e2e/test_api_key_lists.py
index 9b445ba7..8ccf1bd6 100644
--- a/e2e/test_api_key_lists.py
+++ b/e2e/test_api_key_lists.py
@@ -171,7 +171,10 @@ def test_warning_save_refreshes_masks_and_is_clean_then_rechecks_retained_rows(
expect(page.locator("#saveProvider")).to_be_disabled()
expect(dialog.locator(".api-key-row input").nth(1)).to_have_value("")
dialog.locator("#field-NVIDIA_NIM_PROXY").fill("http://localhost:8888")
- dialog.get_by_role("button", name="Save", exact=True).click()
+ with page.expect_response("**/admin/api/config/apply") as saved:
+ dialog.get_by_role("button", name="Save", exact=True).click()
+ assert saved.value.ok
+ expect(dialog.locator("#providerMessage")).to_contain_text("Saved")
expect(page.locator("#saveProvider")).to_be_disabled()
assert checked == [
["warning-first", "warning-second"],
diff --git a/pyproject.toml b/pyproject.toml
index 11ce8378..66c89177 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -101,6 +101,7 @@ dev = [
"pytest-xdist>=3.8.0",
"pytest-playwright>=0.9.0",
"pyyaml>=6.0.3",
+ "pytest-split>=0.11.0",
]
[tool.ruff]
diff --git a/scripts/ci_shards.py b/scripts/ci_shards.py
new file mode 100644
index 00000000..24d42110
--- /dev/null
+++ b/scripts/ci_shards.py
@@ -0,0 +1,49 @@
+"""Generate GitHub Actions test matrices from the workflow's shard counts.
+
+To replay a shard locally, set PYTEST_ADDOPTS to
+"--splits 5 --group 2 --splitting-algorithm=least_duration" and run the
+pytest or playwright check through scripts/ci.ps1 or scripts/ci.sh.
+"""
+
+import argparse
+import json
+
+RUNNERS = {
+ "Linux": "ubuntu-latest",
+ "Windows": "windows-latest",
+ "macOS": "macos-latest",
+}
+MAX_SHARDS = 256 // len(RUNNERS)
+
+
+def shard_count(value: str) -> int:
+ count = int(value)
+ if not 1 <= count <= MAX_SHARDS:
+ raise argparse.ArgumentTypeError(f"must be between 1 and {MAX_SHARDS}")
+ return count
+
+
+def matrix(count: int) -> dict[str, list[dict[str, str | int]]]:
+ return {
+ "include": [
+ {"os": os_name, "runner": runner, "shard": shard, "shards": count}
+ for os_name, runner in RUNNERS.items()
+ for shard in range(1, count + 1)
+ ]
+ }
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--pytest-shards", required=True, type=shard_count)
+ parser.add_argument("--playwright-shards", required=True, type=shard_count)
+ args = parser.parse_args()
+ for suite, count in (
+ ("pytest", args.pytest_shards),
+ ("playwright", args.playwright_shards),
+ ):
+ print(f"{suite}_matrix={json.dumps(matrix(count), separators=(',', ':'))}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/contracts/test_uv_policy.py b/tests/contracts/test_uv_policy.py
index 5960c24c..37bedbc8 100644
--- a/tests/contracts/test_uv_policy.py
+++ b/tests/contracts/test_uv_policy.py
@@ -9,6 +9,8 @@ from pathlib import Path
import pytest
import yaml
+from scripts.ci_shards import matrix
+
UV_MINIMUM = "0.12.13"
CI_SETUP = Path(".github/actions/ci-environment/action.yml")
UV_WORKFLOWS = (
@@ -92,14 +94,14 @@ def test_installer_python_requests_match_package_requirement() -> None:
assert lock["requires-python"] == requirement
-def _assert_required_test_matrix(workflow: dict, suite: str) -> None:
- job = workflow["jobs"][suite]
- assert job["name"] == f"{suite} (${{{{ matrix.os }}}})"
+def _assert_required_test_matrix(workflow: dict, suite: str, entries: list) -> None:
+ job = workflow["jobs"][f"{suite}-shards"]
assert job["runs-on"] == "${{ matrix.runner }}"
- matrix = job["strategy"]["matrix"]
- assert not matrix.get("exclude")
- entries = matrix["include"]
- assert len(entries) == len(REQUIRED_TEST_RUNNERS)
+ assert job["strategy"]["matrix"] == (
+ "${{ fromJSON(needs.prepare-shards.outputs." + suite + "_matrix) }}"
+ )
+ count = int(workflow["env"][f"CI_{suite.upper()}_SHARDS"])
+ assert len(entries) == len(REQUIRED_TEST_RUNNERS) * count
assert {(entry["os"], entry["runner"]) for entry in entries} == set(
REQUIRED_TEST_RUNNERS.items()
)
@@ -108,7 +110,8 @@ def _assert_required_test_matrix(workflow: dict, suite: str) -> None:
@pytest.mark.parametrize("suite", ("pytest", "playwright"))
def test_required_test_matrix_covers_supported_platforms(suite: str) -> None:
workflow = yaml.safe_load(UV_WORKFLOWS[0].read_text(encoding="utf-8"))
- _assert_required_test_matrix(workflow, suite)
+ count = int(workflow["env"][f"CI_{suite.upper()}_SHARDS"])
+ _assert_required_test_matrix(workflow, suite, matrix(count)["include"])
@pytest.mark.parametrize("suite", ("pytest", "playwright"))
@@ -117,10 +120,11 @@ def test_required_test_matrix_rejects_missing_platform(
suite: str, os_name: str
) -> None:
workflow = yaml.safe_load(UV_WORKFLOWS[0].read_text(encoding="utf-8"))
- entries = workflow["jobs"][suite]["strategy"]["matrix"]["include"]
+ count = int(workflow["env"][f"CI_{suite.upper()}_SHARDS"])
+ entries = matrix(count)["include"]
entries[:] = [entry for entry in entries if entry["os"] != os_name]
with pytest.raises(AssertionError):
- _assert_required_test_matrix(workflow, suite)
+ _assert_required_test_matrix(workflow, suite, entries)
def test_supported_uv_minimum_is_consistent() -> None:
@@ -143,7 +147,7 @@ def test_every_uv_workflow_inherits_malware_check() -> None:
for workflow_path in UV_WORKFLOWS:
workflow = workflow_path.read_text(encoding="utf-8")
assert workflow.count(malware_policy) == 1
- assert workflow.index(malware_policy) < workflow.index("jobs:\n")
+ assert workflow.index(malware_policy) < workflow.index("\njobs:\n")
def test_only_trusted_main_workflow_writes_caches() -> None:
diff --git a/tests/scripts/test_ci_shard_partition.py b/tests/scripts/test_ci_shard_partition.py
new file mode 100644
index 00000000..ef77574e
--- /dev/null
+++ b/tests/scripts/test_ci_shard_partition.py
@@ -0,0 +1,117 @@
+"""Exercise the CI split options against pytest's actual collected items."""
+
+import json
+import os
+import subprocess
+import sys
+import xml.etree.ElementTree as ET
+
+import pytest
+
+
+def suite(tmp_path):
+ (tmp_path / "pytest.ini").write_text("[pytest]\n", encoding="utf-8")
+ (tmp_path / "conftest.py").write_text(
+ "import json\n"
+ "from pathlib import Path\n"
+ "def pytest_collection_finish(session):\n"
+ " if session.config.option.collectonly:\n"
+ " Path('items.json').write_text(json.dumps([i.nodeid for i in session.items]))\n",
+ encoding="utf-8",
+ )
+ parameterized = (
+ "import pytest\n"
+ "@pytest.mark.parametrize('value', range(7))\n"
+ "def test_same_name(value):\n"
+ " assert value >= 0\n"
+ )
+ (tmp_path / "test_a.py").write_text(
+ parameterized
+ + "@pytest.mark.skip(reason='fixture skip')\ndef test_skipped(): pass\n",
+ encoding="utf-8",
+ )
+ (tmp_path / "test_b.py").write_text(
+ parameterized + "def test_plain(): pass\n", encoding="utf-8"
+ )
+ return tmp_path
+
+
+def run_pytest(suite, *args):
+ return subprocess.run(
+ [
+ sys.executable,
+ "-m",
+ "pytest",
+ "-p",
+ "pytest_split.plugin",
+ "-p",
+ "xdist.plugin",
+ *args,
+ ],
+ cwd=suite,
+ env={**os.environ, "PYTEST_ADDOPTS": "", "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1"},
+ capture_output=True,
+ text=True,
+ check=False,
+ timeout=60,
+ )
+
+
+def collect(suite, *args):
+ result = run_pytest(suite, "--collect-only", "-q", *args)
+ assert result.returncode == 0, result.stdout + result.stderr
+ return json.loads((suite / "items.json").read_text())
+
+
+def split_args(count, group):
+ return [
+ "--splits",
+ str(count),
+ "--group",
+ str(group),
+ "--splitting-algorithm=least_duration",
+ ]
+
+
[email protected]("count", [2, 3, 5])
+def test_shards_partition_all_items_once_and_run_with_workstealing(suite, count):
+ baseline = collect(suite)
+ assert len(baseline) == 16
+ assert collect(suite, *split_args(1, 1)) == baseline
+ groups = [
+ collect(suite, *split_args(count, group)) for group in range(1, count + 1)
+ ]
+ selected = [nodeid for group in groups for nodeid in group]
+ assert all(groups)
+ assert len(selected) == len(set(selected))
+ assert set(selected) == set(baseline)
+ assert "test_a.py::test_same_name[0]" in selected
+ assert "test_b.py::test_same_name[0]" in selected
+
+ # Execute the shard containing the skip, with real xdist workers.
+ skip_group = next(
+ i for i, group in enumerate(groups, 1) if "test_a.py::test_skipped" in group
+ )
+ result = run_pytest(
+ suite,
+ *split_args(count, skip_group),
+ "-n",
+ "2",
+ "--dist=worksteal",
+ "--junitxml=results.xml",
+ )
+ assert result.returncode == 0, result.stdout + result.stderr
+ cases = ET.parse(suite / "results.xml").findall(".//testcase")
+ executed = {
+ case.attrib["classname"] + ".py::" + case.attrib["name"] for case in cases
+ }
+ assert executed == set(groups[skip_group - 1])
+ assert len(cases) == len(executed)
+ assert len([case for case in cases if case.find("skipped") is not None]) == 1
+
+
[email protected]("count,group", [(0, 1), (5, 0), (5, 6), (17, 17)])
+def test_invalid_or_empty_shards_fail(suite, count, group):
+ result = run_pytest(suite, *split_args(count, group))
+ assert result.returncode == (5 if count == 17 else 4), result.stdout + result.stderr
diff --git a/tests/scripts/test_ci_shard_workflow.py b/tests/scripts/test_ci_shard_workflow.py
new file mode 100644
index 00000000..42ee2d1f
--- /dev/null
+++ b/tests/scripts/test_ci_shard_workflow.py
@@ -0,0 +1,112 @@
+"""Test sharding and required summaries are wired into the CI workflow."""
+
+import os
+import shutil
+import subprocess
+from pathlib import Path
+
+import pytest
+import yaml
+
+from scripts.ci_shards import shard_count
+
+ROOT = Path(__file__).resolve().parents[2]
+
+
+def workflow():
+ return yaml.safe_load((ROOT / ".github/workflows/tests.yml").read_text())
+
+
[email protected]("suite", ["pytest", "playwright"])
+def test_shard_jobs_use_generated_matrices_and_existing_parallelism(suite):
+ config = workflow()
+ shard_count(config["env"][f"CI_{suite.upper()}_SHARDS"])
+ prepare = config["jobs"]["prepare-shards"]
+ assert f"{suite}_matrix" in prepare["outputs"]
+ generate = prepare["steps"][-1]
+ assert f'--{suite}-shards "$CI_{suite.upper()}_SHARDS"' in generate["run"]
+ job = config["jobs"][f"{suite}-shards"]
+ assert job["needs"] == "prepare-shards"
+ assert job["strategy"]["matrix"] == (
+ "${{ fromJSON(needs.prepare-shards.outputs." + suite + "_matrix) }}"
+ )
+ assert job["strategy"]["fail-fast"] is False
+ assert "max-parallel" not in job["strategy"]
+ assert "continue-on-error" not in job
+ assert job["runs-on"] == "${{ matrix.runner }}"
+ assert "${{ matrix.shard }}/${{ matrix.shards }}" in job["name"]
+ command = next(
+ step["run"]
+ for step in job["steps"]
+ if step.get("run", "").startswith("uv run --locked pytest ")
+ )
+ assert "--splits ${{ matrix.shards }}" in command
+ assert "--group ${{ matrix.shard }}" in command
+ assert "--splitting-algorithm=least_duration" in command
+ assert "-n " not in command
+ assert "--dist=" not in command
+ assert ("pytest e2e " in command) == (suite == "playwright")
+ assert "||" not in command
+
+
+def test_browser_artifacts_identify_each_shard_and_run_attempt():
+ job = workflow()["jobs"]["playwright-shards"]
+ upload = next(
+ step
+ for step in job["steps"]
+ if "actions/upload-artifact@" in step.get("uses", "")
+ )
+ name = upload["with"]["name"]
+ for field in (
+ "runner.os",
+ "runner.arch",
+ "matrix.shard",
+ "matrix.shards",
+ "github.run_id",
+ "github.run_attempt",
+ ):
+ assert "${{ " + field + " }}" in name
+ assert upload["if"] == "failure()"
+ assert upload["with"]["path"] == "test-results/"
+ assert upload["with"]["retention-days"] == 7
+
+
[email protected]("suite", ["pytest", "playwright"])
[email protected]("preparation", ["success", "failure", "cancelled", "skipped"])
[email protected]("shards", ["success", "failure", "cancelled", "skipped"])
+def test_summary_only_passes_when_preparation_and_all_shards_succeed(
+ suite, preparation, shards
+):
+ job = workflow()["jobs"][f"{suite}-summary"]
+ assert job["name"] == suite
+ assert set(job["needs"]) == {"prepare-shards", f"{suite}-shards"}
+ assert job["if"] == "${{ always() }}"
+ assert "continue-on-error" not in job
+ assert len(job["steps"]) == 1
+ step = job["steps"][0]
+ assert step["env"] == {
+ "PREPARATION_RESULT": "${{ needs.prepare-shards.result }}",
+ "SHARDS_RESULT": "${{ needs." + suite + "-shards.result }}",
+ }
+ bash = shutil.which("bash")
+ if os.name == "nt":
+ # WSL's bash.exe does not inherit arbitrary Windows environment variables.
+ git = shutil.which("git")
+ bash = (
+ shutil.which("bash", path=str(Path(git).parents[1] / "bin"))
+ if git
+ else None
+ )
+ if bash is None:
+ pytest.skip("bash is required to execute the GitHub summary check")
+ result = subprocess.run(
+ [bash, "--noprofile", "--norc", "-e", "-o", "pipefail", "-c", step["run"]],
+ env={**os.environ, "PREPARATION_RESULT": preparation, "SHARDS_RESULT": shards},
+ capture_output=True,
+ text=True,
+ check=False,
+ timeout=30,
+ )
+ assert (result.returncode == 0) == (preparation == shards == "success"), (
+ result.stderr
+ )
diff --git a/tests/scripts/test_ci_shards.py b/tests/scripts/test_ci_shards.py
new file mode 100644
index 00000000..0bf6cff4
--- /dev/null
+++ b/tests/scripts/test_ci_shards.py
@@ -0,0 +1,62 @@
+"""CI matrix generation rejects invalid counts and covers every OS shard."""
+
+import json
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+RUNNERS = {
+ "Linux": "ubuntu-latest",
+ "Windows": "windows-latest",
+ "macOS": "macos-latest",
+}
+
+
+def run_matrix(pytest_count, playwright_count):
+ return subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / "scripts/ci_shards.py"),
+ "--pytest-shards",
+ str(pytest_count),
+ "--playwright-shards",
+ str(playwright_count),
+ ],
+ capture_output=True,
+ text=True,
+ timeout=30,
+ check=False,
+ )
+
+
[email protected]("counts", [(1, 1), (2, 3), (2, 5), (5, 2), (85, 1)])
+def test_matrix_outputs_cover_each_os_and_shard(counts):
+ result = run_matrix(*counts)
+ assert result.returncode == 0, result.stderr
+ outputs = {
+ name: json.loads(value)
+ for name, value in (line.split("=", 1) for line in result.stdout.splitlines())
+ }
+ assert set(outputs) == {"pytest_matrix", "playwright_matrix"}
+ for name, count in zip(("pytest_matrix", "playwright_matrix"), counts, strict=True):
+ entries = outputs[name]["include"]
+ assert len(entries) == 3 * count
+ assert {(row["os"], row["runner"]) for row in entries} == set(RUNNERS.items())
+ for os_name in RUNNERS:
+ rows = [row for row in entries if row["os"] == os_name]
+ assert [row["shard"] for row in rows] == list(range(1, count + 1))
+ assert {row["shards"] for row in rows} == {count}
+
+
[email protected]("invalid", ["0", "-1", "1.5", "five", "86"])
[email protected]("suite", [0, 1])
+def test_invalid_count_fails_before_emitting_either_matrix(invalid, suite):
+ counts = ["5", "5"]
+ counts[suite] = invalid
+ result = run_matrix(*counts)
+ assert result.returncode == 2
+ assert "shards" in result.stderr
+ assert result.stdout == ""
diff --git a/uv.lock b/uv.lock
index ba5b88f5..3f93167e 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1,5 +1,5 @@
version = 1
-revision = 3
+revision = 5
requires-python = "==3.14.7"
[[package]]
@@ -645,6 +645,7 @@ dev = [
{ name = "pytest-asyncio" },
{ name = "pytest-cov" },
{ name = "pytest-playwright" },
+ { name = "pytest-split" },
{ name = "pytest-xdist" },
{ name = "pyyaml" },
{ name = "ruff" },
@@ -696,6 +697,7 @@ dev = [
{ name = "pytest-asyncio", specifier = ">=1.4.0" },
{ name = "pytest-cov", specifier = ">=7.1.0" },
{ name = "pytest-playwright", specifier = ">=0.9.0" },
+ { name = "pytest-split", specifier = ">=0.11.0" },
{ name = "pytest-xdist", specifier = ">=3.8.0" },
{ name = "pyyaml", specifier = ">=6.0.3" },
{ name = "ruff", specifier = ">=0.16.10" },
@@ -1978,6 +1980,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/ab/70/72ff5c3833f0faa9b5fb23f24c0a606f070ad33bb61b802ba38dfe125e7d/pytest_playwright-0.9.0-py3-none-any.whl", hash = "sha256:9d9dc74e335c647944cecfffa706cc9e6e4bf4c25e84592c128b584d494d4471", size = 17915, upload-time = "2026-08-10T10:20:18.253Z" },
]
+[[package]]
+name = "pytest-split"
+version = "0.11.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "pytest" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/2f/16/8af4c5f2ceb3640bb1f78dfdf5c184556b10dfe9369feaaad7ff1c13f329/pytest_split-0.11.0.tar.gz", hash = "sha256:8ebdb29cc72cc962e8eb1ec07db1eeb98ab25e215ed8e3216f6b9fc7ce0ec2b5", size = 13421, upload-time = "2026-02-03T09:14:31.469Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/ae/a1/d4423657caaa8be9b31e491592b49cebdcfd434d3e74512ce71f6ec39905/pytest_split-0.11.0-py3-none-any.whl", hash = "sha256:899d7c0f5730da91e2daf283860eb73b503259cb416851a65599368849c7f382", size = 11911, upload-time = "2026-02-03T09:14:33.708Z" },
+]
+
[[package]]
name = "pytest-xdist"
version = "3.8.0"