Skip to content

Refactor endpoint tests to use the same setup (#388) #714

Refactor endpoint tests to use the same setup (#388)

Refactor endpoint tests to use the same setup (#388) #714

name: Run tests and push coverage to Codecov
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install uv CLI
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install dependencies
run: uv sync --all-extras --dev
test:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
group: [1, 2, 3]
mongodb-version: ['8']
env:
PMATCHER_CONFIG: ../instance/config.py
steps:
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.1
with:
mongodb-version: ${{ matrix.mongodb-version }}
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install uv CLI
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Cache uv virtualenv and .venv
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: uv-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Run tests
run: uv run pytest --cov --test-group-count 3 --test-group=${{ matrix.group }} --test-group-random-seed=12345
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: coverage-${{ matrix.group }}
path: .coverage
include-hidden-files: true
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install coverage
run: |
python -m pip install --upgrade pip
pip install coverage
- name: Download coverage artifacts
uses: actions/download-artifact@v8
with:
path: ./coverage-data
- name: Combine and report coverage
run: |
coverage combine coverage-data/coverage-*/.coverage
coverage report
coverage xml
- name: Upload to Codecov
uses: codecov/codecov-action@v5