From 0459fe372c837bd0dd468111e3cfa5e40b3a2ed6 Mon Sep 17 00:00:00 2001 From: Nick Stenning Date: Mon, 19 Aug 2024 16:04:54 +0200 Subject: [PATCH] Test on Pydantic v1 and v2 Adds a Pydantic axis to the test matrix --- .github/workflows/ci.yaml | 5 +++-- tox.ini | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da9a02f18e..17dc928a67 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -81,12 +81,13 @@ jobs: run: make test-go test-python: - name: "Test Python ${{ matrix.python-version }}" + name: "Test Python ${{ matrix.python-version }} + Pydantic v${{ matrix.pydantic }}" needs: build-python runs-on: ubuntu-latest-8-cores strategy: fail-fast: false matrix: + pydantic: ["1", "2"] python-version: ${{ fromJson(needs.build-python.outputs.python-versions) }} steps: - name: Download pre-built packages @@ -111,7 +112,7 @@ jobs: - name: Remove src to ensure tests run against wheel run: rm -rf python/cog - name: Test - run: python -Im tox run --installpkg "$COG_WHEEL" -e ${{ env.TOX_PYTHON }}-tests + run: python -Im tox run --installpkg "$COG_WHEEL" -e ${{ env.TOX_PYTHON }}-pydantic${{ matrix.pydantic }}-tests # cannot run this on mac due to licensing issues: https://github.com/actions/virtual-environments/issues/2150 test-integration: diff --git a/tox.ini b/tox.ini index 08e273a1ca..999f8ad787 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] min_version = 4 env_list = - py3{7,8,9,10,11,12,13}-tests + py3{7,8,9,10,11,12,13}-pydantic{1,2}-tests lint typecheck integration @@ -18,6 +18,9 @@ addopts = --timeout=10 package = wheel # Build the same wheel for all environments wheel_build_env = .pkg +deps = + pydantic1: pydantic>=1,<2 + pydantic2: pydantic>=2,<3 extras = tests: tests pass_env =