Skip to content

Commit 2034aac

Browse files
Some cleanups and split the CI
1 parent 3972a0d commit 2034aac

3 files changed

Lines changed: 65 additions & 38 deletions

File tree

.github/workflows/ci.yml

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,64 @@ jobs:
6363
python -m pip install .[test]
6464
python -m pip install ${{ matrix.backend }}
6565
66-
- name: Set up OMERO
67-
if: runner.os == 'Linux'
66+
- name: Test (local)
67+
run: pytest ./tests/local --color=yes --cov=napari_omero --cov-report=xml
68+
69+
# - name: Codecov
70+
# uses: codecov/codecov-action@v5
71+
# env:
72+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
73+
74+
# Integration tests against a real, containerized OMERO server.
75+
# Kept as a separate job (single OS + Python) so the server stack is only
76+
# started once, rather than across the full test matrix.
77+
test-server:
78+
name: server tests
79+
runs-on: ubuntu-latest
80+
defaults:
81+
run:
82+
shell: bash -l {0}
83+
steps:
84+
- uses: actions/checkout@v6
85+
- uses: conda-incubator/setup-miniconda@v3
86+
with:
87+
miniforge-version: "latest"
88+
python-version: "3.12"
89+
90+
# the server test for the browser widget needs a Qt backend + display
91+
- uses: pyvista/setup-headless-display-action@v4
92+
with:
93+
qt: true
94+
95+
- name: Install dependencies
96+
run: |
97+
conda install omero-py
98+
python -m pip install --upgrade pip
99+
python -m pip install .[test]
100+
python -m pip install PyQt5
101+
102+
- name: Set up OMERO server
68103
run: |
69-
git clone https://github.com/openmicroscopy/omero-test-infra .omero
70-
# ensure the ports are bound correctly
104+
# omero-test-infra is used only to stand up a server stack (compose up);
105+
# Pinned to latest commit: Dec 2025
106+
git clone https://github.com/ome/omero-test-infra .omero
107+
git -C .omero checkout c8a0015b0ce72ee0a49e6968af33de10ea00bc77
108+
# Bind the server/web ports to fixed host ports so the host-side tests
109+
# can reach localhost:4064 / :4080 (compose defaults to random ports).
71110
# see also: https://github.com/ome/omero-test-infra/issues/77
72111
echo 'OMERO_SERVER_SSL=4064:' >> .omero/.env
73112
echo 'OMERO_WEB_PORT=4080:' >> .omero/.env
74113
.omero/compose up -d
75114
.omero/wait-on-login
76115
77-
- name: Test with OMERO server
78-
if: runner.os == 'Linux'
116+
- name: Test (server)
79117
run: pytest ./tests/server --color=yes --cov=napari_omero --cov-report=xml
80118

81-
- name: Test local
82-
run: pytest ./tests/local --color=yes --cov=napari_omero --cov-report=xml --cov-append
83-
84-
# - name: Codecov
85-
# uses: codecov/codecov-action@v5
86-
# env:
87-
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
88-
89119
deploy:
90120
# this will run when you have tagged a commit, starting with "v*"
91121
# and requires that you have put your twine API key in your
92-
needs: [test]
93-
if: success() && startsWith(github.ref, 'refs/tags/') && github.repository == 'tlambert03/napari-omero'
122+
needs: [test, test-server]
123+
if: success() && startsWith(github.ref, 'refs/tags/') && github.repository == 'ome/napari-omero'
94124
runs-on: ubuntu-latest
95125
permissions:
96126
id-token: write

tests/server/conftest.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
# This code is derived from the conftest.py file from the ezomero library,
2-
# which is licensed under the GNU General Public License v2.0 as published by
3-
# the Free Software Foundation.
1+
# This code is derived from the conftest.py file in the ezomero project:
2+
# https://github.com/erickmartins/ezomero
3+
# Copyright (c) 2020-2025, Erick Ratamero, Dave Mellert, and contributors
44
#
5-
# Copyright (c) 2020-2025, Erick Ratamero, Dave Mellert, and contributors
6-
#
7-
# This program is free software: you can redistribute it and/or modify
8-
# it under the terms of the GNU General Public License as published by
9-
# the Free Software Foundation, either version 3 of the License, or
10-
# (at your option) any later version.
11-
#
12-
# This program is distributed in the hope that it will be useful,
13-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
# GNU General Public License for more details.
16-
#
17-
# For the original code, please see:
18-
# https://github.com/erickmartins/ezomero
5+
# ezomero is distributed under the GNU General Public License, version 2
6+
# (GPL-2.0). napari-omero is GPL-2.0-or-later, which is compatible. This file is
7+
# distributed under the same terms; it comes with NO WARRANTY, to the extent
8+
# permitted by law. See the GNU General Public License for more details.
199
#
2010
# Note that these fixtures are only used for the OMERO server tests.
2111
import os
@@ -35,7 +25,7 @@
3525
DEFAULT_OMERO_HOST = "localhost"
3626
DEFAULT_OMERO_WEB_HOST = "http://localhost:4080"
3727
DEFAULT_OMERO_PORT = "4064"
38-
DEFAULT_OMERO_SECURE = 1
28+
DEFAULT_OMERO_SECURE = True
3929

4030
# [[group, permissions], ...]
4131
GROUPS_TO_CREATE = [["test_group_1", "read-only"], ["test_group_2", "read-only"]]
@@ -77,7 +67,7 @@ def pytest_addoption(parser):
7767
parser.addoption(
7868
"--omero-secure",
7969
action="store",
80-
default=bool(os.environ.get("OMERO_SECURE", DEFAULT_OMERO_SECURE)),
70+
default=os.environ.get("OMERO_SECURE", DEFAULT_OMERO_SECURE),
8171
)
8272

8373

@@ -89,7 +79,14 @@ def omero_params(request):
8979
host = request.config.getoption("--omero-host")
9080
web_host = request.config.getoption("--omero-web-host")
9181
port = request.config.getoption("--omero-port")
92-
secure = request.config.getoption("--omero-secure")
82+
secure_opt = request.config.getoption("--omero-secure")
83+
# the option default is a real bool, but an OMERO_SECURE env var arrives as
84+
# a string ("0"/"false" should mean False), so coerce explicitly.
85+
secure = (
86+
secure_opt
87+
if isinstance(secure_opt, bool)
88+
else str(secure_opt).strip().lower() in ("1", "true", "yes")
89+
)
9390
return (user, password, host, web_host, port, secure)
9491

9592

@@ -205,7 +202,7 @@ def users_groups(conn, omero_params):
205202

206203
@pytest.fixture(scope="session")
207204
def conn(omero_params):
208-
user, password, host, web_host, port, secure = omero_params
205+
user, password, host, _web_host, port, secure = omero_params
209206
conn = BlitzGateway(user, password, host=host, port=port, secure=secure)
210207
conn.connect()
211208
yield conn

tests/server/test_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_server_connection(conn):
88
def test_omero_browser_login(make_napari_viewer, omero_params, qtbot):
99
from napari_omero import OMEROWidget
1010

11-
user, password, host, web_host, port, secure = omero_params
11+
user, password, host, _web_host, port, _secure = omero_params
1212

1313
viewer = make_napari_viewer()
1414
widget = OMEROWidget()

0 commit comments

Comments
 (0)