diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ba6b86..53e3be5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,12 +53,31 @@ 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. + # + # 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 - 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", 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