Run different version of mypy in ci #5086
Workflow file for this run
This file contains hidden or 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
name: test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
env: | |
UV_FROZEN: true # https://docs.astral.sh/uv/configuration/environment/#uv_frozen | |
UV_NO_SYNC: true # prevent `uv run` cmd from bringing very dev dependencies | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
mypy-self-check: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11', '3.12', '3.13'] | |
mypy-version: ['1.13', '1.14', '1.15', '1.16', 'latest'] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --no-dev --group tests | |
- name: Override mypy version | |
run: | | |
if [ "${{ matrix.mypy-version }}" == "latest" ]; then | |
uv pip install git+https://github.com/python/mypy.git@master | |
else | |
uv pip install mypy==${{ matrix.mypy-version }} | |
fi | |
- name: Run mypy on plugin code | |
run: uv run mypy --strict mypy_django_plugin | |
- name: Run mypy on ext code | |
run: uv run mypy --strict ext | |
- name: Run mypy on scripts and utils | |
run: uv run mypy --strict scripts | |
- name: Run mypy on stubs | |
run: uv run mypy --cache-dir=/dev/null --no-incremental django-stubs | |
- name: Run mypy on the test cases | |
run: uv run mypy --strict tests | |
test: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11', '3.12', '3.13'] | |
shard: [0, 1, 2, 3] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install binutils libproj-dev gdal-bin | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --no-dev --group tests | |
# Must match `shard` definition in the test matrix: | |
- name: Run pytest tests | |
run: uv run pytest --num-shards=4 --shard-id=${{ matrix.shard }} -n auto tests | |
stubtest: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.12', '3.13'] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install binutils libproj-dev gdal-bin | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --no-dev --group tests | |
- name: Run stubtest | |
run: uv run ./scripts/stubtest.sh | |
run-pyright: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.12'] # TODO: enable on other versions | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --no-dev --group pyright | |
# See https://github.com/jakebailey/pyright-action#providing-a-pyright-version-sourced-from-preexisting-dependencies | |
- name: Add venv to path | |
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH | |
- name: Run pyright on the stubs | |
uses: jakebailey/pyright-action@v2 | |
with: | |
version: PATH | |
annotate: false | |
continue-on-error: true # TODO: remove this part | |
- name: Run pyright on the test cases | |
uses: jakebailey/pyright-action@v2 | |
with: | |
version: PATH | |
project: ./pyrightconfig.testcases.json | |
matrix-test: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.10', '3.11', '3.12', '3.13'] | |
django-version: ['5.0', '5.1', '5.2'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install binutils libproj-dev gdal-bin | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: uv sync --no-dev --group tests | |
- name: Run django-stubs-ext tests | |
run: uv run --with "django==${{ matrix.django-version }}" pytest ext | |
build-and-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: python3 -m pip install --upgrade build twine | |
- name: Build | |
run: | | |
python3 -m build . | |
python3 -m build ext/ | |
- name: Check package metadata | |
run: | | |
twine check --strict dist/* | |
twine check --strict ext/dist/* |