Skip to content

Merge branch 'main' into beta #1247

Merge branch 'main' into beta

Merge branch 'main' into beta #1247

Workflow file for this run

name: Lint and Test
on:
push:
branches:
- main
- beta
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
merge_group:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
POETRY_VERSION: 2.0.0
jobs:
setup:
runs-on: ubuntu-24.04
outputs:
examples-matrix: ${{ steps.examples-matrix.outputs.examples-matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Calculate `examples-matrix` output
id: examples-matrix
working-directory: ./examples
env:
JQ_FILTER: >-
"examples-matrix=" + (split("\n") | map(select(length > 0)) | tostring)
run: |
examples=$(find . -type f -name 'pyproject.toml' -printf '%h\n' | cut -c 3- | sort -u | jq -cRrs '${{ env.JQ_FILTER }}')
echo "$examples"
echo "$examples" >> "$GITHUB_OUTPUT"
prefetch:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Update pip
run: |
pip install --upgrade pip
pip --version
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.12
cache: poetry
cache-dependency-path: '**/poetry.lock'
pre-commit:
# Skip pre-commit on `main` because the `no-commit-to-branch` hook won't
# allow it.
if: ${{ github.ref != 'refs/heads/main' }}
needs: [prefetch]
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.12
- uses: pre-commit/action@v3.0.1
lint-black:
needs: [prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
package: [pangea-django, pangea-sdk]
defaults:
run:
working-directory: ./packages/${{ matrix.package }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.9
cache: poetry
cache-dependency-path: ./packages/${{ matrix.package }}/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: black
run: poetry run black --check .
lint-isort:
needs: [prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
package: [pangea-django, pangea-sdk]
defaults:
run:
working-directory: ./packages/${{ matrix.package }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.9
cache: poetry
cache-dependency-path: ./packages/${{ matrix.package }}/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: isort
run: poetry run isort --check .
sdk-lint-mypy:
needs: [prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
package: [pangea-django, pangea-sdk]
defaults:
run:
working-directory: ./packages/${{ matrix.package }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.9
cache: poetry
cache-dependency-path: ./packages/${{ matrix.package }}/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: mypy
run: poetry run mypy .
sdk-test-unit:
needs: [prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
defaults:
run:
working-directory: ./packages/pangea-sdk
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: ./packages/pangea-sdk/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: Unit test
run: poetry run python -m unittest tests.unit
sdk-docs:
needs: [prefetch]
runs-on: ubuntu-24.04
defaults:
run:
working-directory: ./packages/pangea-sdk
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.12
cache: poetry
cache-dependency-path: ./packages/pangea-sdk/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: Generate docs
run: poetry run python parse_module.py > python_sdk.json
- name: Upload
uses: actions/upload-artifact@v4.6.0
with:
name: python_sdk.json
path: ./packages/pangea-sdk/python_sdk.json
examples:
needs: [setup, prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
example: ${{ fromJSON(needs.setup.outputs.examples-matrix) }}
defaults:
run:
working-directory: ./examples/${{ matrix.example }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Update pip
run: |
pip install --upgrade pip
pip --version
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: 3.12
cache: poetry
cache-dependency-path: ./examples/${{ matrix.example }}/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: black
run: poetry run black --check .
- name: isort
run: poetry run isort --check .
- name: mypy
run: poetry run mypy .
django-test-unit:
needs: [prefetch]
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
defaults:
run:
working-directory: ./packages/pangea-django
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Install poetry
run: |
pip install --upgrade poetry==${{ env.POETRY_VERSION }}
poetry --version
- name: Setup Python
uses: actions/setup-python@v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: ./packages/pangea-django/poetry.lock
- name: Install dependencies
run: |
poetry check
poetry install
- name: Unit test
run: poetry run python -m pytest