Skip to content

CI - Tests

CI - Tests #94

Workflow file for this run

# .github/workflows/ci.yml
# This workflow runs Continous Integration (CI) including tests and linting.
# for a variety of Python versions
# For more information see:
# https://py-pkgs.org/08-ci-cd
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: CI - Tests
# Controls when the workflow will run
on:
push:
pull_request:
schedule:
# Runs Monday through Friday at 02:00 UTC
- cron: '0 2 * * 1-5'
# A workflow run is made up of one or more jobs that can run
# sequentially or in parallel
jobs:
ci:
# Set up operating system
runs-on: ${{ matrix.os }}
# Ensure matplotlib uses a non-interactive backend on all runners
env:
MPLBACKEND: Agg
# Use github.workspace (available during workflow evaluation) so MPLCONFIGDIR is valid at parse time
MPLCONFIGDIR: ${{ github.workspace }}/.matplotlib
strategy:
matrix:
# Use underscore keys to avoid expression access issues (use matrix.python_version)
python_version: ["3.14", "3.13", "3.12", "3.11", "3.10"]
# Runner labels: use lowercase macos-latest
os: [ubuntu-latest, macos-latest, windows-latest]
# Exclude/Include logic for 3.14 (allow failure for future Python version)
exclude:
- python_version: "3.14"
os: ubuntu-latest
- python_version: "3.14"
os: macos-latest
- python_version: "3.14"
os: windows-latest
include:
# Re-add 3.14 combos but mark them as allow_failure: true
- python_version: "3.14"
os: ubuntu-latest
allow_failure: true
- python_version: "3.14"
os: macos-latest
allow_failure: true
- python_version: "3.14"
os: windows-latest
allow_failure: true
fail-fast: false
# Apply the matrix value to the entire job; default to false if matrix.allow_failure is not set
continue-on-error: ${{ matrix.allow_failure || false }}
steps:
- uses: actions/checkout@v4
# If we're testing with Python 3.14, use a dedicated lockfile (pdm.lock314) by copying it
# over pdm.lock before any dependency install or cache key evaluation that reads pdm.lock.
- name: Use pdm.lock314
if: matrix.python_version == '3.14'
shell: bash
run: |
if [ -f pdm.lock314 ]; then
echo "Using pdm.lock314 for python 3.14"
cp pdm.lock314 pdm.lock
else
echo "pdm.lock314 not found; falling back to pdm.lock"
fi
# Caching step for speed (runs after potential copy so cache key includes chosen pdm.lock)
- name: Set up PDM cache
uses: actions/cache@v4
with:
path: |
~/.cache/pdm
.venv
key: ${{ runner.os }}-pdm-${{ matrix.python_version }}-${{ hashFiles('pyproject.toml', 'pdm.lock') }}
restore-keys: |
${{ runner.os }}-pdm-${{ matrix.python_version }}-
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: pdm install -dG test
- name: Run Tests
run: pdm run pytest
# See: https://martinheinz.dev/blog/69 "Ultimate CI Pipeline for All of Your Python Projects"
- name: Use Codecov to track coverage
# Running coverage only on push to the "master" branch
if: matrix.os == 'ubuntu-latest' && matrix.python_version == '3.13' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml # coverage report