mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-10-18 13:41:52 +02:00
ci: fix snap smoke test
This commit is contained in:
1 parent
1f6ae40aca
commit
0160756c8e
2 files changed
+25
-12
No files matched your search
@@ -272,16 +272,26 @@ jobs:
|
||||
path: ${{ env.SNAP_FILE }}
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Prepare a user runtime directory
|
||||
# `snap run` moves the app into its own systemd scope and asks the
|
||||
# user's systemd for it. The runner has no user session, so the app died
|
||||
# with "... is not a snap cgroup". Lingering starts systemd --user and,
|
||||
# with dbus-user-session, its bus at /run/user/<uid>/bus.
|
||||
- name: Start a user session
|
||||
run: |
|
||||
dir="/run/user/$(id -u)"
|
||||
sudo install -d -m 700 -o "$(id -u)" -g "$(id -g)" "$dir"
|
||||
echo "XDG_RUNTIME_DIR=$dir" >> "$GITHUB_ENV"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb imagemagick dbus dbus-user-session
|
||||
sudo loginctl enable-linger "$(id -un)"
|
||||
uid="$(id -u)"
|
||||
for _ in $(seq 1 60); do
|
||||
[ -S "/run/user/$uid/bus" ] && break
|
||||
sleep 1
|
||||
done
|
||||
test -S "/run/user/$uid/bus"
|
||||
echo "XDG_RUNTIME_DIR=/run/user/$uid" >> "$GITHUB_ENV"
|
||||
echo "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Install the snap
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb imagemagick dbus
|
||||
sudo snap install gnome-46-2404 mesa-2404 gtk-common-themes
|
||||
sudo snap install --dangerous "$SNAP_FILE"
|
||||
snap connections donutbrowser
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
# smoke-test.sh <output-dir> <seconds> <command> [args...]
|
||||
#
|
||||
# XDG_RUNTIME_DIR must point to a directory owned by the current user. The
|
||||
# script starts a private session bus at $XDG_RUNTIME_DIR/bus, the path both
|
||||
# sandboxes let the app reach, and an Xvfb display. It fails when the app exits
|
||||
# app needs a session bus at $XDG_RUNTIME_DIR/bus, the path both sandboxes let
|
||||
# it reach: an existing one (the user systemd a snap needs) is used as is,
|
||||
# otherwise the script starts a private one. It also starts an Xvfb display. It fails when the app exits
|
||||
# before <seconds> have passed or prints a Rust panic. The app's output and a
|
||||
# screenshot are left in <output-dir>. A screenshot with almost no colours
|
||||
# (a blank window) is reported as a warning.
|
||||
@@ -19,9 +20,11 @@ mkdir -p "$out"
|
||||
|
||||
: "${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR must be set}"
|
||||
bus="$XDG_RUNTIME_DIR/bus"
|
||||
rm -f "$bus"
|
||||
dbus-daemon --session --address="unix:path=$bus" --nofork --nopidfile &
|
||||
dbus_pid=$!
|
||||
dbus_pid=""
|
||||
if [ ! -S "$bus" ]; then
|
||||
dbus-daemon --session --address="unix:path=$bus" --nofork --nopidfile &
|
||||
dbus_pid=$!
|
||||
fi
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$bus"
|
||||
|
||||
display_number=99
|
||||
@@ -29,7 +32,7 @@ Xvfb ":$display_number" -screen 0 1600x1000x24 -nolisten tcp >"$out/xvfb.log" 2>
|
||||
xvfb_pid=$!
|
||||
export DISPLAY=":$display_number"
|
||||
|
||||
trap 'kill "$xvfb_pid" "$dbus_pid" 2>/dev/null || true' EXIT
|
||||
trap 'kill "$xvfb_pid" ${dbus_pid:+"$dbus_pid"} 2>/dev/null || true' EXIT
|
||||
|
||||
for _ in $(seq 1 100); do
|
||||
if [ -S "$bus" ] && [ -S "/tmp/.X11-unix/X$display_number" ]; then
|
||||
|
||||
Reference in new issue
Block a user