diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml new file mode 100644 index 00000000..7c4f64d5 --- /dev/null +++ b/.github/workflows/publish_pypi.yml @@ -0,0 +1,20 @@ +--- +name: PyPI +on: push + +jobs: + build-n-publish: + name: Build and publish Python distribution to PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Build a binary wheel and a source tarball + run: | + python -mpip install wheel + python setup.py sdist bdist_wheel + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@v1.3.0 + with: + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 00000000..4f6062c3 --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,32 @@ +--- +name: Tox +on: + push: + pull_request: + +jobs: + test: + name: Run tox tests + strategy: + fail-fast: false + matrix: + python-version: + - '3.6' + - '3.7' + - '3.8' + - '3.9' + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: python -mpip install --upgrade wheel pytest tox + - name: Get tox target + id: toxtarget + run: | + py=$(echo ${{ matrix.python-version }} | tr -d .) + echo "::set-output name=py::$py" + - name: Run tests + run: tox -e py${{ steps.toxtarget.outputs.py }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d6f56655..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -language: python -dist: bionic -sudo: required -python: 3.6 - -before_install: - - pip3 install https://github.com/ome/zeroc-ice-ubuntu1804/releases/download/0.3.0/zeroc_ice-3.6.5-cp36-cp36m-linux_x86_64.whl - - pip3 install omero-py - - pip3 install flake8 - - pip3 install -U setuptools - - flake8 . - -script: - - python3 setup.py test --pytest-args='-v -v' - - python3 setup.py sdist install --record files.txt - - python3 -c 'import omero.clients; import omero_marshal.encode' - - cat files.txt | xargs rm -rf - - python3 setup.py bdist_egg - - easy_install dist/*.egg - - python3 -c 'import omero.clients; import omero_marshal.encode' - -deploy: - provider: pypi - user: $PYPI_USER - password: $PYPI_PASSWORD - distributions: sdist bdist_wheel - on: - tags: true diff --git a/README.rst b/README.rst index 1a820b2d..8656f32a 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -.. image:: https://travis-ci.org/ome/omero-marshal.png - :target: https://travis-ci.org/ome/omero-marshal +.. image:: https://github.com/ome/omero-marshal/workflows/Tox/badge.svg + :target: https://github.com/ome/omero-marshal/actions .. image:: https://img.shields.io/pypi/v/omero-marshal.svg :alt: PyPI diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 008bae10..e227794a 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -484,7 +484,7 @@ def roi_with_shapes_and_annotations(roi, ellipse, rectangle): return roi -def populate_shape(o, set_unit_attributes=True): +def populate_shape(o, transform, set_unit_attributes=True): o.fillColor = rint(0xffffffff) o.fillRule = rstring('solid') o.fontFamily = rstring('cursive') @@ -503,11 +503,10 @@ def populate_shape(o, set_unit_attributes=True): o.theC = rint(1) o.theT = rint(2) o.theZ = rint(3) - t = identity_transform() if SCHEMA_VERSION == '2015-01': - o.transform = t.svg_transform + o.transform = transform.svg_transform else: - o.transform = t + o.transform = transform return o @@ -576,9 +575,9 @@ def scale_transform(): @pytest.fixture() -def ellipse(): +def ellipse(identity_transform): o = EllipseI() - populate_shape(o) + populate_shape(o, identity_transform) if SCHEMA_VERSION == '2015-01': o.cx = rdouble(1.0) o.cy = rdouble(2.0) @@ -594,16 +593,16 @@ def ellipse(): @pytest.fixture() -def ellipse_with_annotations(): - o = ellipse() +def ellipse_with_annotations(ellipse): + o = ellipse add_annotations(o) return o @pytest.fixture() -def rectangle(): +def rectangle(identity_transform): o = RectangleI() - populate_shape(o) + populate_shape(o, identity_transform) o.x = rdouble(1.0) o.y = rdouble(2.0) o.width = rdouble(3.0) @@ -613,9 +612,9 @@ def rectangle(): @pytest.fixture() -def point(): +def point(identity_transform): o = PointI() - populate_shape(o) + populate_shape(o, identity_transform) if SCHEMA_VERSION == '2015-01': o.cx = rdouble(1.0) o.cy = rdouble(2.0) @@ -627,9 +626,9 @@ def point(): @pytest.fixture() -def label(): +def label(identity_transform): o = LabelI() - populate_shape(o) + populate_shape(o, identity_transform) o.x = rdouble(1.0) o.y = rdouble(2.0) o.id = rlong(7) @@ -637,9 +636,9 @@ def label(): @pytest.fixture() -def polyline(): +def polyline(identity_transform): o = PolylineI() - populate_shape(o) + populate_shape(o, identity_transform) o.points = rstring('0,0 1,2 3,5') if SCHEMA_VERSION != '2015-01': o.setMarkerStart('Arrow') @@ -649,18 +648,18 @@ def polyline(): @pytest.fixture() -def polygon(): +def polygon(identity_transform): o = PolygonI() - populate_shape(o) + populate_shape(o, identity_transform) o.points = rstring('0,0 1,2 3,5') o.id = rlong(5) return o @pytest.fixture() -def line(): +def line(identity_transform): o = LineI() - populate_shape(o) + populate_shape(o, identity_transform) o.setX1(0) o.setY1(0) o.setX2(1) @@ -673,9 +672,9 @@ def line(): @pytest.fixture() -def opt_unit_label(): +def opt_unit_label(identity_transform): o = LabelI() - populate_shape(o, False) + populate_shape(o, identity_transform, False) o.x = rdouble(1.0) o.y = rdouble(2.0) o.id = rlong(7) @@ -683,9 +682,9 @@ def opt_unit_label(): @pytest.fixture() -def mask(): +def mask(identity_transform): o = MaskI() - populate_shape(o) + populate_shape(o, identity_transform) o.x = rdouble(0.0) o.y = rdouble(0.0) o.width = rdouble(1.0) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..48a575bb --- /dev/null +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = py36, py37, py38, py39 +# https://tox.readthedocs.io/en/latest/config.html#conf-requires +# Ensure pip is new enough +requires = pip >= 19.0.0 + virtualenv >= 16.0.0 + +[testenv] +# For environment markers see +# https://www.python.org/dev/peps/pep-0508/#environment-markers +deps = + flake8 + omero-py + pytest-rerunfailures + pytest-xdist + restructuredtext-lint + https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.1.0/zeroc_ice-3.6.5-cp36-cp36m-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.6" + https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.1.0/zeroc_ice-3.6.5-cp37-cp37m-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.7" + https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.1.0/zeroc_ice-3.6.5-cp38-cp38-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.8" + https://github.com/ome/zeroc-ice-py-github-ci/releases/download/0.1.0/zeroc_ice-3.6.5-cp39-cp39-linux_x86_64.whl; platform_system=="Linux" and python_version=="3.9" +commands = + rst-lint README.rst + flake8 . + python setup.py sdist install --record files.txt + python -c 'import omero.clients; import omero_marshal.encode' + pytest {posargs:-n4 -rf tests -s} + sh -c 'cat files.txt | xargs rm -rf' + python setup.py bdist_egg + sh -c 'easy_install dist/*.egg' + python -c 'import omero.clients; import omero_marshal.encode'