From 61dea0585b9b7acd716b113f4c38dc34fac29341 Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Tue, 19 May 2026 15:08:36 +0200 Subject: [PATCH 1/2] Enhance GitHub Actions CI and deploy workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modernize and expand the test-and-deploy workflow: bump action versions (checkout/setup-python), enable pip caching, and broaden the matrix to ubuntu, windows, and macos with Python 3.10–3.12. Add fail-fast:false and platform-specific steps (Linux Qt libs, Windows OpenGL with pwsh). Install tox centrally and run tests per-OS with appropriate Qt/PyQt and PyVista env vars; upload coverage with codecov v6. Adjust deploy job to trigger on semver-style tags (refs/tags/v*), update setup actions, split build and publish steps (build then twine upload), and simplify dependency installs. --- .github/workflows/test_and_deploy.yml | 103 ++++++++++++++++---------- 1 file changed, 62 insertions(+), 41 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index cb581b79..599b574c 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,6 +1,3 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - name: test and deploy on: @@ -8,7 +5,7 @@ on: branches: - main tags: - - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v*" pull_request: branches: - main @@ -18,76 +15,100 @@ jobs: test: name: ${{ matrix.platform }} py${{ matrix.python-version }} runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false matrix: -# platform: [ubuntu-latest, windows-latest] # , macos-latest - platform: [ubuntu-latest] - python-version: ['3.8', '3.9'] #issues with monai and 3.10; pausing for now. users should use python 3.9 + platform: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: pip -# these libraries enable testing on Qt on linux - - uses: tlambert03/setup-qt-libs@v1 + - name: Install Qt libraries on Linux + if: runner.os == 'Linux' + uses: tlambert03/setup-qt-libs@v1 -# strategy borrowed from vispy for installing opengl libs on windows - name: Install Windows OpenGL if: runner.os == 'Windows' + shell: pwsh run: | git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git - powershell gl-ci-helpers/appveyor/install_opengl.ps1 - if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1} - -# note: if you need dependencies from conda, considering using -# setup-miniconda: https://github.com/conda-incubator/setup-miniconda -# and -# tox-conda: https://github.com/tox-dev/tox-conda - - name: Install dependencies + ./gl-ci-helpers/appveyor/install_opengl.ps1 + if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) { + exit 0 + } else { + exit 1 + } + + - name: Install tox run: | python -m pip install --upgrade pip - python -m pip install setuptools tox tox-gh-actions - python -m pip install tifffile - python -m pip install monai[nibabel,einops,tifffile] -# pip install git+https://github.com/lucasb-eyer/pydensecrf.git@master#egg=pydensecrf - -# this runs the platform-specific tests declared in tox.ini - - name: Test with tox - uses: GabrielBB/xvfb-action@v1 # aganders3/headless-gui@v1 + python -m pip install tox tox-gh-actions + + - name: Test with tox on Linux + if: runner.os == 'Linux' + uses: GabrielBB/xvfb-action@v1 with: run: python -m tox env: PLATFORM: ${{ matrix.platform }} + QT_API: pyqt6 + PYTEST_QT_API: pyqt6 + VISPY_USE_APP: pyqt6 + QT_OPENGL: software + PYVISTA_OFF_SCREEN: true - - name: Coverage - uses: codecov/codecov-action@v2 + - name: Test with tox on Windows/macOS + if: runner.os != 'Linux' + run: python -m tox + env: + PLATFORM: ${{ matrix.platform }} + QT_API: pyqt6 + PYTEST_QT_API: pyqt6 + VISPY_USE_APP: pyqt6 + QT_OPENGL: software + PYVISTA_OFF_SCREEN: true + + - name: Upload coverage + uses: codecov/codecov-action@v6 + with: + files: ./coverage.xml + fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} deploy: -# this will run when you have tagged a commit, starting with "v*" -# and requires that you have put your twine API key in your -# github secrets (see readme for details) needs: [test] runs-on: ubuntu-latest - if: contains(github.ref, 'tags') + if: startsWith(github.ref, 'refs/tags/v') + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 + - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: "3.x" - - name: Install dependencies + + - name: Install build tools run: | python -m pip install --upgrade pip - pip install -U setuptools setuptools_scm wheel twine build - - name: Build and publish + python -m pip install build twine + + - name: Build package + run: | + python -m build + + - name: Publish to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} run: | - git tag - python -m build . twine upload dist/* From 6cc0c7529aa4908693a653e246949089c56ba3bd Mon Sep 17 00:00:00 2001 From: Cyril Achard Date: Tue, 19 May 2026 15:16:33 +0200 Subject: [PATCH 2/2] Fix missing OSs in tox.ini --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index da1b2b10..36307e3f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ # For more information about tox, see https://tox.readthedocs.io/en/latest/ [tox] -envlist = py{310,311,312}-{linux} +envlist = py{310,311,312}-{linux,windows,macos} isolated_build=true [gh-actions]