Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci to test all plugins on PR label #132

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
fail_ci_if_error: true

test_napari:
if: ${{ github.event.label.name != 'test-all-plugins' }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this triggers for prs with the test-all-plugins label. Is that right?

name: napari tests
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test_all_plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: Test all plugins

on:
pull_request:
types: [ labeled ]
workflow_dispatch:

jobs:
get-plugins:
if: github.event.label.name == 'test-all-plugins' || github.event_name == 'workflow_dispatch'
if: contains(github.event.pull_request.labels.*.name, 'test-all-plugins') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.9.1
Expand Down Expand Up @@ -54,7 +53,7 @@ jobs:
# but also work in the absence of napari... so probably don't want
# to add napari to their deps.
- name: install napari
if: matrix.plugin == "RedLionfish" || matrix.plugin == "smo"
if: ${{ matrix.plugin == 'RedLionfish' || matrix.plugin == 'smo' }}
run: mamba install napari

- name: Install ${{ matrix.plugin }} from conda
Expand Down
41 changes: 36 additions & 5 deletions tests/test_all_plugins.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import os
import warnings
from importlib import metadata
from typing import List

import pytest

from npe2._from_npe1 import _python_name, iter_hookimpls
from npe2.manifest.utils import SHIM_NAME_PREFIX, import_python_name

PLUGIN = os.getenv("TEST_PACKAGE_NAME")
if not PLUGIN:
pytest.skip("skipping plugin specific tests", allow_module_level=True)


FORGOT_NAPARI = [
"vessel-express",
"RedLionfish",
Expand All @@ -33,19 +38,45 @@ def entry_points():
def test_plugin_has_entry_points(entry_points):
if PLUGIN not in {"napari-console", "napari-error-reporter"}:
assert entry_points
print("EPs:", entry_points)
print("\nEPs:", entry_points)


if PLUGIN in FORGOT_NAPARI:
m = pytest.mark.xfail(reason="forgot napari in deps", strict=True)
depsfail = pytest.mark.xfail(reason="forgot napari in deps", strict=True)
elif PLUGIN == "napari-omero":
m = pytest.mark.xfail(reason="needs conda work", strict=True)
depsfail = pytest.mark.xfail(reason="needs conda work", strict=True)
else:
m = lambda f: f # noqa
depsfail = lambda f: f # noqa


@m
@depsfail
def test_entry_points_importable(entry_points: List[metadata.EntryPoint]):
for ep in entry_points:
if ep.group == "napari.plugin":
ep.load()


@depsfail
def test_npe1_python_names(entry_points: List[metadata.EntryPoint]):
for ep in entry_points:
if ep.group == "napari.plugin":
for impl in iter_hookimpls(ep.load()):
if impl.specname not in (
"napari_provide_sample_data",
"napari_experimental_provide_function",
"napari_experimental_provide_dock_widget",
):
continue
print()
result = impl.function()
if isinstance(result, dict):
result = result.values()
elif not isinstance(result, list):
result = [result]
for idx, item in enumerate(result):
pyname = _python_name(item, impl.function, idx)
print(pyname)
assert import_python_name(pyname) is not None
if SHIM_NAME_PREFIX in pyname:
warnings.warn("SHIMMING: %r" % pyname)
assert SHIM_NAME_PREFIX not in pyname # temporary