Skip to content

Unit Testing and Deployment #560

Unit Testing and Deployment

Unit Testing and Deployment #560

name: Unit Testing and Deployment
# zizmor ignore note: All caching for pushes to main should be disabled with the `USE_CACHE` env var
on: # zizmor: ignore[cache-poisoning]
pull_request:
merge_group:
workflow_dispatch:
schedule:
- cron: "0 4 * * *"
push:
tags:
- "*"
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ALLOW_PLOTTING: true
SHELLOPTS: "errexit:pipefail"
PYTEST_ADDOPTS: "--color=yes"
USE_CACHE: ${{
(
(github.event_name == 'workflow_dispatch' && github.event.inputs.cache == 'true') ||
(github.event_name == 'pull_request') ||
(github.event_name == 'push')
) &&
!startsWith(github.ref, 'refs/tags/v') &&
!startsWith(github.ref, 'refs/heads/release/') &&
!startsWith(github.ref, 'refs/heads/main')
}}
permissions:
id-token: none
jobs:
macOS:
name: Mac OS Unit Testing
strategy:
fail-fast: false
matrix:
config:
- { os: macos-13, python-version: "3.9" }
- { os: macos-14, python-version: "3.10" }
- { os: macos-latest, python-version: "3.11" }
- { os: macos-latest, python-version: "3.12" }
- { os: macos-latest, python-version: "3.13" }
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.config.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python-version }}
if: env.USE_CACHE == 'true'
cache: "pip"
- name: Install PyVista test dependencies
run: |
pip install --upgrade pip
pip install . --group test
- name: Report
run: python -c "import pyvista;print(pyvista.Report(gpu=False));from pyvista import examples;print('User data path:', examples.USER_DATA_PATH)"
- name: Test Core API
run: pytest -v --ignore=tests/plotting
- name: Test Plotting
if: always()
run: pytest -v tests/plotting --fail_extra_image_cache --generated_image_dir debug_images
- name: Upload Generated Images
if: always()
uses: actions/upload-artifact@v4
with:
name: debug_images-${{ github.job }}-${{ join(matrix.config.* , '-') }}
path: debug_images
Linux:
name: Linux Unit Testing
runs-on: ubuntu-22.04
strategy:
fail-fast: false
# see discussion at https://github.com/pyvista/pyvista/issues/2867
matrix:
include:
# numeric numpy versions are ~= conditions, e.g. "1.23" means "numpy~=1.23.0"
- python-version: "3.9"
vtk-version: "9.0.3" # Requires numpy~=1.23
numpy-version: "1.23"
- python-version: "3.9"
vtk-version: "9.1"
numpy-version: "1.26" # Test numpy 1.26
- python-version: "3.10"
vtk-version: "9.2.2"
numpy-version: "latest"
- python-version: "3.11"
vtk-version: "9.2.6"
numpy-version: "latest"
- python-version: "3.12"
vtk-version: "9.3.1"
numpy-version: "latest"
- python-version: "3.13"
vtk-version: "9.4.2"
numpy-version: "latest"
- python-version: "3.13"
vtk-version: "latest"
numpy-version: "nightly"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- uses: actions/cache@v4
with:
path: ~/.local/share/pyvista/examples
key: Examples-1-${{ hashFiles('*') }}
restore-keys: |
Examples-1-
- name: Build wheel and install pyvista
run: |
pip install build
python -m build --wheel
pip install dist/pyvista*.whl
- name: Set up vtk
if: ${{ matrix.vtk-version != 'latest' }}
run: pip install vtk==${{ matrix.vtk-version }}
# Make sure PyVista does not break from non-core dependencies
- name: Software Report (Core Dependencies)
run: python -c "import pyvista; print(pyvista.Report());"
- name: Install Testing Requirements
run: |
pip install --upgrade pip
pip install . --group test
- name: Set up numpy
if: ${{ matrix.numpy-version != 'latest' && matrix.numpy-version != 'nightly' }}
run: pip install 'numpy~=${{ matrix.numpy-version }}.0'
- name: Limit Matplotlib for VTK<9.2.2
if: ${{ matrix.vtk-version == '9.1' || matrix.vtk-version == '9.0.3' }}
run: pip install 'matplotlib<3.6'
- name: Install latest numpy 2.0 beta/rc
if: ${{ matrix.numpy-version == 'nightly' }}
run: |
pip uninstall numpy matplotlib -y
pip install --pre --no-deps -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple matplotlib
pip install --pre --no-deps -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- name: Core Testing (no GL)
run: python -m pytest --cov=pyvista --cov-branch -v --ignore=tests/plotting
- uses: awalsh128/[email protected]
if: always()
with:
packages: xvfb
version: 3.0
- name: Software Report (Plotting Dependencies)
if: always()
run: xvfb-run -a python -c "import pyvista; print(pyvista.Report());"
- name: Plotting Testing (uses GL)
if: always()
run: xvfb-run -a python -m pytest tests/plotting --cov=pyvista --cov-append --cov-report=xml --cov-branch --fail_extra_image_cache -v --generated_image_dir debug_images
- name: Upload Generated Images
if: always()
uses: actions/upload-artifact@v4
with:
name: debug_images-${{ github.job }}-${{ join(matrix.* , '-') }}
path: debug_images
- name: Software Report
if: always()
run: |
xvfb-run -a python -c "import pyvista; print(pyvista.Report()); from pyvista import examples; print('User data path:', examples.USER_DATA_PATH)"
which python
pip list
- uses: codecov/codecov-action@v4
name: "Upload coverage to CodeCov"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Check package
run: |
pip install build twine
python -m build
twine check --strict dist/*
- name: Upload to PyPi
if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/v')
run: |
twine upload --skip-existing dist/pyvista*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TWINE_REPOSITORY_URL: "https://upload.pypi.org/legacy/"
windows:
name: Windows Unit Testing
runs-on: windows-latest
env:
CI_WINDOWS: true
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set up headless display
uses: pyvista/[email protected]
- name: Install PyVista test dependencies
run: |
python -m pip install --upgrade pip
pip install . --group test
- name: Report
run: python -c "import pyvista; print(pyvista.Report(gpu=False)); from pyvista import examples; print('User data path:', examples.USER_DATA_PATH)"
- name: Set example data path as env variable
run: |
chcp 65001 #set code page to utf-8
echo ("PYVISTA_EXAMPLE_DATA_PATH=" + $(python -c "import pyvista; from pyvista import examples; print(examples.USER_DATA_PATH)")) >> $env:GITHUB_ENV
- name: Cache example data
uses: actions/cache@v4
with:
path: ${{ env.PYVISTA_EXAMPLE_DATA_PATH }}
key: Examples-1-${{ hashFiles('*') }}
restore-keys: |
Examples-1-
- name: Test Core API
run: python -m pytest -v --ignore=tests/plotting
- name: Test Plotting
if: always()
run: python -m pytest -v tests/plotting --fail_extra_image_cache --generated_image_dir debug_images
- name: Upload Generated Images
if: always()
uses: actions/upload-artifact@v4
with:
name: debug_images-${{ github.job }}-${{ join(matrix.* , '-') }}
path: debug_images