diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 003cec5..592f612 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -50,19 +50,23 @@ jobs: # Editable installs of packages/core + packages/server are extremely slow # on the hosted runner — measured 4-6x slower than building wheels first # because hatchling's editable hook re-resolves on every collection. We - # build wheels once, then install them (and only the test deps) into a - # plain venv. The wheels themselves are NOT cached because their hashes - # depend on every file under packages/ — invalidates on basically every - # PR. Pip's HTTP cache for the test deps is enough. - - name: Build wheels + # build wheels once into an isolated venv, then install them (and only + # the test deps). The venv isolation also prevents broken-wheel installs + # from leaking dist-info across runs on the persistent Gitea runner + # (pip can't uninstall a wheel that landed without a RECORD file). The + # wheels themselves are NOT cached because their hashes depend on every + # file under packages/ — invalidates on basically every PR. Pip's HTTP + # cache for the test deps is enough. + - name: Build wheels in isolated venv run: | - python -m pip install --upgrade pip build + python -m venv /tmp/venv + /tmp/venv/bin/pip install --upgrade pip build mkdir -p /tmp/wheels - pip wheel --no-deps -w /tmp/wheels packages/core packages/server + /tmp/venv/bin/pip wheel --no-deps -w /tmp/wheels packages/core packages/server - name: Install backend + test deps run: | - pip install /tmp/wheels/*.whl pytest pytest-asyncio httpx aioresponses prometheus_client + /tmp/venv/bin/pip install /tmp/wheels/*.whl pytest pytest-asyncio httpx aioresponses prometheus_client - name: Run pytest env: @@ -72,7 +76,7 @@ jobs: NOTIFY_BRIDGE_CORS_ALLOWED_ORIGINS: "http://localhost:8420" run: | cd packages/server - pytest tests --tb=short + /tmp/venv/bin/pytest tests --tb=short build-image: if: ${{ !startsWith(gitea.event.head_commit.message, 'chore: release v') }} diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 527136d..008c2cd 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -20,17 +20,20 @@ jobs: with: python-version: "3.12" - # Same wheel-first strategy as build.yml — editable install is too slow - # on the hosted runner. - - name: Build wheels + # Wheel-first strategy in an isolated venv — editable install is too slow, + # and a plain pip install into the toolcache Python leaks state across + # runs on the persistent Gitea runner (previous broken wheel installs + # leave dist-info dirs that pip can't uninstall: "uninstall-no-record-file"). + - name: Build wheels in isolated venv run: | - python -m pip install --upgrade pip build + python -m venv /tmp/venv + /tmp/venv/bin/pip install --upgrade pip build mkdir -p /tmp/wheels - pip wheel --no-deps -w /tmp/wheels packages/core packages/server + /tmp/venv/bin/pip wheel --no-deps -w /tmp/wheels packages/core packages/server - name: Install backend + test deps run: | - pip install /tmp/wheels/*.whl pytest pytest-asyncio httpx aioresponses prometheus_client + /tmp/venv/bin/pip install /tmp/wheels/*.whl pytest pytest-asyncio httpx aioresponses prometheus_client - name: Run pytest env: @@ -40,7 +43,7 @@ jobs: NOTIFY_BRIDGE_CORS_ALLOWED_ORIGINS: "http://localhost:8420" run: | cd packages/server - pytest tests --tb=short + /tmp/venv/bin/pytest tests --tb=short release: needs: [test-backend]