From 8294404ad4edf01887bcd39b1acfd04ce9cb2b7f Mon Sep 17 00:00:00 2001 From: ProtocolWarden <32967198+ProtocolWarden@users.noreply.github.com> Date: Thu, 4 Jun 2026 16:24:48 -0400 Subject: [PATCH] fix(ci): run pytest inside project .venv so the test job goes green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `test` job installed `.[dev]` into the hosted Python and ran a bare `pytest`. But tests/conftest.py has a venv guard that hard-exits (code 2) unless the active interpreter is this project's ./.venv (or CUSTODIAN_SKIP_VENV_GUARD is set). On the runner sys.prefix was the hosted toolcache, not .venv, so every CI run aborted before collecting a single test: ERROR: Tests must be run inside this project's virtual environment. Expected: .../.venv Active: /opt/hostedtoolcache/Python/... Root cause: environment mismatch between the workflow and the guard, not a test failure — the suite passes (76 passed) when run through .venv. Fix: have the test job create ./.venv, install the package into it, and invoke `.venv/bin/pytest`, exactly as the guard's own instructions and a developer checkout do. This keeps the guard meaningful in CI rather than bypassing it. license-check and lint jobs were already green and are untouched. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f66924..e4e2f4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,13 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" - - name: Install dependencies - run: pip install -e ".[dev]" + - name: Create project virtualenv and install + # tests/conftest.py guards against running against the global + # interpreter and requires this project's ./.venv. Build it here so + # CI exercises the same environment a developer checkout uses. + run: | + python -m venv .venv + .venv/bin/python -m pip install --upgrade pip + .venv/bin/pip install -e ".[dev]" - name: Run tests - run: pytest -q + run: .venv/bin/pytest -q