Skip to content

Commit aabd2c0

Browse files
Refactor Linux CI desktop setup into separate script
Moved the XFCE desktop and tray test setup logic from ci.yml into a new ci_linux_desktop.sh script for improved maintainability and readability. The workflow now calls this script during Linux CI runs, preserving all previous setup steps and diagnostics.
1 parent a05c070 commit aabd2c0

File tree

2 files changed

+101
-80
lines changed

2 files changed

+101
-80
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,22 @@ jobs:
6060
fi
6161
6262
sudo apt-get install -y \
63-
${{ matrix.appindicator }} \
64-
${APPINDICATOR_RUNTIME} \
6563
build-essential \
6664
cmake \
65+
${{ matrix.appindicator }} \
66+
${APPINDICATOR_RUNTIME} \
6767
dbus-x11 \
6868
dconf-cli \
6969
dconf-service \
70+
xfce4 \
71+
xfce4-panel \
72+
xfce4-indicator-plugin \
73+
xfconf \
74+
xkb-data \
7075
imagemagick \
7176
libglib2.0-dev \
7277
libnotify-dev \
7378
ninja-build \
74-
xfce4 \
75-
xfce4-indicator-plugin \
76-
xfce4-panel \
77-
xfconf \
7879
xvfb
7980
8081
- name: Setup Dependencies macOS
@@ -195,80 +196,7 @@ jobs:
195196
# GNOME Shell extensions are unstable in headless CI and can crash with
196197
# "Oh no! Something has gone wrong". XFCE is lightweight and provides a
197198
# stable panel area for showing AppIndicator icons.
198-
dbus-run-session -- bash -lc '
199-
set -euo pipefail
200-
201-
export NO_AT_BRIDGE=1
202-
export GTK_THEME=Adwaita
203-
204-
# dconf/gsettings need a writable XDG_RUNTIME_DIR in minimal CI environments.
205-
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp/xdg-runtime-${UID}}"
206-
mkdir -p "${XDG_RUNTIME_DIR}"
207-
chmod 700 "${XDG_RUNTIME_DIR}"
208-
209-
cleanup() {
210-
kill ${WATCHER_PID:-} ${PANEL_PID:-} ${WM_PID:-} >/dev/null 2>&1 || true
211-
}
212-
trap cleanup EXIT
213-
214-
# Start a minimal XFCE session.
215-
xfwm4 >/dev/null 2>&1 &
216-
WM_PID=$!
217-
218-
# Create a deterministic panel containing the indicator plugin.
219-
# The indicator plugin is the piece that actually renders AppIndicator icons.
220-
rm -rf "${HOME}/.config/xfce4/panel" || true
221-
mkdir -p "${HOME}/.config/xfce4/xfconf/xfce-perchannel-xml"
222-
223-
# Wipe existing panel configuration (best-effort).
224-
xfconf-query -c xfce4-panel -r -R -p /panels >/dev/null 2>&1 || true
225-
xfconf-query -c xfce4-panel -r -R -p /plugins >/dev/null 2>&1 || true
226-
227-
# Define one panel (panel-1) with a single plugin (plugin-1).
228-
xfconf-query -c xfce4-panel -p /panels/panel-1/position -s "p=6;x=0;y=0" -t string -n
229-
xfconf-query -c xfce4-panel -p /panels/panel-1/size -s 32 -t int -n
230-
xfconf-query -c xfce4-panel -p /panels/panel-1/length -s 100 -t int -n
231-
xfconf-query -c xfce4-panel -p /panels/panel-1/length-adjust -s true -t bool -n
232-
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -t int -n
233-
234-
# Plugin-1 is the indicator plugin.
235-
xfconf-query -c xfce4-panel -p /plugins/plugin-1 -s indicator -t string -n
236-
237-
xfce4-panel >/dev/null 2>&1 &
238-
PANEL_PID=$!
239-
240-
# Start an SNI/AppIndicator watcher so AppIndicators can appear.
241-
# Prefer Ayatana watcher if available.
242-
if command -v ayatana-indicator-application-service >/dev/null 2>&1; then
243-
ayatana-indicator-application-service >/dev/null 2>&1 &
244-
WATCHER_PID=$!
245-
elif command -v indicator-application-service >/dev/null 2>&1; then
246-
indicator-application-service >/dev/null 2>&1 &
247-
WATCHER_PID=$!
248-
else
249-
WATCHER_PID=
250-
fi
251-
252-
# Small settle time for panel + watcher.
253-
sleep 3
254-
255-
echo "::group::Linux tray diagnostics"
256-
echo "DISPLAY=${DISPLAY}"
257-
echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}"
258-
echo "Enabled XFCE panel plugins:"
259-
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids || true
260-
xfconf-query -c xfce4-panel -p /plugins/plugin-1 || true
261-
echo "Watcher process: ${WATCHER_PID:-none}"
262-
dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply \
263-
/org/freedesktop/DBus org.freedesktop.DBus.ListNames \
264-
| sed -n "s/.*string \"\(.*\)\".*/\1/p" \
265-
| sort \
266-
| grep -Ei "(indicator|statusnotifier|ayatana|dbusmenu)" \
267-
|| true
268-
echo "::endgroup::"
269-
270-
./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml
271-
'
199+
dbus-run-session -- bash "${GITHUB_WORKSPACE}/.github/workflows/ci_linux_desktop.sh"
272200
status=$?
273201
kill ${XVFB_PID} >/dev/null 2>&1 || true
274202
exit ${status}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script sets up a lightweight desktop/session suitable for tray tests in headless CI.
5+
# It is intended to be executed from the build directory (e.g. build/tests) and within a
6+
# session bus (e.g. dbus-run-session), with DISPLAY already set to an active Xvfb server.
7+
8+
# Reduce a11y/AT-SPI noise in headless CI.
9+
export NO_AT_BRIDGE=1
10+
export GTK_MODULES=
11+
export GTK_THEME=${GTK_THEME:-Adwaita}
12+
13+
# dconf/gsettings need a writable XDG_RUNTIME_DIR in minimal CI environments.
14+
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp/xdg-runtime-${UID}}"
15+
mkdir -p "${XDG_RUNTIME_DIR}"
16+
chmod 700 "${XDG_RUNTIME_DIR}"
17+
18+
# xfce4-notifyd can try to create/update a sqlite notification log DB.
19+
# In CI this can race ("database is locked") and produce GLib criticals.
20+
# Disable it by making the location unwritable.
21+
export XDG_DATA_HOME="${XDG_DATA_HOME:-/tmp/xdg-data-${UID}}"
22+
mkdir -p "${XDG_DATA_HOME}"
23+
chmod 700 "${XDG_DATA_HOME}"
24+
25+
cleanup() {
26+
# best effort cleanup
27+
kill "${WATCHER_PID:-}" "${PANEL_PID:-}" "${WM_PID:-}" >/dev/null 2>&1 || true
28+
chmod -R u+w "${XDG_DATA_HOME}" >/dev/null 2>&1 || true
29+
}
30+
trap cleanup EXIT
31+
32+
# Start a minimal XFCE session.
33+
xfwm4 >/dev/null 2>&1 &
34+
WM_PID=$!
35+
36+
# Create a deterministic panel containing the indicator plugin.
37+
rm -rf "${HOME}/.config/xfce4/panel" || true
38+
mkdir -p "${HOME}/.config/xfce4/xfconf/xfce-perchannel-xml"
39+
40+
# Wipe existing panel configuration (best-effort).
41+
xfconf-query -c xfce4-panel -r -R -p /panels >/dev/null 2>&1 || true
42+
xfconf-query -c xfce4-panel -r -R -p /plugins >/dev/null 2>&1 || true
43+
44+
# Define one panel (panel-1) with a single plugin (plugin-1).
45+
xfconf-query -c xfce4-panel -p /panels/panel-1/position -s "p=6;x=0;y=0" -t string -n
46+
xfconf-query -c xfce4-panel -p /panels/panel-1/size -s 32 -t int -n
47+
xfconf-query -c xfce4-panel -p /panels/panel-1/length -s 100 -t int -n
48+
xfconf-query -c xfce4-panel -p /panels/panel-1/length-adjust -s true -t bool -n
49+
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -t int -n
50+
51+
# Plugin-1 is the indicator plugin.
52+
xfconf-query -c xfce4-panel -p /plugins/plugin-1 -s indicator -t string -n
53+
54+
# Make xfce4-notifyd's notification database location unwritable before it starts.
55+
mkdir -p "${XDG_DATA_HOME}/xfce4/notifyd" || true
56+
chmod -R a-w "${XDG_DATA_HOME}/xfce4/notifyd" || true
57+
58+
xfce4-panel >/dev/null 2>&1 &
59+
PANEL_PID=$!
60+
61+
# Start an SNI/AppIndicator watcher so AppIndicators can appear.
62+
# Prefer Ayatana watcher if available.
63+
if command -v ayatana-indicator-application-service >/dev/null 2>&1; then
64+
ayatana-indicator-application-service >/dev/null 2>&1 &
65+
WATCHER_PID=$!
66+
elif command -v indicator-application-service >/dev/null 2>&1; then
67+
indicator-application-service >/dev/null 2>&1 &
68+
WATCHER_PID=$!
69+
else
70+
WATCHER_PID=
71+
fi
72+
73+
# Small settle time for panel + watcher.
74+
sleep 3
75+
76+
echo "::group::Linux tray diagnostics"
77+
echo "DISPLAY=${DISPLAY:-}"
78+
echo "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}"
79+
echo "XDG_DATA_HOME=${XDG_DATA_HOME}"
80+
echo "Enabled XFCE panel plugins:"
81+
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids || true
82+
xfconf-query -c xfce4-panel -p /plugins/plugin-1 || true
83+
echo "Watcher process: ${WATCHER_PID:-none}"
84+
dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply \
85+
/org/freedesktop/DBus org.freedesktop.DBus.ListNames \
86+
| sed -n 's/.*string "\(.*\)".*/\1/p' \
87+
| sort \
88+
| grep -Ei '(indicator|statusnotifier|ayatana|dbusmenu)' \
89+
|| true
90+
echo "::endgroup::"
91+
92+
# Run the tests from the current working directory.
93+
./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml

0 commit comments

Comments
 (0)