Skip to content

Commit 0aeb615

Browse files
committed
Use Python venv for coverage too
1 parent 800c449 commit 0aeb615

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
workflow_dispatch:
1111

1212
env:
13+
DEFAULT_PYTHON: "3.13"
1314
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1415

1516
concurrency:
@@ -314,23 +315,35 @@ jobs:
314315
coverage:
315316
name: Process test coverage
316317
runs-on: ubuntu-latest
317-
needs: ["pytest"]
318+
needs: ["pytest", "prepare"]
318319
steps:
319320
- name: Check out code from GitHub
320321
uses: actions/[email protected]
322+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
323+
uses: actions/[email protected]
324+
id: python
321325
with:
322-
fetch-depth: 0
323-
- name: Download coverage data
324-
uses: actions/[email protected]
325-
- name: Set up uv
326-
uses: astral-sh/[email protected]
326+
python-version: ${{ env.DEFAULT_PYTHON }}
327+
- name: Restore Python virtual environment
328+
id: cache-venv
329+
uses: actions/[email protected]
327330
with:
328-
enable-cache: true
329-
- name: Install dependencies
330-
run: uv sync --frozen --dev
331-
- name: Process coverage results
331+
path: venv
332+
key: >
333+
${{ runner.os }}-venv-${{ env.DEFAULT_PYTHON }}-
334+
${{ hashFiles('pyproject.toml') }}
335+
- name: Fail job if Python cache restore failed
336+
if: steps.cache-venv.outputs.cache-hit != 'true'
332337
run: |
333-
uv run --frozen coverage combine coverage*/.coverage*
334-
uv run --frozen coverage xml -i
338+
echo "Failed to restore Python virtual environment from cache"
339+
exit 1
340+
- name: Download all coverage artifacts
341+
uses: actions/[email protected]
342+
- name: Combine coverage results
343+
run: |
344+
. venv/bin/activate
345+
coverage combine coverage*/.coverage*
346+
coverage report
347+
coverage xml
335348
- name: Upload coverage to Codecov
336349
uses: codecov/[email protected]

0 commit comments

Comments
 (0)