name: Coverage CI
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
max-parallel: 42
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# install & configure uv
#----------------------------------------------
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
# Install a specific version of uv.
version: "0.5.1"
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --all-extras --dev
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Define a cache dependency glob
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Run tests
# For example, using `pytest`
run: uv run pytest tests
#----------------------------------------------
# Test coverage
#----------------------------------------------
- name: Run tests and generate coverage
run: |
uv run pytest --cov=backend/server --cov-report=xml tests/
# Uncomment when achieve sufficient coverage threshold
uv run coverage report -m
#----------------------------------------------
# Update codecov coverage
#----------------------------------------------
- name: Debug CODECOV_TOKEN
run: |
if [ -z "${CODECOV_TOKEN}" ]; then
echo "CODECOV_TOKEN is NOT set"
else
echo "CODECOV_TOKEN is set (but value is hidden)"
fi
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Only upload if the token is non-empty
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}