CI/CD for package that requires X server

Hi all,
I am trying to add CI/CD for a package that requires X server:
https://github.com/omlins/JustSayIt.jl
Concretely, it is the Python dependency pynput that requires it. Does anybody have some suggestions on how to setup CI/CD in such a case?

It fails with the error message failed to acquire X connection: Bad display name and suggests to make sure that you have an X server running, and that the DISPLAY environment variable is set correctly'.

The full error is found at the end of this post and the full CI/CD report is here:
https://github.com/omlins/JustSayIt.jl/runs/5994275217?check_suite_focus=true

Thanks a lot for any help!!


Full error:

      Testing Running tests...
[ Info: Running `conda config --set pip_interop_enabled true --file /home/runner/.julia/conda/3/condarc-julia.yml` in root environment
[ Info: Running `pip install pynput` in root environment
Collecting pynput
  Downloading pynput-1.7.6-py2.py3-none-any.whl (89 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 89.2/89.2 KB 5.7 MB/s eta 0:00:00
Requirement already satisfied: six in /home/runner/.julia/conda/3/lib/python3.9/site-packages (from pynput) (1.16.0)
Collecting python-xlib>=0.17
  Downloading python_xlib-0.31-py2.py3-none-any.whl (179 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 179.0/179.0 KB 19.2 MB/s eta 0:00:00
Collecting evdev>=1.3
  Downloading evdev-1.5.0.tar.gz (26 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: evdev
  Building wheel for evdev (setup.py): started
  Building wheel for evdev (setup.py): finished with status 'done'
  Created wheel for evdev: filename=evdev-1.5.0-cp39-cp39-linux_x86_64.whl size=45646 sha256=c1127bbce79d345001d2716882561405afc2c0335ab6e8ab118473857193a606
  Stored in directory: /home/runner/.cache/pip/wheels/54/df/1f/13ea2086d1ed715655e527c387e8a010670588f262bedf4beb
Successfully built evdev
Installing collected packages: evdev, python-xlib, pynput
Successfully installed evdev-1.5.0 pynput-1.7.6 python-xlib-0.31
ERROR: LoadError: InitError: PyError (PyImport_ImportModule

The Python package pynput could not be imported by pyimport. Usually this means
that you did not install pynput in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the pynput module, you can
use `pyimport_conda("pynput", PKG)`, where PKG is the Anaconda
package that contains the module pynput, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ImportError'>
ImportError('this platform is not supported: (\'failed to acquire X connection: Bad display name ""\', DisplayNameError(\'\'))\n\nTry one of the following resolutions:\n\n * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly')
  File "/home/runner/.julia/conda/3/lib/python3.9/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/home/runner/.julia/conda/3/lib/python3.9/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/home/runner/.julia/conda/3/lib/python3.9/site-packages/pynput/_util/__init__.py", line 76, in backend
    raise ImportError('this platform is not supported: {}'.format(

Stacktrace:
  [1] pyimport(name::String)
    @ PyCall ~/.julia/packages/PyCall/7a7w0/src/PyCall.jl:550

Try using xvfb-run: https://github.com/JuliaGraphics/Gtk.jl/blob/69c108069e9b3147841da7fb539dc9a4a0bedfc6/.github/workflows/ci.yml#L30. To be clear, you also need to actually pass prefix to the julia-actions/julia-runtest workflow: https://github.com/JuliaGraphics/Gtk.jl/blob/69c108069e9b3147841da7fb539dc9a4a0bedfc6/.github/workflows/ci.yml#L54-L56

Thanks I’ll try what was done in the repo you link ASAP!

That worked, thanks!