Skip to content

Workflow file for this run

name: Build
on: push
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
fail-fast: false
env:
PYTHONDEVMODE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
# Install dependencies.
- name: Install dependencies
run: poetry install
# Run checks.
- name: Check (ruff)
run: poetry run ruff check
- name: Check (ruff format)
run: poetry run ruff format --check
- name: Check (mypy)
run: poetry run mypy
# Run tests.
- name: Test
run: poetry run coverage run --data-file=".coverage-${{ matrix.python-version }}" -m pytest
# Upload coverage.
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: .coverage-${{ matrix.python-version }}
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
# Install dependencies.
- name: Install dependencies
run: poetry install --without dev --with docs
# Build docs.
- name: Build docs
run: poetry run sphinx-build -W docs docs/_build
report:
runs-on: ubuntu-latest
needs:
- test
- docs
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
# Install dependencies.
- name: Install dependencies
run: poetry install
# Report coverage.
- name: Download coverage
uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true
- name: Combine coverage
run: poetry run coverage combine .coverage-*
- name: Report coverage
run: poetry run coverage report
# Fail if any `needs` job was not a success.
# Along with `if: always()`, this allows this job to act as a single required status check for the entire workflow.
- name: Fail on workflow error
run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}