Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

ci(core): split the backend tests across three runners

Petr Bauch43a22c00c4fc
diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml
index 541237a08..2584aa1c1 100644
--- a/.github/workflows/pr-ci.yml
+++ b/.github/workflows/pr-ci.yml
@@ -187,17 +187,47 @@ jobs:
- name: E2E surface snapshot is current
run: uv run --project core python scripts/e2e_surface.py --check
- # Store tests boot real Postgres via testcontainers; ubuntu-latest ships
- # Docker so the containers come up without extra setup. The slow
- # integration suite (Postgres + Tuwunel) is excluded from the default run
- # and is not part of PR CI.
- #
- # Spread over one pytest-xdist worker per CPU. The Postgres fixture is
- # session-scoped, and a session is per worker, so each worker boots and
- # owns a container of its own: no test shares a database with another
- # running at the same time.
+ # The tests, apart from the checks above so they can be split across
+ # runners. Store tests boot real Postgres via testcontainers; ubuntu-latest
+ # ships Docker so the containers come up without extra setup. The slow
+ # integration suite (Postgres + Tuwunel) is excluded from the default run
+ # and is not part of PR CI.
+ backend-tests:
+ name: Backend (core) tests (${{ matrix.group }}/3)
+ needs: changes
+ if: ${{ needs.changes.outputs.backend == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ group: [1, 2, 3]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+
+ - name: Set up uv
+ uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
+ with:
+ python-version: '3.12'
+ enable-cache: true
+
+ - name: Sync dependencies
+ run: uv sync --project core
+
+ # Each runner takes a third of the tests, dealt out one at a time
+ # (`least_duration` with no durations file to read). The slow tests sit
+ # together, so equal contiguous slices would leave one runner with most
+ # of the time; dealt out, the three come within a few percent of each
+ # other. Within a runner, one pytest-xdist worker per CPU. The Postgres
+ # fixture is session-scoped, and a session is per worker, so each worker
+ # boots and owns a container of its own: no test shares a database with
+ # another running at the same time.
- name: pytest
- run: uv run --project core pytest -c core/pyproject.toml core/tests/ -n auto
+ run: >-
+ uv run --project core pytest -c core/pyproject.toml core/tests/
+ -n auto
+ --splits 3 --group ${{ matrix.group }}
+ --splitting-algorithm least_duration
console:
name: Switch Console
diff --git a/core/pyproject.toml b/core/pyproject.toml
index 9daa19075..338ebbb68 100644
--- a/core/pyproject.toml
+++ b/core/pyproject.toml
@@ -70,6 +70,7 @@ dev = [
"pytest-asyncio>=0.24",
"testcontainers>=4.14.2",
"pytest-xdist>=3.6",
+ "pytest-split>=0.10",
]
[tool.ruff]
diff --git a/core/uv.lock b/core/uv.lock
index 6087105bf..a63be3079 100644
--- a/core/uv.lock
+++ b/core/uv.lock
@@ -1967,6 +1967,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/e5/35/f8b19922b6a25bc0880171a2f1a003eaeb93657475193ab516fd87cac9da/pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5", size = 15075, upload-time = "2025-11-10T16:07:45.537Z" },
]
+[[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"
@@ -2389,6 +2401,7 @@ dev = [
{ name = "pre-commit" },
{ name = "pytest" },
{ name = "pytest-asyncio" },
+ { name = "pytest-split" },
{ name = "pytest-xdist" },
{ name = "ruff" },
{ name = "testcontainers" },
@@ -2427,6 +2440,7 @@ dev = [
{ name = "pre-commit", specifier = ">=4.5" },
{ name = "pytest", specifier = ">=8" },
{ name = "pytest-asyncio", specifier = ">=0.24" },
+ { name = "pytest-split", specifier = ">=0.10" },
{ name = "pytest-xdist", specifier = ">=3.6" },
{ name = "ruff", specifier = ">=0.15" },
{ name = "testcontainers", specifier = ">=4.14.2" },