Skip to content

Test Matrix

Test Matrix #15

Workflow file for this run

name: Test Matrix
on: [ workflow_dispatch ]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
branch: ${{ github.head_ref || github.ref_name }}
strategy:
matrix:
python_version: [ '3.9', '3.10', '3.11', '3.12' ]
pydantic: [ 'no', 'v1', 'v2' ]
include:
- python_version: '3.9'
- python_version: '3.10'
- python_version: '3.11'
pydantic: 'v2'
- python_version: '3.12'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Restore poetry from cache
id: cache-poetry-restore
uses: actions/cache/restore@v3
with:
path: ~/.local
key: test-all/poetry/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}
- name: Install poetry
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Check poetry version
run: echo POETRY_VERSION=$(poetry --version | grep -oP '\d+.\d+.\d+') >> $GITHUB_ENV
- name: Save poetry cache
id: cache-poetry-save
uses: actions/cache/save@v3
with:
path: ~/.local
key: test-all/poetry/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}/version/${{ env.POETRY_VERSION }}
- name: Cache virtual environment
id: cache-venv
uses: actions/cache@v3
with:
path: .venv
key: test/branch/${{ env.branch }}/runner/${{ runner.os }}/python/${{ steps.setup-python.outputs.python-version }}/pydantic/${{ matrix.pydantic }}/hash/${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --all-extras --no-root --with=test
- name: Install pydantic v1
if: steps.cache-venv.outputs.cache-hit != 'true' && matrix.pydantic == 'v1'
run: poetry run pip install pydantic===1.10.13
- name: Install pydantic v2
if: steps.cache-venv.outputs.cache-hit != 'true' && matrix.pydantic == 'v2'
run: poetry install --no-interaction --no-root --with=pydantic
- name: Install project
run: poetry install --no-interaction --all-extras
- name: Run pytest
run: poetry run pytest