Skip to content

Commit

Permalink
Dynamic testing matrix for combinations of python and numpy versions. (
Browse files Browse the repository at this point in the history
…#286)

* 👷 `tox` config in separate file

* 👷 cis use `tox`

* 🐛 repo review tox exception

* 🐛 cache versions as env variables

* 🐛 run `tox` with specific py version

* Dynamic testing matrix for combinations of python and numpy versions.

* With pre-releases support now, and uv everywhere :)

* We need `packaging` for version parsing.

* ruff!

* matrix improvements

* matrix improvements

* removed debug step

* made ruff, pyright and even mypy happy

* reducing matrix to only minor versions, not micro

* attempted to merge #285

* attempted to merge #285

* extra tox environments

* attempt to fix build

* attempt to fix build

* attempt to fix build

* attempt to fix build

* attempt to fix build

* attempt to fix build

* attempt to fix build

* debugging bloody CI

* debugging bloody CI

* debugging bloody CI

* debugging bloody CI

* debugging bloody CI

* finally fixed build!?

* testing without the explicit packaging requirement

* linebreaks!

* testing without the explicit packaging requirement

* reduced timeouts

* removed extraneous python specifiers

* testing with locked instead of frozen

* further timeout reductions

* updated lock file

* added pip freeze

---------

Co-authored-by: miloth <milo.knightword@gmail.com>
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
  • Loading branch information
3 people authored Dec 15, 2024
1 parent 0b63592 commit 8793281
Show file tree
Hide file tree
Showing 6 changed files with 526 additions and 130 deletions.
120 changes: 47 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ name: CI

on:
push:
branches: [master]
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
UV_LOCKED: true

jobs:
lint:
timeout-minutes: 5
timeout-minutes: 1
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

Expand All @@ -29,92 +28,67 @@ jobs:
- name: typos
uses: crate-ci/typos@master

- name: setup uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
python-version: "3.13"
generate-matrix:
name: Generate Test Matrix
timeout-minutes: 1
runs-on: ubuntu-latest

- name: install
run: uv sync
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4

- name: repo-review
run: uv run repo-review .
- name: Install uv
uses: astral-sh/setup-uv@v4

- name: mdformat
run: uv run mdformat --check
- name: Install dependencies
run: |
uv sync --locked
- name: ruff
- name: Generate Matrix
id: set-matrix
shell: bash
run: |
uv run ruff check --output-format=github
uv run ruff format --check
matrix=$(uv run scripts/generate_matrix.py | jq -c)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
typetest:
timeout-minutes: 5

needs: generate-matrix
timeout-minutes: 2
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

- name: setup uv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
python-version: "3.13"

- name: install
run: uv sync --no-editable
python-version: ${{ matrix.python }}

- name: basedpyright
run: >
uv run --no-sync
basedpyright
- name: setup tox
run: uv tool install tox --with tox-uv

- name: basedmypy
run: >
uv run --no-sync
mypy --config-file=pyproject.toml .
- name: stubtest
run: >
uv run --no-sync
stubtest
--mypy-config-file=pyproject.toml
--allowlist=.mypyignore
--ignore-unused-allowlist
scipy
typetest-oldest-supported-numpy:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
continue-on-error: true
run: |
rm -rf .venv
uv add --no-build-package=numpy "numpy<=${{ matrix.numpy }}"
- name: setup uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
python-version: "3.10"
- name: Run typetest
run: uv run tox -e=typetest

- name: install
run: |
uv sync --no-editable --no-install-package numpy
uv pip install numpy==$(uv run --no-sync scripts/version_bounds.py numpy)
- name: Run stubtest
run: uv run tox -e=stubtest

- name: basedpyright
run: >
uv run --no-sync
basedpyright
- name: lint
run: uv run tox -e=lint

- name: basedmypy
run: >
uv run --no-sync
mypy --config-file=pyproject.toml .
- name: stubtest
run: >
uv run --no-sync
stubtest
--mypy-config-file=pyproject.toml
--allowlist=.mypyignore
--ignore-unused-allowlist
scipy
run: uv run tox -e=mypy

- name: basedpyright
run: uv run tox -e=pyright
25 changes: 3 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ lint = [
]
typecheck = [
{include-group = "scipy"},
{include-group = "codegen"},
"basedmypy[faster-cache]>=2.8.1",
"basedpyright>=1.22.1",
"packaging",
]
codegen = [
"libcst>=1.5.1,<2",
Expand Down Expand Up @@ -223,6 +225,7 @@ reportUnsafeMultipleInheritance = true # based
[tool.repo-review]
ignore = [
"PY004", # no /docs
"PY007", # tox configured in tox.toml
"PP301", # pytest is irrelevant
"PC111", # no blacken-docs because markdown has no code
"PC140", # manual typecheck pre-commit hooks
Expand Down Expand Up @@ -274,25 +277,3 @@ typing = ["collections.abc", "types", "typing", "typing_extensions"]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
mypy-init-return = true

[tool.tox]
isolated_build = true
env_list = ["repo-review", "pre-commit", "3.10", "3.11", "3.12", "3.13"]

[tool.tox.env_run_base]
runner = "uv-venv-lock-runner"
description = "stubtest with {base_python}"
allowlist_externals = ["poe"]
commands = [["poe", "stubtest"]]

[tool.tox.env.pre-commit]
runner = "uv-venv-lock-runner"
description = "pre-commit"
allowlist_externals = ["poe"]
commands = [["poe", "pre-commit"]]

[tool.tox.env.repo-review]
runner = "uv-venv-lock-runner"
description = "repo-review"
allowlist_externals = ["poe"]
commands = [["poe", "repo-review"]]
Loading

0 comments on commit 8793281

Please sign in to comment.