Skip to content

Update CI script

Update CI script #17

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-native:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install -e .[test,style,build]
python3 -m pip install build
- name: Test with pytest
run: pytest
- name: Build and test with twine
run: |
python3 -m build
twine check --strict dist/*
- name: Upload built package
uses: actions/upload-artifact@v6
if: ${{ matrix.python-version == '3.10' }}
with:
name: Package
path: dist
- name: Collect coverage
if: ${{ matrix.python-version == '3.10' }}
run:
coverage html
- name: Upload coverage report
uses: actions/upload-artifact@v6
if: ${{ matrix.python-version == '3.10' }}
with:
name: Coverage
path: htmlcov
build-uv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Lint with black
run: uv run black --check .
- name: Lint with flake8
run: uv run flake8 . --show-source --statistics
- name: Lint with isort
run: uv run isort --check --diff .
- name: Check with mypy
run: uv run mypy src
- name: Test with pytest
run: uv run pytest
- name: Build and test with twine
run: |
uv build
twine check --strict dist/*
docs:
needs: build-native
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r docs/requirements.txt
- name: Build documentation
run: |
sphinx-build -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
- name: Upload documentation
uses: actions/upload-artifact@v6
with:
name: Docs
path: dist/docs