diff --git a/.github/workflows/relocatability.yml b/.github/workflows/relocatability.yml index d3e62f5c33f..7f333b57670 100644 --- a/.github/workflows/relocatability.yml +++ b/.github/workflows/relocatability.yml @@ -17,8 +17,8 @@ concurrency: cancel-in-progress: true jobs: - glmakie: - name: GLMakie relocatability + makie-relocatability: + name: Relocatability ${{ matrix.backend }} env: MODERNGL_DEBUGGING: "true" # turn on errors when running OpenGL tests runs-on: ${{ matrix.os }} @@ -31,6 +31,10 @@ jobs: - ubuntu-20.04 arch: - x64 + backend: + - GLMakie + - WGLMakie + - CairoMakie steps: - name: Checkout uses: actions/checkout@v4 @@ -39,7 +43,13 @@ jobs: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - uses: julia-actions/cache@v2 - - 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 xsettingsd x11-xserver-utils + - name: Install dependencies for GPU backends + if: matrix.backend != 'CairoMakie' + 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 xsettingsd x11-xserver-utils - name: Relocatability test - run: > - DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia ./relocatability.jl + run: | + if [ "${{ matrix.backend }}" != "CairoMakie" ]; then + DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --color=yes ./relocatability.jl ${{ matrix.backend }} + else + julia --color=yes ./relocatability.jl ${{ matrix.backend }} + fi \ No newline at end of file diff --git a/relocatability.jl b/relocatability.jl index b036ef4903f..6977bdd8eff 100644 --- a/relocatability.jl +++ b/relocatability.jl @@ -1,11 +1,22 @@ - +const BACKEND = ARGS[1] +@assert BACKEND in ["CairoMakie", "GLMakie", "WGLMakie"] module_src = """ module MakieApp -using GLMakie +using $BACKEND + +if "$BACKEND" == "WGLMakie" + using Electron + function _display(fig) + disp = WGLMakie.Bonito.use_electron_display() + display(disp, WGLMakie.Bonito.App(fig)) + end +else + _display(fig) = display(fig) +end function julia_main()::Cint - screen = display(scatter(1:4)) + screen = _display(scatter(1:4)) # wait(screen) commented out to test if this blocks anything, but didn't change anything return 0 # if things finished successfully end @@ -21,14 +32,15 @@ Pkg.generate("MakieApp") Pkg.activate("MakieApp") makie_dir = @__DIR__ -commit = cd(makie_dir) do - chomp(read(`git rev-parse --verify HEAD`, String)) -end # Add packages from branch, to make it easier to move the code later (e.g. when running this locally) # Since, package dir is much easier to move then the active project (on windows at least). -paths = ["MakieCore", "Makie", "GLMakie"] -Pkg.add(map(x -> (; name=x, rev=commit), paths)) +paths = ["MakieCore", "", BACKEND] +Pkg.develop(map(x -> (; path=joinpath(makie_dir, x)), paths)) + +if BACKEND == "WGLMakie" + pkg"add Electron@5.1" +end open("MakieApp/src/MakieApp.jl", "w") do io print(io, module_src) @@ -44,14 +56,19 @@ exe = joinpath(pwd(), "executable", "bin", "MakieApp") # `run` allows to see potential informative printouts, `success` swallows those p = run(`$(exe)`) @test p.exitcode == 0 + julia_pkg_dir = joinpath(Base.DEPOT_PATH[1], "packages") @test isdir(julia_pkg_dir) mvd_julia_pkg_dir = julia_pkg_dir * ".old" -mv(julia_pkg_dir, mvd_julia_pkg_dir, force = true) +new_makie_dir = makie_dir * ".old" +mv(julia_pkg_dir, mvd_julia_pkg_dir; force=true) +mv(makie_dir, new_makie_dir; force=true) # Move package dir so that we can test relocatability (hardcoded paths to package dir being invalid now) try + @info "Running executable in relocated mode..." p2 = run(`$(exe)`) @test p2.exitcode == 0 finally mv(mvd_julia_pkg_dir, julia_pkg_dir) + mv(new_makie_dir, makie_dir) end