Setup a headless display on Linux and Windows (not needed on MacOS)
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v3name: Tests that require virtual display
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: pyvista/setup-headless-display-action@v3-
qt(defaultfalse): set totrueto install libraries required for Qt on Linux, e.g.:- uses: pyvista/setup-headless-display-action@v3 with: qt: true
-
pyvista(defaulttrue): set tofalseif you don't want to set env vars to use PyVista in offscreen mode. -
wm(defaultfalse): Installs and starts a window manager on Linux. Set toherbstluftwmfor a window manager on top of the Xvfb display, or towestonfor a headless Wayland session instead of Xvfb, e.g.:- uses: pyvista/setup-headless-display-action@v3 with: qt: true wm: weston
westonis the odd one out, because a Wayland compositor replaces the display server rather than running on top of one. It starts headless Weston on the GL renderer and exportsWAYLAND_DISPLAY,XDG_RUNTIME_DIR,XDG_SESSION_TYPE=wayland, andQT_QPA_PLATFORM=wayland, plusLIBGL_ALWAYS_SOFTWARE=1andGALLIUM_DRIVER=llvmpipebecause the runners have no GPU and a Wayland client cannot fall back to OSMesa the way an X11 one can. The compositor log is left at$WESTON_LOG.No X server is started in that mode and
DISPLAYis left unset, so a Qt binding missing its Wayland platform plugin fails loudly instead of quietly testing xcb.Only Linux is affected; on macOS and Windows this input is ignored.
-
mesa3d-release(default24.3.0): set to a specific release to install that version of Mesa3D. This is only applicable for Windows. For example, to install Mesa3D 21.2.5:- uses: pyvista/setup-headless-display-action@v3 with: mesa3d-release: 21.2.5
You can also use
latestto use the latest release version. -
install-mesa3d-offscreen(defaulttrue): installs the offscreen version of Mesa3D on Windows. This is only applicable for Windows. This will also set theVTK_DEFAULT_OPENGL_WINDOWenvironment variable tovtkOSOpenGLRenderWindowbased on the VTK Runtime settings For example:- uses: pyvista/setup-headless-display-action@v3 with: install-mesa3d-offscreen: true
name: Workflow that uses PyVista for plotting
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pyvista/setup-headless-display-action@v3
- uses: actions/setup-python@v5
with:
python-version: 3.12
- run: pip install pyvista
- run: python -c "import pyvista;pyvista.Sphere().plot(screenshot='${{ matrix.os }}-sphere.png')"
- uses: actions/upload-artifact@v4
with:
name: sphere
path: ${{ matrix.os }}-sphere.png