Skip to content

Commit 533a0ce

Browse files
authored
Enhance GitHub Actions CI and deploy workflow (#122)
* Enhance GitHub Actions CI and deploy workflow 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. * Fix missing OSs in tox.ini
1 parent e0b7c98 commit 533a0ce

2 files changed

Lines changed: 63 additions & 42 deletions

File tree

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
41
name: test and deploy
52

63
on:
74
push:
85
branches:
96
- main
107
tags:
11-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
8+
- "v*"
129
pull_request:
1310
branches:
1411
- main
@@ -18,76 +15,100 @@ jobs:
1815
test:
1916
name: ${{ matrix.platform }} py${{ matrix.python-version }}
2017
runs-on: ${{ matrix.platform }}
18+
2119
strategy:
20+
fail-fast: false
2221
matrix:
23-
# platform: [ubuntu-latest, windows-latest] # , macos-latest
24-
platform: [ubuntu-latest]
25-
python-version: ['3.8', '3.9'] #issues with monai and 3.10; pausing for now. users should use python 3.9
22+
platform: [ubuntu-latest, windows-latest, macos-latest]
23+
python-version: ["3.10", "3.11", "3.12"]
2624

2725
steps:
28-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v6
2927

3028
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v6
3230
with:
3331
python-version: ${{ matrix.python-version }}
32+
cache: pip
3433

35-
# these libraries enable testing on Qt on linux
36-
- uses: tlambert03/setup-qt-libs@v1
34+
- name: Install Qt libraries on Linux
35+
if: runner.os == 'Linux'
36+
uses: tlambert03/setup-qt-libs@v1
3737

38-
# strategy borrowed from vispy for installing opengl libs on windows
3938
- name: Install Windows OpenGL
4039
if: runner.os == 'Windows'
40+
shell: pwsh
4141
run: |
4242
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
43-
powershell gl-ci-helpers/appveyor/install_opengl.ps1
44-
if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1}
45-
46-
# note: if you need dependencies from conda, considering using
47-
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
48-
# and
49-
# tox-conda: https://github.com/tox-dev/tox-conda
50-
- name: Install dependencies
43+
./gl-ci-helpers/appveyor/install_opengl.ps1
44+
if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {
45+
exit 0
46+
} else {
47+
exit 1
48+
}
49+
50+
- name: Install tox
5151
run: |
5252
python -m pip install --upgrade pip
53-
python -m pip install setuptools tox tox-gh-actions
54-
python -m pip install tifffile
55-
python -m pip install monai[nibabel,einops,tifffile]
56-
# pip install git+https://github.com/lucasb-eyer/pydensecrf.git@master#egg=pydensecrf
57-
58-
# this runs the platform-specific tests declared in tox.ini
59-
- name: Test with tox
60-
uses: GabrielBB/xvfb-action@v1 # aganders3/headless-gui@v1
53+
python -m pip install tox tox-gh-actions
54+
55+
- name: Test with tox on Linux
56+
if: runner.os == 'Linux'
57+
uses: GabrielBB/xvfb-action@v1
6158
with:
6259
run: python -m tox
6360
env:
6461
PLATFORM: ${{ matrix.platform }}
62+
QT_API: pyqt6
63+
PYTEST_QT_API: pyqt6
64+
VISPY_USE_APP: pyqt6
65+
QT_OPENGL: software
66+
PYVISTA_OFF_SCREEN: true
6567

66-
- name: Coverage
67-
uses: codecov/codecov-action@v2
68+
- name: Test with tox on Windows/macOS
69+
if: runner.os != 'Linux'
70+
run: python -m tox
71+
env:
72+
PLATFORM: ${{ matrix.platform }}
73+
QT_API: pyqt6
74+
PYTEST_QT_API: pyqt6
75+
VISPY_USE_APP: pyqt6
76+
QT_OPENGL: software
77+
PYVISTA_OFF_SCREEN: true
78+
79+
- name: Upload coverage
80+
uses: codecov/codecov-action@v6
81+
with:
82+
files: ./coverage.xml
83+
fail_ci_if_error: false
84+
env:
85+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6886

6987
deploy:
70-
# this will run when you have tagged a commit, starting with "v*"
71-
# and requires that you have put your twine API key in your
72-
# github secrets (see readme for details)
7388
needs: [test]
7489
runs-on: ubuntu-latest
75-
if: contains(github.ref, 'tags')
90+
if: startsWith(github.ref, 'refs/tags/v')
91+
7692
steps:
77-
- uses: actions/checkout@v2
93+
- uses: actions/checkout@v6
94+
7895
- name: Set up Python
79-
uses: actions/setup-python@v2
96+
uses: actions/setup-python@v6
8097
with:
8198
python-version: "3.x"
82-
- name: Install dependencies
99+
100+
- name: Install build tools
83101
run: |
84102
python -m pip install --upgrade pip
85-
pip install -U setuptools setuptools_scm wheel twine build
86-
- name: Build and publish
103+
python -m pip install build twine
104+
105+
- name: Build package
106+
run: |
107+
python -m build
108+
109+
- name: Publish to PyPI
87110
env:
88111
TWINE_USERNAME: __token__
89112
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
90113
run: |
91-
git tag
92-
python -m build .
93114
twine upload dist/*

‎tox.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# For more information about tox, see https://tox.readthedocs.io/en/latest/
22
[tox]
3-
envlist = py{310,311,312}-{linux}
3+
envlist = py{310,311,312}-{linux,windows,macos}
44
isolated_build=true
55

66
[gh-actions]

0 commit comments

Comments
 (0)