CI fails to build GLMakie dependency

I am trying to set up a CI pipeline for a package that depends on GLMakie. So far this fails with

ERROR: LoadError: Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to /home/runner/.julia/compiled/v1.7/GLMakie/jl_hvqBqq.

See: Next try · aenarete/KiteViewers.jl@0eb844c · GitHub

How can I fix that?

My current CI.yml: KiteViewers.jl/CI.yml at main · aenarete/KiteViewers.jl · GitHub

The warning in the log is pretty clear:

┌ Warning:     OpenGL/GLFW wasn't loaded correctly or couldn't be initialized.
│     This likely means, you're on a headless server without having OpenGL support setup correctly.
│     Have a look at the troubleshooting section in the readme:
│     https://github.com/JuliaPlots/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
└ @ GLMakie ~/.julia/packages/GLMakie/pFGSp/src/gl_backend.jl:4

You’ll need, at least, to deploy an X server with sofware GL rendering. Look for xvfb in the Makie CI scripts, Makie.jl/glmakie.yaml at 3e4ae3227f3eb4bb507627cd8e41a0850a515f44 · JuliaPlots/Makie.jl · GitHub.

But I did:

      - run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev

Figured it out. Using the following three lines it works.

      - run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
      - run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project -e 'using Pkg; Pkg.instantiate()'
      - run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project -e "using TestEnv; TestEnv.activate(); include(\"test/runtests.jl\")"

Well, on Linux. Any chance to make this work on Windows or Mac?