Skip to content

[GSK-1745] Support both Pydantic 1 & 2 #86

[GSK-1745] Support both Pydantic 1 & 2

[GSK-1745] Support both Pydantic 1 & 2 #86

name: Python-client
on:
push:
branches:
- main
pull_request:
paths:
- 'python-client/**'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Do not stop when any job fails
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
os: [ubuntu-latest]
experimental: [false]
pydantic_v1: [false]
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- python-version: "3.10"
os: windows-2019
experimental: false
pydantic_v1: false
- python-version: "3.10"
os: ubuntu-latest
experimental: false
pydantic_v1: true
continue-on-error: ${{ matrix.experimental }} # https://ncorti.com/blog/howto-github-actions-build-matrix
steps:
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
uses: actions/[email protected]
- name: Cache Python deps
uses: actions/cache@v3
with:
path: python-client/.venv
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: false # TODO(Bazire): https://linear.app/giskard/issue/GSK-1712/activate-cache-on-pdm-setup-in-github-action
- name: Set up Pandoc (needed for python-client doc)
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: '3.1.7' # https://github.com/jgm/pandoc/releases
- name: Cache Giskard test resources
uses: actions/cache@v3
with:
path: ~/.giskard
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-test-resources-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-giskard-test-resources
- name: Install dependencies
working-directory: python-client
run: pdm install -G :all
- name: Lint code
working-directory: python-client
run: pdm run lint
- name: Install pydantic settings (Dirty hack, do not merge !)
if: ${{ !matrix.pydantic_v1 }}
working-directory: python-client
run: pdm run pip install "pydantic_settings>2"
- name: Install pydantic v1
if: ${{ matrix.pydantic_v1 }}
working-directory: python-client
run: pdm run pip install "pydantic<2"
- name: Check Pydantic installed version
working-directory: python-client
run: |
pdm run pip freeze | tail -n +1 | grep '^pydantic'
pdm run pip freeze | tail -n +1 | grep -q '^pydantic==${{ matrix.pydantic_v1 && '1' || '2' }}\.'
- name: Test code
working-directory: python-client
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: ${{ matrix.os == 'windows-2019' && 1 || 2 }}
GSK_DISABLE_ANALYTICS: true
run: pdm run test-fast
- name: Build doc
if : ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'}}
working-directory: python-client
run: pdm run doc
- name: Build
working-directory: python-client
run: pdm build
- name: "Python client: archive built artifacts"
if: ${{ steps.extract_branch.outputs.branch == 'main' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v3
with:
path: python-client/dist/*whl