✨ Enable caching for uv installation and add coverage installation st… #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
env: | |
UV_SYSTEM_PYTHON: 1 | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Install dependencies | |
run: uv sync --all-extras | |
- name: Run pre-commit | |
run: uv run pre-commit run --all-files | |
test: | |
name: Test Python ${{ matrix.python }} | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ["3.11", "3.12", "3.13"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Install dependencies | |
run: uv sync --all-extras --python ${{ matrix.python }} | |
- name: Test with pytest | |
run: uv run pytest | |
- name: Rename coverage report | |
run: mv .coverage .coverage.py${{ matrix.python }} | |
- name: Save coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.python }} | |
path: .coverage.py${{ matrix.python }} | |
include-hidden-files: true | |
coverage-report: | |
name: Coverage report | |
runs-on: ubuntu-latest | |
needs: [test] | |
steps: | |
- name: Get coverage reports | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-* | |
merge-multiple: true | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Install coverage | |
run: uv pip install coverage | |
- name: Combine coverage reports | |
run: | | |
uv run coverage combine .coverage.* | |
uv run coverage xml -o cov.xml | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v4.0.1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./cov.xml |