Skip to content

Commit

Permalink
Test each backend for relocatability (#4288)
Browse files Browse the repository at this point in the history
* Test each backend for relocatability

* different bash syntax

* `@info` to see hangs

* add Electron for WGLMakie

* don't swallow stdout and stderr when executing app

* enable color so output is easier to read

* fix WGLMakie

* Update relocatability.jl

* revert using checkout commit and dev instead

---------

Co-authored-by: Simon <sdanisch@protonmail.com>
  • Loading branch information
jkrumbiegel and SimonDanisch authored Oct 24, 2024
1 parent 06c986d commit 445d7ae
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/relocatability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -31,6 +31,10 @@ jobs:
- ubuntu-20.04
arch:
- x64
backend:
- GLMakie
- WGLMakie
- CairoMakie
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -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
35 changes: 26 additions & 9 deletions relocatability.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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

0 comments on commit 445d7ae

Please sign in to comment.