Skip to content

ci: split test suite #2436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 72 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
with:
model: qwen2:0.5b

- run: uv sync --only-dev
- run: >
uv run
--package pydantic-ai-slim
Expand All @@ -130,13 +131,14 @@ jobs:
CO_API_KEY: ${{ secrets.COHERE_API_KEY }}

test:
name: test on ${{ matrix.python-version }}
name: test on ${{ matrix.python-version }} (${{ matrix.install }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
install: ["slim", "standard", "all-extras"]
env:
UV_PYTHON: ${{ matrix.python-version }}
CI: true
Expand All @@ -148,43 +150,92 @@ jobs:
with:
enable-cache: true

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: |
if [ "${{ matrix.install }}" = "slim" ]; then
echo "--package pydantic-ai-slim"
elif [ "${{ matrix.install }}" = "standard" ]; then
echo ""
elif [ "${{ matrix.install }}" = "all-extras" ]; then
echo "--all-extras"
fi
id: install-command

- run: mkdir .coverage

# run tests with just `pydantic-ai-slim` dependencies
- run: uv run --package pydantic-ai-slim coverage run -m pytest -n auto --dist=loadgroup
env:
COVERAGE_FILE: .coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-slim
- run: uv sync --group dev
- run: uv run ${{ steps.install-command.outputs.install-command }} coverage run -m pytest -n auto --dist=loadgroup

- run: uv run coverage run -m pytest -n auto --dist=loadgroup
env:
COVERAGE_FILE: .coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-standard
- name: store coverage files
uses: actions/upload-artifact@v4
if: matrix.python-version != '3.9'
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.install }}
path: .coverage
include-hidden-files: true

- run: uv run --all-extras coverage run -m pytest -n auto --dist=loadgroup
env:
COVERAGE_FILE: .coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-all-extras
test-lowest-versions:
name: test lowest versions on ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
env:
UV_PYTHON: ${{ matrix.python-version }}
CI: true
COVERAGE_PROCESS_START: ./pyproject.toml
steps:
- uses: actions/checkout@v4

- run: uv run --all-extras python tests/import_examples.py
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- run: mkdir .coverage

- run: uv sync --group dev

# this must run last as it modifies the environment!
- name: test lowest versions
if: matrix.python-version != '3.9'
run: |
unset UV_FROZEN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a name here or move this to a separate run

uv run --all-extras --resolution lowest-direct coverage run -m pytest -n auto --dist=loadgroup
env:
COVERAGE_FILE: .coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-lowest-versions

- name: store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
name: coverage-${{ matrix.python-version }}-lowest-versions
path: .coverage
include-hidden-files: true

test-examples:
name: test examples on ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
env:
UV_PYTHON: ${{ matrix.python-version }}
CI: true
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- run: uv run --all-extras python tests/import_examples.py

coverage:
runs-on: ubuntu-latest
needs: [test]
Expand All @@ -204,8 +255,7 @@ jobs:
with:
enable-cache: true

- run: uv sync --package pydantic-ai-slim --only-dev
- run: rm .coverage/.coverage.*-py3.9-* # Exclude 3.9 coverage as it gets the wrong line numbers, causing invalid failures.
- run: uv sync --group dev
- run: uv run coverage combine

- run: uv run coverage html --show-contexts --title "Pydantic AI coverage for ${{ github.sha }}"
Expand Down
21 changes: 0 additions & 21 deletions pydantic_ai_slim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,6 @@ ag-ui = ["ag-ui-protocol>=0.1.8", "starlette>=0.45.3"]
# Retries
retries = ["tenacity>=8.2.3"]

[dependency-groups]
dev = [
"anyio>=4.5.0",
"asgi-lifespan>=2.1.0",
"devtools>=0.12.2",
"coverage[toml]>=7.10.2",
"dirty-equals>=0.9.0",
"duckduckgo-search>=7.0.0",
"inline-snapshot>=0.19.3",
"pytest>=8.3.3",
"pytest-examples>=0.0.14",
"pytest-mock>=3.14.0",
"pytest-pretty>=1.3.0",
"pytest-recording>=0.13.2",
"diff-cover>=9.2.0",
"boto3-stubs[bedrock-runtime]",
"strict-no-cover @ git+https://github.com/pydantic/strict-no-cover.git@7fc59da2c4dff919db2095a0f0e47101b657131d",
"pytest-xdist>=3.6.1",
"coverage-enable-subprocess>=0.1.0",
]

[tool.hatch.metadata]
allow-direct-references = true

Expand Down
23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,29 @@ members = [
"examples",
]

[tool.uv]
default-groups = ["dev", "lint", "docs"]

[dependency-groups]
# dev dependencies are defined in `pydantic-ai-slim/pyproject.toml` to allow for minimal testing
dev = [
"anyio>=4.5.0",
"asgi-lifespan>=2.1.0",
"devtools>=0.12.2",
"coverage[toml]>=7.10.2",
"dirty-equals>=0.9.0",
"duckduckgo-search>=7.0.0",
"inline-snapshot>=0.19.3",
"pytest>=8.3.3",
"pytest-examples>=0.0.18",
"pytest-mock>=3.14.0",
"pytest-pretty>=1.3.0",
"pytest-recording>=0.13.2",
"diff-cover>=9.2.0",
"boto3-stubs[bedrock-runtime]",
"strict-no-cover @ git+https://github.com/pydantic/strict-no-cover.git@7fc59da2c4dff919db2095a0f0e47101b657131d",
"pytest-xdist>=3.6.1",
"coverage-enable-subprocess>=0.1.0",
]
lint = ["mypy>=1.11.2", "pyright>=1.1.390", "ruff>=0.6.9"]
docs = [
"pydantic-ai[a2a]",
Expand Down
82 changes: 39 additions & 43 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading