Unit Testing and Deployment #96
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit Testing and Deployment | |
on: | |
pull_request: | |
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' | |
jobs: | |
macOS: | |
runs-on: macos-latest | |
name: Mac OS Unit Testing | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.11'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
requirements_test.txt | |
- name: Install PyVista | |
run: pip install . --no-deps | |
- name: Install test dependencies | |
run: pip install vtk -r requirements_test.txt | |
- 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 | |
run: pytest -v tests/plotting --fail_extra_image_cache | |
LinuxConda: | |
runs-on: ubuntu-20.04 | |
if: false | |
env: | |
CONDA_ALWAYS_YES: 1 | |
conda_env: pyvista-vtk | |
DISPLAY: ':99.0' | |
PYVISTA_OFF_SCREEN: True | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up headless display | |
uses: pyvista/setup-headless-display-action@v2 | |
- name: Cache Conda Packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/anaconda3/pkgs | |
key: Conda-${{ runner.os }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda- | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.local/share/pyvista/examples | |
key: Examples-1-${{ hashFiles('*') }} | |
restore-keys: | | |
Examples-1- | |
# See: https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community | |
- name: Install mamba | |
run: | | |
source /usr/share/miniconda/etc/profile.d/conda.sh | |
conda config --set channel_priority strict | |
conda update -n base conda | |
conda install -n base conda-libmamba-solver | |
- name: 'Workaround for mamba-org/mamba#488' | |
run: rm /usr/share/miniconda/pkgs/cache/*.json | |
- name: Create Anaconda environment | |
run: | | |
source /usr/share/miniconda/etc/profile.d/conda.sh | |
conda config --add channels conda-forge | |
conda env create --quiet -n ${{ env.conda_env }} --file environment.yml --experimental-solver=libmamba | |
conda activate ${{ env.conda_env }} | |
conda list | |
- name: Install PyVista | |
run: | | |
source /usr/share/miniconda/etc/profile.d/conda.sh | |
conda activate ${{ env.conda_env }} | |
pip install -e . | |
which python | |
python -c "import pyvista; print(pyvista.Report(gpu=False))" | |
python -c "from pyvista import examples; print(examples.USER_DATA_PATH)" | |
- name: Test Core API | |
run: | | |
source /usr/share/miniconda/etc/profile.d/conda.sh | |
conda activate ${{ env.conda_env }} | |
pip install -r requirements_test.txt | |
pytest -v --ignore=tests/plotting | |
- name: Test Core Plotting | |
run: | | |
source /usr/share/miniconda/etc/profile.d/conda.sh | |
conda activate ${{ env.conda_env }} | |
pytest -v tests/plotting --cov-report html --fail_extra_image_cache | |
Linux: | |
name: Linux Unit Testing | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
# see discussion at https://github.com/pyvista/pyvista/issues/2867 | |
matrix: | |
include: | |
- python-version: '3.8' | |
vtk-version: '9.0.3' # Requires numpy<1.24 | |
- python-version: '3.9' | |
vtk-version: '9.1' | |
- python-version: '3.10' | |
vtk-version: '9.2.2' | |
- python-version: '3.11' | |
vtk-version: '9.2.6' | |
- python-version: '3.12' | |
vtk-version: 'latest' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
requirements_test.txt | |
- uses: actions/cache@v3 | |
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 -r requirements_test.txt | |
- name: Limit NumPy for VTK 9.0.3 | |
if: ${{ matrix.vtk-version == '9.0.3' }} | |
run: pip install 'numpy<1.24' | |
- 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: Core Testing (no GL) | |
run: python -m pytest --cov=pyvista -v tests/core tests/examples | |
- uses: awalsh128/cache-apt-pkgs-action@v1.1.3 | |
with: | |
packages: libgl1-mesa-glx xvfb | |
version: 3.0 | |
- name: Plotting Testing (uses GL) | |
run: xvfb-run -a python -m pytest --cov=pyvista --cov-append --cov-report=xml --fail_extra_image_cache -v --ignore=tests/core --ignore=tests/examples | |
- 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@v3 | |
name: 'Upload coverage to CodeCov' | |
- 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.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
requirements_test.txt | |
- name: Set up headless display | |
uses: pyvista/setup-headless-display-action@v2 | |
- name: Install PyVista | |
run: pip install . --no-deps | |
- name: Install test dependencies | |
run: pip install vtk -r requirements_test.txt | |
- 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@v3 | |
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 | |
run: python -m pytest -v tests/plotting --fail_extra_image_cache |