-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (111 loc) · 5.06 KB
/
Copy pathrun-unit-tests.yml
File metadata and controls
116 lines (111 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Unit tests
on:
push:
workflow_call:
jobs:
unit-tests:
name: "Unit tests (Python ${{ matrix.python-version }}, ${{ matrix.resolution }}, Pydantic ${{ matrix.pydantic-version }}, FastAPI ${{ matrix.fastapi-version }})"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
resolution: ['locked']
pydantic-version: ['lockfile']
fastapi-version: ['lockfile']
# Every include entry must spell out all four keys. GitHub only merges an
# include into an existing combination when it overwrites no original key;
# because `resolution` and `pydantic-version` are original keys, these rows
# create new combinations that contain *only* the keys listed here. Omitting
# one would silently expand to an empty string below.
include:
# Floor and ceiling of the declared dependency ranges. lowest-direct stops
# at 3.13: pydantic-core ships no 3.14 wheel for the pydantic 2.9.0 floor.
- python-version: '3.10'
resolution: 'lowest-direct'
pydantic-version: 'lockfile'
fastapi-version: 'lockfile'
- python-version: '3.13'
resolution: 'lowest-direct'
pydantic-version: 'lockfile'
fastapi-version: 'lockfile'
- python-version: '3.13'
resolution: 'highest'
pydantic-version: 'lockfile'
fastapi-version: 'lockfile'
- python-version: '3.14'
resolution: 'highest'
pydantic-version: 'lockfile'
fastapi-version: 'lockfile'
# Specific older releases, to avoid an extremely large test matrix.
# Older pydantic releases with the oldest + second-latest supported python version.
# (using python 3.14 requires pydantic 2.12 which is currently the latest)
- python-version: '3.13'
resolution: 'locked'
pydantic-version: '2.11.10'
fastapi-version: 'lockfile'
- python-version: '3.13'
resolution: 'locked'
pydantic-version: '2.10.6'
fastapi-version: 'lockfile'
- python-version: '3.10'
resolution: 'locked'
pydantic-version: '2.10.6'
fastapi-version: 'lockfile'
- python-version: '3.13'
resolution: 'locked'
pydantic-version: '2.9.2'
fastapi-version: 'lockfile'
- python-version: '3.10'
resolution: 'locked'
pydantic-version: '2.9.2'
fastapi-version: 'lockfile'
# Older fastapi releases with the oldest + latest supported python version
- python-version: '3.14'
resolution: 'locked'
pydantic-version: 'lockfile'
fastapi-version: '0.103.2'
- python-version: '3.10'
resolution: 'locked'
pydantic-version: 'lockfile'
fastapi-version: '0.103.2'
fail-fast: false
steps:
- name: Check out repository code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install uv and set the python version
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
# Pinned to the version that generated uv.lock, so `--locked` cannot
# fail on an unrelated lockfile-format bump.
version: "0.12.7"
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install the project
# --all-extras: [project.optional-dependencies], i.e. fastapi + orjson
# The 'dev' group from [dependency-groups] is synced by default and
# chains in 'test' and 'doc' via include-group.
run: |
case "${{ matrix.resolution }}" in
locked) uv sync --all-extras --locked ;;
lowest-direct) uv sync --all-extras --resolution lowest-direct --upgrade ;;
highest) uv sync --all-extras --resolution highest --upgrade ;;
*) echo "::error::unknown resolution '${{ matrix.resolution }}'" && exit 1 ;;
esac
# Force specific older releases on top of the resolved set. This
# deliberately deviates from the lockfile, hence --no-sync when running.
if [ "${{ matrix.pydantic-version }}" != "lockfile" ]; then
uv pip install "pydantic[email]~=${{ matrix.pydantic-version }}"
fi
if [ "${{ matrix.fastapi-version }}" != "lockfile" ]; then
uv pip install "fastapi~=${{ matrix.fastapi-version }}"
fi
- name: Run Unit tests
run: uv run --no-sync pytest tests/unit_tests --cov-branch --cov=pydantic_forms --ignore=tests --cov-report=xml
env:
COVERAGE_FILE: reports/.coverage.${{ matrix.python-version }}
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./coverage.xml