From 659d75def6775af3769d0fdd3cecb34f6e63c1f0 Mon Sep 17 00:00:00 2001 From: Duncan McKinnon Date: Fri, 11 Sep 2026 10:09:00 -0700 Subject: [PATCH 1/2] Speed up CI, especially the Windows matrix Windows CI runs the suite in ~265-300s vs ~65s on Ubuntu (~4x), largely concentrated in file-concurrency tests hitting the Windows fsops retry-on-PermissionError path, plus a long tail of thousands of tests each somewhat slower (atomic writes, msvcrt locks, real subprocess spawns in test_e2e_*). Under load this recently tipped a fixed 30s subprocess timeout in test_store_concurrency.py into a flaky failure. - pytest-xdist + `-n auto`: distributes tests across the runner's cores. Locally, full suite: ~25s serial -> ~7-9s parallel, no cross-test contamination (2720 passed either way). - Skip coverage instrumentation on Windows: only ubuntu/3.12's coverage is uploaded, so the other five matrix legs -- ubuntu included -- were paying for it with nothing to show. `-o addopts=` clears pyproject's default `--cov` flags for the Windows invocation. - Cache pip downloads via actions/setup-python's `cache: pip`. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/test.yml | 16 ++++++++++++++-- pyproject.toml | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ba6b86..ee1583d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,12 +53,24 @@ jobs: with: python-version: ${{ matrix.python-version }} allow-prereleases: true + cache: pip + cache-dependency-path: pyproject.toml - name: Install dependencies run: pip install -e ".[dev,ui,logfire]" - - name: Run tests with coverage - run: pytest tests/ -v --cov-report=xml + - name: Run tests + shell: bash + run: | + if [ "${{ runner.os }}" = "Windows" ]; then + # Coverage instrumentation adds meaningful overhead on top of + # Windows's already-slower file I/O and process spawn, and only + # the ubuntu/3.12 run's coverage is uploaded below. `-o addopts=` + # clears pyproject's default `--cov` flags for this invocation. + pytest tests/ -n auto -o addopts="" -v + else + pytest tests/ -n auto -v --cov-report=xml + fi - name: Upload coverage reports to Codecov if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' diff --git a/pyproject.toml b/pyproject.toml index 81052a3..082e819 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,6 +99,7 @@ fallback_version = "0.1.0.dev0" dev = [ "pytest>=8.0", "pytest-cov>=5.0", + "pytest-xdist>=3.5", "pre-commit>=3.7", "ruff>=0.7", "build>=1.2", From 2e6871c596e36d271769140e820a91dc5f0a4fb5 Mon Sep 17 00:00:00 2001 From: Duncan McKinnon Date: Fri, 11 Sep 2026 10:24:46 -0700 Subject: [PATCH 2/2] Isolate the subprocess-heavy concurrency test from the xdist pool pushed run: windows-latest/3.13 regressed under -n auto -- slower overall (347s vs the ~298s pre-xdist baseline) and still hit the pre-existing "writer timed out" flake, this time in a different test in the same file. test_store_concurrency.py spawns 8 real Python subprocesses itself and asserts they finish within a fixed deadline. Under -n auto those 8 processes now also compete with three other xdist worker processes for the runner's CPU -- more contention than serial execution had, not less. Run that file outside the parallel pool so it gets the runner to itself; everything else still parallelizes. Also widen _WRITER_TIMEOUT 30 -> 90 for margin: this test's assumption of near-dedicated CPU to start 8 interpreters and contend for one file lock doesn't hold reliably on shared Windows CI runners even in isolation. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/test.yml | 9 ++++++++- tests/test_store_concurrency.py | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee1583d..53e3be5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,14 @@ jobs: # Windows's already-slower file I/O and process spawn, and only # the ubuntu/3.12 run's coverage is uploaded below. `-o addopts=` # clears pyproject's default `--cov` flags for this invocation. - pytest tests/ -n auto -o addopts="" -v + # + # test_store_concurrency.py spawns 8 real subprocesses of its own + # and asserts they finish within a fixed deadline; run it outside + # the -n auto pool so it isn't also competing with three other + # xdist workers for the runner's CPU, which made its timeout + # flakier, not less so, under parallelism. + pytest tests/ -n auto -o addopts="" -v --ignore=tests/test_store_concurrency.py + pytest tests/test_store_concurrency.py -o addopts="" -v else pytest tests/ -n auto -v --cov-report=xml fi diff --git a/tests/test_store_concurrency.py b/tests/test_store_concurrency.py index d3cff1b..cc825bd 100644 --- a/tests/test_store_concurrency.py +++ b/tests/test_store_concurrency.py @@ -18,7 +18,11 @@ _SESSION_ID = "CONCURRENT_SESSION" _PLATFORM = "claude" _CWD = "/concurrency-test" -_WRITER_TIMEOUT = 30 +# Generous margin: this spawns _WRITER_COUNT real Python interpreters that +# contend for the same on-disk lock, and a busy or oversubscribed CI runner +# (observed on GitHub's Windows runners) can push interpreter start-up and +# lock-wait time well past what a quiet dev machine sees. +_WRITER_TIMEOUT = 90 _WRITER_SCRIPT = f""" from pathlib import Path import sys