Skip to content

Commit

Permalink
ci: use reusable test workflow (#612)
Browse files Browse the repository at this point in the history
* ci: try reusable workflow

* force

* try rename

* force

* force

* rename

* add coverage.run

* test deps

* style(pre-commit.ci): auto fixes [...]

* update

* inherit secrets

* add min-reqs test

* shorter name

* add min typing extensions

* change cov report

* update minreqs

* bump min typing-ext

* ci: don't use matrix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
tlambert03 and pre-commit-ci[bot] committed Feb 17, 2024
1 parent d3f8979 commit 293a561
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 177 deletions.
204 changes: 63 additions & 141 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,57 @@ concurrency:

on:
push:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches: [main]
tags: [v*]
pull_request:
branches:
- main
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # run once a day

jobs:
test:
name: ${{ matrix.platform }} (${{ matrix.python-version }}) ${{ matrix.backend }}
runs-on: ${{ matrix.platform }}
name: Test
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v1
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
qt: ${{ matrix.qt }}
pip-install-pre-release: ${{ github.event_name == 'schedule' }}
report-failures: ${{ github.event_name == 'schedule' }}
secrets: inherit
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
platform: [ubuntu-latest, macos-latest, windows-latest]
backend: [pyqt5, pyside2]
os: [ubuntu-latest, macos-latest, windows-latest]
qt: [pyqt5, pyside2]
include:
- python-version: "3.10"
platform: ubuntu-latest
backend: pyqt6
os: ubuntu-latest
qt: pyqt6
- python-version: "3.10"
platform: ubuntu-latest
backend: pyside6
os: ubuntu-latest
qt: pyside6
- python-version: "3.12"
platform: ubuntu-latest
backend: pyqt6
os: ubuntu-latest
qt: pyqt6
exclude:
- python-version: "3.11"
backend: pyside2

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: tlambert03/setup-qt-libs@v1.7
- name: Install dependencies
run: python -m pip install --upgrade hatch

- name: Test
uses: aganders3/headless-gui@v2
with:
run: hatch -v run +backend=${{ matrix.backend }} test:run

- name: Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
qt: pyside2

test-min-reqs:
name: Test min reqs
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@main
with:
os: ubuntu-latest
python-version: ${{ matrix.python-version }}
qt: pyqt5
pip-install-min-reqs: true
secrets: inherit
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

test-pydantic1:
name: Test pydantic1
Expand Down Expand Up @@ -85,110 +84,33 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

test_napari:
name: napari tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: napari/napari
path: napari-from-github
- uses: tlambert03/setup-qt-libs@v1.7
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install
run: |
python -m pip install --upgrade pip pytest-pretty
python -m pip install -e .[testing]
python -m pip install -e ./napari-from-github[pyqt5]
- name: Test napari magicgui
uses: aganders3/headless-gui@v2
with:
working-directory: napari-from-github
run: pytest -W ignore napari/_tests/test_magicgui.py -v --color=yes

test_magicclass:
name: magic-class tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: hanjinliu/magic-class
path: magic-class
- uses: tlambert03/setup-qt-libs@v1.7
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install -e .[testing,pyqt5]
python -m pip install ./magic-class[testing]
- name: Test magicclass
uses: aganders3/headless-gui@v2
# magicclass is still in development, don't fail the whole build
# this makes this much less useful... but it's better than nothing?
continue-on-error: true
with:
working-directory: magic-class
run: pytest -v --color=yes

test_stardist:
name: stardist tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: stardist/stardist-napari
path: stardist-napari
- uses: tlambert03/setup-qt-libs@v1.7
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install -e .[testing]
python -m pip install ./stardist-napari[test]
- name: Run stardist tests
uses: aganders3/headless-gui@v2
with:
working-directory: stardist-napari
run: python -m pytest -v --color=yes -W ignore stardist_napari
env:
STARDIST_NAPARI_NOTHREADS: true
STARDIST_NAPARI_NOPERSIST: true

test_partseg:
name: partseg tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: 4DNucleome/PartSeg
path: PartSeg
- uses: tlambert03/setup-qt-libs@v1.7
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install
run: |
python -m pip install -e .[testing]
python -m pip install ./PartSeg[test,pyqt5]
- name: Run PartSeg tests
uses: aganders3/headless-gui@v2
with:
working-directory: PartSeg
run: python -m pytest -v --color=yes -W ignore package/tests/test_PartSeg/test_napari_widgets.py
test-dependents:
uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v1
with:
dependency-repo: ${{ matrix.package }}
dependency-ref: ${{ matrix.package-version }}
dependency-extras: ${{ matrix.package-extras || 'testing' }}
host-extras: "testing"
qt: pyqt5
python-version: "3.10"
post-install-cmd: "python -m pip install pytest-pretty"
pytest-args: ${{ matrix.pytest-args }}
strategy:
fail-fast: false
matrix:
include:
- package: napari/napari
pytest-args: napari/_tests/test_magicgui.py
- package: napari/napari
package-version: "v0.4.18"
pytest-args: napari/_tests/test_magicgui.py
- package: hanjinliu/magic-class
- package: stardist/stardist-napari
package-extras: test
pytest-args: stardist_napari
- package: 4DNucleome/PartSeg
package-extras: test
pytest-args: package/tests/test_PartSeg/test_napari_widgets.py

deploy:
needs: test
Expand Down
48 changes: 12 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,15 @@ classifiers = [
dynamic = ["version"]
dependencies = [
"docstring_parser>=0.7",
"psygnal>=0.5.0",
"psygnal>=0.6.1",
"qtpy>=1.7.0",
"superqt[iconify]>=0.6.1",
"typing_extensions",
"typing_extensions>=4.1.0",
]

# extras
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
[project.optional-dependencies]
min-req = [
"docstring_parser==0.7",
"psygnal==0.5.0",
"qtpy==1.7.0",
"superqt==0.6.1",
"typing_extensions",
]

pyqt5 = ["pyqt5>=5.12.0"]
pyqt6 = ["pyqt6"]
pyside2 = [
Expand All @@ -63,11 +55,11 @@ tqdm = ["tqdm>=4.30.0"]
jupyter = ["ipywidgets>=8.0.0"]
image = ["pillow>=4.0"]
quantity = ["pint>=0.13.0"]
testing = [
test = [
"pytest",
"pytest-qt",
"pytest-cov",
"pytest-mypy-plugins",
"pytest-mypy-plugins>=3",
"numpy",
"pandas",
"tqdm>=4.30.0",
Expand All @@ -82,33 +74,14 @@ testing = [
"annotated_types",
]
dev = [
"annotated_types",
"attrs",
"black",
"ruff",
"ipython",
"ipywidgets",
"isort",
"matplotlib",
"mypy",
"numpy",
"pandas",
"pdbpp",
"pillow>=4.0",
"pint>=0.13.0",
"pre-commit",
"pydantic",
"pydocstyle",
"pyqt6",
"pytest-cov",
"pytest-cov",
"pytest-mypy-plugins",
"pytest-qt",
"pytest",
"pytest",
"rich",
"toolz",
"tqdm>=4.30.0",
]
docs = [
"mkdocs",
Expand Down Expand Up @@ -140,7 +113,7 @@ documentation = "https://pyapp-kit.github.io/magicgui/"
source = "vcs"

[tool.hatch.envs.test]
features = ["testing"]
features = ["test"]
[tool.hatch.envs.test.scripts]
run = "pytest -v --color=yes --cov-config=pyproject.toml --cov --cov-report=xml --cov-report=term-missing"
[[tool.hatch.envs.test.matrix]]
Expand Down Expand Up @@ -213,6 +186,7 @@ filterwarnings = [
"error",
"ignore::DeprecationWarning:tqdm",
"ignore::DeprecationWarning:docstring_parser",
"ignore:distutils Version classes are deprecated:DeprecationWarning",
]

# https://mypy.readthedocs.io/en/stable/config_file.html
Expand Down Expand Up @@ -241,6 +215,7 @@ ignore_missing_imports = true

# https://coverage.readthedocs.io/en/6.4/config.html
[tool.coverage.report]
show_missing = true
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
Expand All @@ -252,13 +227,14 @@ exclude_lines = [
"\\.\\.\\.",
]
omit = [
"src/magicgui/events.py",
"src/magicgui/widgets/_image/_mpl_image.py",
"src/magicgui/widgets/_bases/*",
"**/magicgui/events.py",
"**/magicgui/widgets/_image/_mpl_image.py",
"**/magicgui/widgets/_bases/*",
"tests/*",
"docs/*",
]

[tool.coverage.run]
source = ["magicgui"]

# https://github.com/mgedmin/check-manifest#configuration
[tool.check-manifest]
Expand Down

0 comments on commit 293a561

Please sign in to comment.