Skip to content
Merged
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
103 changes: 62 additions & 41 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# 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:
push:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v*"
pull_request:
branches:
- main
Expand All @@ -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"]
Comment thread
C-Achard marked this conversation as resolved.

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/*
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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]
Expand Down