Skip to content

Import modules/objects directly from v1 namespace #12539

Import modules/objects directly from v1 namespace

Import modules/objects directly from v1 namespace #12539

Workflow file for this run

name: CI
on:
push:
branches:
- main
- 1.10.X-fixes
tags:
- '**'
pull_request: {}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.9
- uses: actions/cache@v3
id: cache
with:
path: |
${{ env.pythonLocation }}
.mypy_cache
key: >
lint-v2
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements-linting.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: |
make install-linting
pip freeze
- name: lint
run: make lint
- name: pyupgrade
run: make pyupgrade
- name: mypy
run: make mypy
- name: make history
run: python3 ./changes/make_history.py
- name: check dist
run: make check-dist
- name: install node for pyright
uses: actions/setup-node@v3
with:
node-version: '14'
- run: npm install -g pyright
- run: make pyright
docs-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
docs-build-v2
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('docs/requirements.txt') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: make install-docs
- name: build site
run: make docs
- name: Store docs site
uses: actions/upload-artifact@v3
with:
name: docs
path: site
test-memray:
name: test memray
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-memray
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: |
make install-testing
pip install pytest-memray==1.4.0
- name: compile
run: |
make build-trace
python -c "import sys, pydantic; print('compiled:', pydantic.compiled); sys.exit(0 if pydantic.compiled else 1)"
- name: test
run: pytest --ignore=tests/mypy/ --memray
test-linux-compiled:
name: test py${{ matrix.python-version }} on linux compiled
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
env:
PYTHON: ${{ matrix.python-version }}
OS: ubuntu
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-linux-compiled-v2
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: make install-testing
- name: compile
run: |
make build-trace
python -c "import sys, pydantic; print('compiled:', pydantic.compiled); sys.exit(0 if pydantic.compiled else 1)"
ls -alh
ls -alh pydantic/
- run: mkdir coverage
- name: test
run: make test
env:
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-compiled
CONTEXT: linux-py${{ matrix.python-version }}-compiled
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
test-not-compiled:
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-latest, windows]
python-version: ['3.7', '3.8', '3.9', '3.10']
exclude:
# Python 3.7, 3.8, and 3.9 are not available on macOS 14
- os: macos-13
python-version: '3.10'
- os: macos-latest
python-version: '3.7'
- os: macos-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.9'
runs-on: ${{ matrix.os }}
env:
PYTHON: ${{ matrix.python-version }}
OS: ${{ matrix.os }}
COMPILED: no
DEPS: yes
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: >
test-not-compiled-v2
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('setup.py') }}
${{ hashFiles('requirements.txt') }}
${{ hashFiles('tests/requirements-testing.txt') }}
- name: install
run: make install-testing
- run: pip freeze
- run: mkdir coverage
- name: test with deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-with-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-with-deps
- name: uninstall deps
run: pip uninstall -y cython email-validator devtools python-dotenv
- name: test without deps
run: make test
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-without-deps
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-deps
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
test-old-mypy:
name: test mypy v${{ matrix.mypy-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mypy-version: ['0.910', '0.921', '0.931', '0.942', '0.950', '0.960']
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: install
run: |
make install-testing
pip freeze
- name: uninstall deps
run: pip uninstall -y mypy tomli toml
- name: install specific mypy version
run: pip install mypy==${{ matrix.mypy-version }}
- run: mkdir coverage
- name: run tests
run: pytest --cov=pydantic tests/mypy
env:
COVERAGE_FILE: coverage/.coverage.linux-py3.10-mypy${{ matrix.mypy-version }}
CONTEXT: linux-py3.10-mypy${{ matrix.mypy-version }}
- name: store coverage files
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
coverage-combine:
needs: [test-linux-compiled, test-not-compiled, test-old-mypy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: get coverage files
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- run: pip install coverage
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "pydantic coverage for ${{ github.sha }}"
- name: Store coverage html
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: htmlcov
test-fastapi:
name: test fastAPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: install
run: make install-testing
- name: test
run: make test-fastapi
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu , macos , windows]
python-version: ['7', '8', '9', '10', '11']
include:
- os: ubuntu
platform: linux
- os: windows
ls: dir
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: install
run: pip install -U twine setuptools wheel cibuildwheel
- name: build sdist
if: matrix.os == 'ubuntu' && matrix.python-version == '9'
run: python setup.py sdist bdist_wheel
env:
SKIP_CYTHON: 1
- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir dist
env:
PIP: 'pip'
CIBW_BUILD: 'cp3${{ matrix.python-version }}-*'
CIBW_SKIP: '*-win32'
CIBW_PLATFORM: '${{ matrix.platform || matrix.os }}'
CIBW_BEFORE_BUILD: 'pip install -U "cython<3"'
CIBW_TEST_REQUIRES: 'pytest==6.2.5 pytest-mock==3.6.1'
CIBW_TEST_COMMAND: 'pytest {project}/tests'
CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014'
CIBW_MANYLINUX_I686_IMAGE: 'manylinux2014'
CIBW_ARCHS_MACOS: 'x86_64 arm64'
CIBW_TEST_SKIP: '*-macosx_arm64' # see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
# TODO build windows 32bit binaries
- name: list dist files
run: |
${{ matrix.ls || 'ls -lh' }} dist/
twine check dist/*
- name: Store dist artifacts
uses: actions/upload-artifact@v3
with:
name: pypi_files
path: dist
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- lint
- docs-build
- test-linux-compiled
- test-not-compiled
- test-old-mypy
- test-fastapi
- build
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
inspect-pypi-assets:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- name: list dist files
run: |
ls -lh dist/
echo "`ls dist | wc -l` files"
- name: extract and list sdist file
run: |
mkdir sdist-files
tar -xvf dist/*.tar.gz -C sdist-files
tree -a sdist-files
- name: extract and list wheel file
run: |
ls dist/*cp310-manylinux*x86_64.whl | head -n 1
python -m zipfile --list `ls dist/*cp310-manylinux*x86_64.whl | head -n 1`
publish_docs:
needs: [check]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
steps:
- name: checkout docs-site
uses: actions/checkout@v3
with:
ref: docs-site
- name: checkout current branch
uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: install
run: make install-docs
- name: Set git credentials
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- run: make docs
- name: check version
id: check-version
uses: samuelcolvin/check-python-version@v3.2
with:
version_file_path: 'pydantic/version.py'
- run: mike deploy -b docs-site ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} --update-aliases --push
if: "!fromJSON(steps.check-version.outputs.IS_PRERELEASE)"
release:
needs: [check]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- name: check version
uses: samuelcolvin/check-python-version@v3.2
with:
version_file_path: pydantic/version.py
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1