refactor: Migrate Python projects from Pydantic v1 to v2 #20316
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow runs tests and lint on pull requests that touch the api/ | |
# project or its CI configuration. | |
name: 'API test/lint/deploy' | |
on: | |
# Most of the time, we run on pull requests, which lets us handle external PRs | |
pull_request: | |
paths: | |
- 'api/**/*' | |
- 'Makefile' | |
- 'shared-data/**/*' | |
- '!shared-data/js/**' | |
- 'hardware/**/*' | |
- 'scripts/**/*.mk' | |
- 'scripts/**/*.py' | |
- '.github/workflows/api-test-lint-deploy.yaml' | |
- '.github/actions/python/**/*' | |
- '.github/workflows/utils.js' | |
push: | |
paths: | |
- 'api/**' | |
- 'Makefile' | |
- 'shared-data/**/*' | |
- '!shared-data/js/**/*' | |
- 'hardware/**/*' | |
- 'scripts/**/*.mk' | |
- 'scripts/**/*.py' | |
- '.github/workflows/api-test-lint-deploy.yaml' | |
- '.github/actions/python/**/*' | |
- '.github/workflows/utils.js' | |
branches: | |
- 'edge' | |
- 'release' | |
- '*hotfix*' | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
lint: | |
name: 'opentrons package linting' | |
timeout-minutes: 10 | |
runs-on: 'ubuntu-22.04' | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
- uses: 'actions/setup-node@v4' | |
with: | |
node-version: '22.11.0' | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: '3.10' | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'api' | |
- name: Lint with opentrons_hardware | |
run: make -C api lint | |
test: | |
name: 'opentrons package tests on ${{ matrix.os }}, python ${{ matrix.python }}' | |
timeout-minutes: 30 | |
needs: [lint] | |
strategy: | |
matrix: | |
os: ['windows-2022', 'ubuntu-22.04', 'macos-latest'] | |
python: ['3.10'] | |
with-ot-hardware: ['true', 'false'] | |
exclude: | |
- os: 'windows-2022' | |
with-ot-hardware: 'true' | |
- os: 'macos-latest' | |
with-ot-hardware: 'true' | |
runs-on: '${{ matrix.os }}' | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
# https://github.com/actions/checkout/issues/290 | |
- name: 'Fix actions/checkout odd handling of tags' | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
git checkout ${{ github.ref }} | |
- uses: 'actions/setup-node@v4' | |
with: | |
node-version: '22.11.0' | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: ${{ matrix.python }} | |
- name: 'set complex environment variables' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) | |
buildComplexEnvVars(core, context) | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'api' | |
python-version: ${{ matrix.python }} | |
- if: ${{ matrix.with-ot-hardware == 'false' }} | |
name: Remove OT-3 hardware package | |
run: make -C api setup-ot2 | |
env: | |
OT_VIRTUALENV_VERSION: ${{ matrix.python }} | |
- if: ${{ matrix.with-ot-hardware == 'false' }} | |
name: Test without opentrons_hardware | |
run: make -C api test-ot2 | |
- if: ${{ matrix.with-ot-hardware == 'true' }} | |
name: Test with opentrons_hardware | |
run: make -C api test-cov | |
- name: Ensure assets build | |
run: make -C api sdist wheel | |
- name: Upload coverage report | |
uses: 'codecov/codecov-action@v3' | |
with: | |
files: ./api/coverage.xml | |
flags: api | |
test-package: | |
name: 'installed package tests on ${{ matrix.os }}' | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
os: ['ubuntu-22.04', 'macos-latest', 'windows-2022'] | |
runs-on: '${{ matrix.os }}' | |
steps: | |
- uses: 'actions/checkout@v4' | |
- name: 'Fix actions/checkout odd handling of tags' | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
git checkout ${{ github.ref }} | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: '3.10' | |
- name: Set up package-testing | |
id: setup | |
if: ${{ matrix.os != 'windows-2022' }} | |
working-directory: package-testing | |
shell: bash | |
run: make setup | |
- name: Set up package-testing (Windows) | |
id: setup-windows | |
if: ${{ matrix.os == 'windows-2022' }} | |
working-directory: package-testing | |
shell: pwsh | |
run: make setup-windows | |
- name: Run the tests | |
if: ${{ matrix.os != 'windows-2022' }} | |
shell: bash | |
id: test | |
working-directory: package-testing | |
run: make test | |
- name: Run the tests (Windows) | |
shell: pwsh | |
id: test-windows | |
working-directory: package-testing | |
run: make test-windows | |
- name: Save the test results | |
if: ${{ always() && steps.setup.outcome == 'success' || steps.setup-windows.outcome == 'success' }} | |
id: results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package-test-results-${{ matrix.os }} | |
path: package-testing/results | |
- name: Set job summary | |
if: ${{ always() }} | |
run: | | |
echo "## Opentrons Package Test Results ${{matrix.os}}" >> $GITHUB_STEP_SUMMARY | |
echo "### Test Outcome: Unixy ${{ steps.test.outcome }} Windows: ${{ steps.test-windows.outcome }}" >> $GITHUB_STEP_SUMMARY | |
echo "[Download the test results artifact](${{steps.results.outputs.artifact-url}})" >> $GITHUB_STEP_SUMMARY | |
deploy: | |
name: 'deploy opentrons package' | |
needs: [test] | |
runs-on: 'ubuntu-22.04' | |
if: github.event_name == 'push' | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
# https://github.com/actions/checkout/issues/290 | |
- name: 'Fix actions/checkout odd handling of tags' | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
git fetch -f origin ${{ github.ref }}:${{ github.ref }} | |
git checkout ${{ github.ref }} | |
- uses: 'actions/setup-node@v4' | |
with: | |
node-version: '22.11.0' | |
- uses: 'actions/setup-python@v4' | |
with: | |
python-version: '3.10' | |
- name: 'set complex environment variables' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`) | |
buildComplexEnvVars(core, context) | |
- uses: './.github/actions/python/setup' | |
with: | |
project: 'api' | |
# creds and repository configuration for deploying python wheels | |
- if: ${{ !env.OT_TAG }} | |
name: 'upload to test pypi' | |
uses: './.github/actions/python/pypi-deploy' | |
with: | |
project: 'api' | |
repository_url: 'https://test.pypi.org/legacy/' | |
password: '${{ secrets.TEST_PYPI_DEPLOY_TOKEN_OPENTRONS }}' | |
- if: startsWith(env.OT_TAG, 'v') | |
name: 'upload to real pypi' | |
uses: './.github/actions/python/pypi-deploy' | |
with: | |
project: 'api' | |
repository_url: 'https://upload.pypi.org/legacy/' | |
password: '${{ secrets.PYPI_DEPLOY_TOKEN_OPENTRONS }}' |