ci: run desktop integration/patrol tests under xvfb (#22)

Headless Linux runners have no display, so 'flutter test integration_test'
fails to launch the GTK app ('The log reader stopped unexpectedly, or never
started'). Wrap integration/patrol layers in xvfb-run with a 24-bit screen
and install xvfb + mesa DRI driver for headless GL. macOS/local runs are
unaffected (no xvfb-run -> command runs directly).

Co-authored-by: Haitao Pan <haitao.pan@xworkmate.ai>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Haitao Pan 2026-06-28 14:46:00 +08:00 committed by GitHub
parent db0b8abc66
commit 4ed10c8f2b
2 changed files with 18 additions and 3 deletions

View File

@ -3,6 +3,19 @@ set -euo pipefail
LAYER="${1:-all}"
# Desktop integration tests launch the real GTK app, which needs a display
# server. On a headless Linux CI runner there is none, so the app never
# establishes a debug connection ("The log reader stopped unexpectedly, or
# never started"). Wrap such commands in a virtual framebuffer when one is
# available; on macOS/local runs (no xvfb-run) the command runs unchanged.
with_display() {
if [[ "$(uname -s)" == "Linux" ]] && command -v xvfb-run >/dev/null 2>&1; then
xvfb-run -a --server-args="-screen 0 1920x1080x24" "$@"
else
"$@"
fi
}
run_flutter_base() {
flutter pub get
flutter analyze
@ -33,7 +46,7 @@ run_flutter_golden_if_present() {
run_flutter_integration_if_present() {
if [[ -d integration_test ]] && find integration_test -name '*_test.dart' | grep -q .; then
flutter test integration_test
with_display flutter test integration_test
else
echo "[skip] no integration tests found under integration_test"
fi
@ -41,7 +54,7 @@ run_flutter_integration_if_present() {
run_patrol_if_present() {
if command -v patrol >/dev/null 2>&1 && [[ -d patrol_test ]] && find patrol_test -name '*_test.dart' | grep -q .; then
patrol test patrol_test
with_display patrol test patrol_test
else
echo "[skip] patrol not installed or patrol_test is empty"
fi

View File

@ -16,10 +16,12 @@ case "$platform" in
pkg-config \
libx11-dev \
libgl1-mesa-dev \
libgl1-mesa-dri \
libayatana-appindicator3-dev \
dpkg-dev \
rpm \
imagemagick
imagemagick \
xvfb
;;
android)
sudo apt-get update