name: CI/CD Pipeline
on:
push:
branches: [main, develop, "release/**"]
tags: ["v*"]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-extras
- name: Lint with ruff
run: uv run ruff check --no-fix
- name: Check formatting
run: uv run ruff format --check
- name: Type check with mypy
run: uv run mypy src
- name: Test with pytest
run: uv run pytest --cov=src --cov-report=xml --ignore=tests/docs/
- name: Upload coverage
uses: codecov/codecov-action@v3
integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python 3.11
run: uv python install 3.11
- name: Install dependencies
run: uv sync --all-extras
- name: Run integration tests
run: uv run pytest tests/integration/ -v
build:
runs-on: ubuntu-latest
needs: [test, integration-test]
if: startsWith(github.ref, 'refs/heads/release/v') || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python 3.11
run: uv python install 3.11
- name: Install dependencies
run: uv sync
- name: Build package
run: uv build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/heads/release/v') || startsWith(github.ref, 'refs/tags/v')
environment: PyPI
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1