'Running a GUI application on a CI service without X11

I have a GUI application that I would like to set up testing for via GitHub Actions. I already have it set up so that GitHub Actions compiles the application on Ubuntu, but now what I would like to do is run the application for a few seconds and test if it crashes or not. However, currently it fails to start because there is no X11 server installed.

Is there a way that I can install a dummy X11 server, so that the application runs? I don't care about what is actually displayed, I just want the application to be able to open without failing due to the X11 server missing.

Alternatively, is there a way to install a dummy Wayland server? This app can also run on Wayland.



Solution 1:[1]

You can try xvfb-run from Xvfb project. It starts your application(s) under fully compatible X Window server w/o any hardware (you can even run x11vnc among your apps and connect to the server over VNC, but I believe it's not your case for now). Personally I use xvfb-run for isolated screenless X.org-aware packages build, when, e. g., a package needs to take a snapshot of itself while making documentation.

$ xvfb-run x.org_application_binary

Solution 2:[2]

I use this command:

  linux:
    runs-on: ubuntu-latest

    steps:
        run: |
          export DISPLAY=:99
          sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
          mycommand

Solution 3:[3]

Yes, that is possible. Simply create a Docker Image with your X11 environment and deploy your application in it.

Alternatively, you can also just install X11 on your machine. Make sure to do it in every run, as the environments always fully reset:

sudo apt-get install xorg openbox

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FrBrGeorge
Solution 2 User Rebo
Solution 3 Meiswjn