Xvfb makes fake X11 for CI

Continuous integration for program that plot or need a display can be tricky, since in many cases the CI doesn’t have an X11 display server. Workarounds include generating plots using xvfb dummy X11 display server. This maintains code coverage, and may allow dumping plots to disk for further checks

Xvfb

This method uses X server virtual framebuffer (Xvfb) on continuous integration services.

GitHub Actions

Add to the “.github/workflows/ci.yml”, and assuming the project uses PyTest, the xvfb-action enables Xvfb for that command:

- name: Run headless test
  uses: GabrielBB/xvfb-action@v1
  with:
    run: pytest

Travis-CI

Travis-CI supports Xvfb by adding to project “.travis.yml”:

services: xvfb

Detect CI in Python via environment variable