Skip to content

Commit 293a561

Browse files
ci: use reusable test workflow (#612)
* 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>
1 parent d3f8979 commit 293a561

File tree

2 files changed

+75
-177
lines changed

2 files changed

+75
-177
lines changed

.github/workflows/test_and_deploy.yml

Lines changed: 63 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,57 @@ concurrency:
66

77
on:
88
push:
9-
branches:
10-
- main
11-
tags:
12-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
9+
branches: [main]
10+
tags: [v*]
1311
pull_request:
14-
branches:
15-
- main
1612
workflow_dispatch:
13+
schedule:
14+
- cron: "0 0 * * *" # run once a day
1715

1816
jobs:
1917
test:
20-
name: ${{ matrix.platform }} (${{ matrix.python-version }}) ${{ matrix.backend }}
21-
runs-on: ${{ matrix.platform }}
18+
name: Test
19+
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@v1
20+
with:
21+
os: ${{ matrix.os }}
22+
python-version: ${{ matrix.python-version }}
23+
qt: ${{ matrix.qt }}
24+
pip-install-pre-release: ${{ github.event_name == 'schedule' }}
25+
report-failures: ${{ github.event_name == 'schedule' }}
26+
secrets: inherit
2227
strategy:
2328
fail-fast: false
2429
matrix:
2530
python-version: ["3.8", "3.9", "3.10", "3.11"]
26-
platform: [ubuntu-latest, macos-latest, windows-latest]
27-
backend: [pyqt5, pyside2]
31+
os: [ubuntu-latest, macos-latest, windows-latest]
32+
qt: [pyqt5, pyside2]
2833
include:
2934
- python-version: "3.10"
30-
platform: ubuntu-latest
31-
backend: pyqt6
35+
os: ubuntu-latest
36+
qt: pyqt6
3237
- python-version: "3.10"
33-
platform: ubuntu-latest
34-
backend: pyside6
38+
os: ubuntu-latest
39+
qt: pyside6
3540
- python-version: "3.12"
36-
platform: ubuntu-latest
37-
backend: pyqt6
41+
os: ubuntu-latest
42+
qt: pyqt6
3843
exclude:
3944
- python-version: "3.11"
40-
backend: pyside2
41-
42-
steps:
43-
- uses: actions/checkout@v4
44-
- name: Set up Python ${{ matrix.python-version }}
45-
uses: actions/setup-python@v5
46-
with:
47-
python-version: ${{ matrix.python-version }}
48-
- uses: tlambert03/[email protected]
49-
- name: Install dependencies
50-
run: python -m pip install --upgrade hatch
51-
52-
- name: Test
53-
uses: aganders3/headless-gui@v2
54-
with:
55-
run: hatch -v run +backend=${{ matrix.backend }} test:run
56-
57-
- name: Coverage
58-
uses: codecov/codecov-action@v4
59-
with:
60-
token: ${{ secrets.CODECOV_TOKEN }}
45+
qt: pyside2
46+
47+
test-min-reqs:
48+
name: Test min reqs
49+
uses: pyapp-kit/workflows/.github/workflows/test-pyrepo.yml@main
50+
with:
51+
os: ubuntu-latest
52+
python-version: ${{ matrix.python-version }}
53+
qt: pyqt5
54+
pip-install-min-reqs: true
55+
secrets: inherit
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
python-version: ["3.8", "3.9", "3.10", "3.11"]
6160

6261
test-pydantic1:
6362
name: Test pydantic1
@@ -85,110 +84,33 @@ jobs:
8584
with:
8685
token: ${{ secrets.CODECOV_TOKEN }}
8786

88-
test_napari:
89-
name: napari tests
90-
runs-on: ubuntu-latest
91-
steps:
92-
- uses: actions/checkout@v4
93-
- uses: actions/checkout@v4
94-
with:
95-
repository: napari/napari
96-
path: napari-from-github
97-
- uses: tlambert03/[email protected]
98-
- uses: actions/setup-python@v5
99-
with:
100-
python-version: "3.10"
101-
- name: Install
102-
run: |
103-
python -m pip install --upgrade pip pytest-pretty
104-
python -m pip install -e .[testing]
105-
python -m pip install -e ./napari-from-github[pyqt5]
106-
107-
- name: Test napari magicgui
108-
uses: aganders3/headless-gui@v2
109-
with:
110-
working-directory: napari-from-github
111-
run: pytest -W ignore napari/_tests/test_magicgui.py -v --color=yes
112-
113-
test_magicclass:
114-
name: magic-class tests
115-
runs-on: ubuntu-latest
116-
steps:
117-
- uses: actions/checkout@v4
118-
- uses: actions/checkout@v4
119-
with:
120-
repository: hanjinliu/magic-class
121-
path: magic-class
122-
- uses: tlambert03/[email protected]
123-
- uses: actions/setup-python@v5
124-
with:
125-
python-version: "3.10"
126-
- name: Install
127-
run: |
128-
python -m pip install --upgrade pip
129-
python -m pip install -e .[testing,pyqt5]
130-
python -m pip install ./magic-class[testing]
131-
132-
- name: Test magicclass
133-
uses: aganders3/headless-gui@v2
134-
# magicclass is still in development, don't fail the whole build
135-
# this makes this much less useful... but it's better than nothing?
136-
continue-on-error: true
137-
with:
138-
working-directory: magic-class
139-
run: pytest -v --color=yes
140-
141-
test_stardist:
142-
name: stardist tests
143-
runs-on: ubuntu-latest
144-
steps:
145-
- uses: actions/checkout@v4
146-
- uses: actions/checkout@v4
147-
with:
148-
repository: stardist/stardist-napari
149-
path: stardist-napari
150-
- uses: tlambert03/[email protected]
151-
- uses: actions/setup-python@v5
152-
with:
153-
python-version: "3.10"
154-
- name: Install
155-
run: |
156-
python -m pip install --upgrade pip
157-
python -m pip install -e .[testing]
158-
python -m pip install ./stardist-napari[test]
159-
160-
- name: Run stardist tests
161-
uses: aganders3/headless-gui@v2
162-
with:
163-
working-directory: stardist-napari
164-
run: python -m pytest -v --color=yes -W ignore stardist_napari
165-
env:
166-
STARDIST_NAPARI_NOTHREADS: true
167-
STARDIST_NAPARI_NOPERSIST: true
168-
169-
test_partseg:
170-
name: partseg tests
171-
runs-on: ubuntu-latest
172-
steps:
173-
- uses: actions/checkout@v4
174-
- uses: actions/checkout@v4
175-
with:
176-
repository: 4DNucleome/PartSeg
177-
path: PartSeg
178-
- uses: tlambert03/[email protected]
179-
- uses: actions/setup-python@v5
180-
with:
181-
python-version: "3.10"
182-
- name: Install
183-
run: |
184-
python -m pip install -e .[testing]
185-
python -m pip install ./PartSeg[test,pyqt5]
186-
187-
- name: Run PartSeg tests
188-
uses: aganders3/headless-gui@v2
189-
with:
190-
working-directory: PartSeg
191-
run: python -m pytest -v --color=yes -W ignore package/tests/test_PartSeg/test_napari_widgets.py
87+
test-dependents:
88+
uses: pyapp-kit/workflows/.github/workflows/test-dependents.yml@v1
89+
with:
90+
dependency-repo: ${{ matrix.package }}
91+
dependency-ref: ${{ matrix.package-version }}
92+
dependency-extras: ${{ matrix.package-extras || 'testing' }}
93+
host-extras: "testing"
94+
qt: pyqt5
95+
python-version: "3.10"
96+
post-install-cmd: "python -m pip install pytest-pretty"
97+
pytest-args: ${{ matrix.pytest-args }}
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
include:
102+
- package: napari/napari
103+
pytest-args: napari/_tests/test_magicgui.py
104+
- package: napari/napari
105+
package-version: "v0.4.18"
106+
pytest-args: napari/_tests/test_magicgui.py
107+
- package: hanjinliu/magic-class
108+
- package: stardist/stardist-napari
109+
package-extras: test
110+
pytest-args: stardist_napari
111+
- package: 4DNucleome/PartSeg
112+
package-extras: test
113+
pytest-args: package/tests/test_PartSeg/test_napari_widgets.py
192114

193115
deploy:
194116
needs: test

pyproject.toml

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,15 @@ classifiers = [
3535
dynamic = ["version"]
3636
dependencies = [
3737
"docstring_parser>=0.7",
38-
"psygnal>=0.5.0",
38+
"psygnal>=0.6.1",
3939
"qtpy>=1.7.0",
4040
"superqt[iconify]>=0.6.1",
41-
"typing_extensions",
41+
"typing_extensions>=4.1.0",
4242
]
4343

4444
# extras
4545
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
4646
[project.optional-dependencies]
47-
min-req = [
48-
"docstring_parser==0.7",
49-
"psygnal==0.5.0",
50-
"qtpy==1.7.0",
51-
"superqt==0.6.1",
52-
"typing_extensions",
53-
]
54-
5547
pyqt5 = ["pyqt5>=5.12.0"]
5648
pyqt6 = ["pyqt6"]
5749
pyside2 = [
@@ -63,11 +55,11 @@ tqdm = ["tqdm>=4.30.0"]
6355
jupyter = ["ipywidgets>=8.0.0"]
6456
image = ["pillow>=4.0"]
6557
quantity = ["pint>=0.13.0"]
66-
testing = [
58+
test = [
6759
"pytest",
6860
"pytest-qt",
6961
"pytest-cov",
70-
"pytest-mypy-plugins",
62+
"pytest-mypy-plugins>=3",
7163
"numpy",
7264
"pandas",
7365
"tqdm>=4.30.0",
@@ -82,33 +74,14 @@ testing = [
8274
"annotated_types",
8375
]
8476
dev = [
85-
"annotated_types",
86-
"attrs",
8777
"black",
8878
"ruff",
8979
"ipython",
90-
"ipywidgets",
91-
"isort",
92-
"matplotlib",
9380
"mypy",
94-
"numpy",
95-
"pandas",
9681
"pdbpp",
97-
"pillow>=4.0",
98-
"pint>=0.13.0",
9982
"pre-commit",
100-
"pydantic",
101-
"pydocstyle",
10283
"pyqt6",
103-
"pytest-cov",
104-
"pytest-cov",
105-
"pytest-mypy-plugins",
106-
"pytest-qt",
107-
"pytest",
108-
"pytest",
10984
"rich",
110-
"toolz",
111-
"tqdm>=4.30.0",
11285
]
11386
docs = [
11487
"mkdocs",
@@ -140,7 +113,7 @@ documentation = "https://pyapp-kit.github.io/magicgui/"
140113
source = "vcs"
141114

142115
[tool.hatch.envs.test]
143-
features = ["testing"]
116+
features = ["test"]
144117
[tool.hatch.envs.test.scripts]
145118
run = "pytest -v --color=yes --cov-config=pyproject.toml --cov --cov-report=xml --cov-report=term-missing"
146119
[[tool.hatch.envs.test.matrix]]
@@ -213,6 +186,7 @@ filterwarnings = [
213186
"error",
214187
"ignore::DeprecationWarning:tqdm",
215188
"ignore::DeprecationWarning:docstring_parser",
189+
"ignore:distutils Version classes are deprecated:DeprecationWarning",
216190
]
217191

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

242216
# https://coverage.readthedocs.io/en/6.4/config.html
243217
[tool.coverage.report]
218+
show_missing = true
244219
exclude_lines = [
245220
"pragma: no cover",
246221
"if TYPE_CHECKING:",
@@ -252,13 +227,14 @@ exclude_lines = [
252227
"\\.\\.\\.",
253228
]
254229
omit = [
255-
"src/magicgui/events.py",
256-
"src/magicgui/widgets/_image/_mpl_image.py",
257-
"src/magicgui/widgets/_bases/*",
230+
"**/magicgui/events.py",
231+
"**/magicgui/widgets/_image/_mpl_image.py",
232+
"**/magicgui/widgets/_bases/*",
258233
"tests/*",
259234
"docs/*",
260235
]
261-
236+
[tool.coverage.run]
237+
source = ["magicgui"]
262238

263239
# https://github.com/mgedmin/check-manifest#configuration
264240
[tool.check-manifest]

0 commit comments

Comments
 (0)