Skip to content

CI: run tests in parallel within each shard (xdist) on the free 4-vCPU runners #2001

Open

Description

@phernandez

Why

Core CI takes 13 to 27 minutes per push. In a recent slow run, "Test Postgres Unit (Python 3.14, shard 1/6)" spent 940 seconds in its test step. The other shards finished in about 9 to 11 minutes, and the Windows SQLite shards took about 11 minutes.

Each shard runs pytest in a single process. pytest-xdist is already in the dev dependencies, but neither test.yml nor the justfile passes -n. GitHub's free runners for public repos (ubuntu-latest and windows-latest) have 4 vCPU and 16 GB, so most of each runner sits idle.

Paid runners were considered and set aside: Depot runners cost $0.024/min at 8 vCPU (vs $0.006 at 2), and core's CI is free on GitHub. Re-splitting shards by duration was also set aside, because the testmon/shard work took a long time before.

Plan

  1. SQLite first. Add -n 4 to one SQLite unit shard in test.yml (through the just test-unit-sqlite recipe) and compare its test-step time with the current run. SQLite tests use per-test database files, so they should already be worker-safe.
  2. Roll out to the SQLite jobs if the speedup holds, including Windows.
  3. Postgres. The Postgres jobs share one service container, so each xdist worker needs its own database (for example, named from PYTEST_XDIST_WORKER). Make the Postgres fixtures worker-aware, then add -n 4 to the Postgres shards.
  4. Check the reporting that CI depends on: junit XML, --durations, and the shard file lists.

Done when

  • SQLite and Postgres shards run with xdist on the free runners.
  • The slowest shard's test step is measurably shorter (baseline: 940s for Postgres Unit 1/6).
  • No new flaky failures from shared state across a week of pushes.

Activity

  1. added
    enhancement
    on Oct 30, 2026
  2. claude commented on Oct 30, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 17s —— View job


    Triage

    • Type: Enhancement (CI performance improvement)
    • Component: Testing / CI infrastructure (not Cloud)
    • Priority: Medium. It cuts CI wall-clock time (13–27 min per push) but nothing is broken.
    • Complexity: Medium
      • The SQLite rollout should be simple, because per-test database files are already worker-safe.
      • The Postgres work is the harder part. Each xdist worker needs its own database on the shared service container, so the Postgres fixtures have to become PYTEST_XDIST_WORKER-aware.
    • Duplicates: A search for existing issues on xdist and parallel CI found none.

    Notes for whoever picks this up

    • Run the SQLite shard through just test-unit-sqlite first, as the plan says, and compare its test-step time with the current run.
    • Check that junit XML output, --durations reporting and the shard file lists still work under -n 4. Also check that per-worker output doesn't break testmon.
    • The repo requires 100% coverage. Confirm that coverage combining works across xdist workers.
    • Changes to .github/workflows/test.yml need a maintainer. Automated agents can't modify workflow files.

    No clarifying questions are needed. The plan and the done-when criteria are clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions