Skip to content

Commit f7c2018

Browse files
committed
ci: Build the runtime against the SDK and test it
This PR builds the runtime agains a new SDK, and tests it against several snaps. Specifically, it tests: * firefox * epiphany * thunderbird * darktable * cheese * gimp * gnome-calculator * gnome-system-monitor * gnome-text-editor * evince * kicad * chromium * shotwell * telegram * mattermost It uses YARF OCR capabilities to detect that the application has been launched correctly. After it detects it, it waits five seconds and test again, to ensure that it is still working (thus to avoid the case where the window does appear but the application crashes immediately). If a test fails, it uploads an artifact with the YARF logs, to check if it's a test problem or a PR problem.
1 parent a44914b commit f7c2018

2 files changed

Lines changed: 297 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 157 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,168 @@ on:
99
jobs:
1010
snap:
1111
runs-on: ubuntu-latest
12+
outputs:
13+
runtime: ${{ steps.upload-runtime.outputs.artifact-id }}
1214
steps:
13-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v6
16+
1417
- name: Free disk space
1518
run: |
1619
sudo rm -rf /usr/local/lib/android
17-
- uses: snapcore/action-build@v1
20+
21+
- name: Build SDK
22+
uses: snapcore/action-build@v1
1823
id: snapcraft
19-
- uses: actions/upload-artifact@v4
24+
25+
- uses: actions/upload-artifact@v6
2026
with:
2127
name: 'snap'
2228
path: ${{ steps.snapcraft.outputs.snap}}
29+
30+
- name: Prepare runtime
31+
run: |
32+
set -eu
33+
git clone --depth 1 --branch gnome-46-2404 https://github.com/ubuntu/gnome-sdk gnome-runtime
34+
mkdir gnome-runtime/base-gnome-sdk
35+
mv ${{ steps.snapcraft.outputs.snap}} gnome-runtime/base-gnome-sdk/
36+
cd gnome-runtime
37+
./local-build.py --prepare-only
38+
39+
- name: Build runtime
40+
uses: snapcore/action-build@v1
41+
id: snapcraft-runtime
42+
with:
43+
path: gnome-runtime
44+
45+
- name: Delete old snap
46+
run: |
47+
rm -f gnome-runtime/base-gnome-sdk/*.snap
48+
49+
- uses: actions/upload-artifact@v6
50+
id: upload-runtime
51+
with:
52+
name: 'snap-runtime'
53+
path: ${{ steps.snapcraft-runtime.outputs.snap}}
54+
55+
testing:
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
# define in 'snapname' the name of each snap to test
60+
snapname:
61+
- cheese
62+
- chromium
63+
- darktable
64+
- evince
65+
- epiphany
66+
- firefox
67+
- gimp
68+
- gnome-calculator
69+
- gnome-system-monitor
70+
- gnome-text-editor
71+
- kicad
72+
- mattermost-desktop
73+
- shotwell
74+
- telegram-desktop
75+
- thunderbird
76+
# here, in waittext, define the text to find for each snap
77+
# more variables are:
78+
# - commandname: the command to run instead of 'snap run $snapname'
79+
# - timeout: the timeout to wait for the text to appear. Default is 20 seconds.
80+
# - connections: an space-separated list of plugs that must be connected
81+
# - enablex11: if true, will enable Xwayland
82+
# - separated: if true, the words will be split and must be found each anywhere in the screen
83+
include:
84+
- snapname: "cheese"
85+
waittext: "Take a Photo"
86+
- snapname: "chromium"
87+
waittext: "New Tab"
88+
enablex11: "true"
89+
- snapname: "darktable"
90+
waittext: "darktable lighttable darkroom"
91+
separated: "true"
92+
- snapname: "evince"
93+
waittext: "Document Viewer Open"
94+
- snapname: "epiphany"
95+
waittext: "Set as Default Browser"
96+
enablex11: "true"
97+
- snapname: "firefox"
98+
waittext: "Welcome to Firefox"
99+
- snapname: "gimp"
100+
waittext: "Welcome to GIMP"
101+
- snapname: "gnome-calculator"
102+
waittext: "Basic mod"
103+
separated: "true"
104+
- snapname: "gnome-system-monitor"
105+
waittext: "Network Resources Processes Disk Memory Swap CPU"
106+
separated: "true"
107+
- snapname: "gnome-text-editor"
108+
waittext: "New Document"
109+
- snapname: "kicad"
110+
waittext: "Configure KiCad"
111+
enablex11: "true"
112+
- snapname: "mattermost-desktop"
113+
waittext: "Mattermost"
114+
separated: "true"
115+
commandname: "snap run mattermost-desktop"
116+
enablex11: "true"
117+
connections: "login-session-observe"
118+
- snapname: "shotwell"
119+
waittext: "Shotwell"
120+
- snapname: "telegram-desktop"
121+
waittext: "Welcome to the official Telegram Desktop app"
122+
- snapname: "thunderbird"
123+
waittext: "Thunderbird will automatically search"
124+
runs-on: ubuntu-latest
125+
needs: snap
126+
steps:
127+
- name: Get data
128+
uses: actions/checkout@v6
129+
- name: Download artifact
130+
id: download-snap
131+
uses: actions/download-artifact@v8
132+
with:
133+
artifact-ids: ${{ needs.snap.outputs.runtime }}
134+
- name: Install tools
135+
run: |
136+
set -eu
137+
sudo snap refresh
138+
sudo apt update
139+
# dbus-x11 is required because it contains dbus-launch!!
140+
# x11-apps are required to wait for XWayland
141+
sudo apt install -y \
142+
dbus-daemon \
143+
dconf-gsettings-backend \
144+
xwayland \
145+
gnome-keyring \
146+
wayland-utils \
147+
xdg-desktop-portal-gnome \
148+
dbus-x11 \
149+
gnome-session-common \
150+
gnome-settings-daemon \
151+
x11-apps
152+
# to be able to use Xwayland, --devmode is required
153+
sudo snap install --devmode mir-test-tools
154+
sudo snap install --beta yarf
155+
sudo snap connect yarf:process-control
156+
sudo snap install --dangerous ${{ steps.download-snap.outputs.download-path}}/*.snap
157+
158+
# test application with the new runtime
159+
- name: Test application
160+
run: |
161+
export TEST_SNAPNAME=${{ matrix.snapname }}
162+
export TEST_WAITTEXT="${{ matrix.waittext }}"
163+
export TEST_COMMAND_NAME="${{ matrix.commandname }}"
164+
export TEST_DO_ENABLE_X11=${{ matrix.enablex11 }}
165+
export TEST_DO_SEPARATED=${{ matrix.separated }}
166+
export TEST_TIMEOUT=${{ matrix.timeout }}
167+
export TEST_IFACE_CONNECTIONS=${{ matrix.connections }}
168+
169+
./.github/workflows/test_script.sh
170+
171+
- uses: actions/upload-artifact@v6
172+
id: upload-yarf-log
173+
if: always()
174+
with:
175+
path: ~/snap/yarf/common/yarf-outdir
176+
name: yarf-logs-${{ matrix.snapname }}

.github/workflows/test_script.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
3+
set -eux -o pipefail
4+
5+
export TEST_COMMAND_NAME="${TEST_COMMAND_NAME:-snap run ${TEST_SNAPNAME}}"
6+
# default value for TEST_TIMEOUT: 20 seconds
7+
export TEST_TIMEOUT=${TEST_TIMEOUT:-20}
8+
9+
echo Testing ${TEST_SNAPNAME} with $TEST_COMMAND_NAME and waiting for ${TEST_WAITTEXT}
10+
rm -rf ./testRobot
11+
mkdir ./testRobot
12+
13+
TEST_ROBOT_FILE=./testRobot/app.robot
14+
cat > $TEST_ROBOT_FILE <<EOF
15+
*** Settings ***
16+
Resource kvm.resource
17+
Library Process
18+
19+
*** Tasks ***
20+
Do test
21+
EOF
22+
if [[ "${TEST_DO_SEPARATED}" == "true" ]]; then
23+
for entry in ${TEST_WAITTEXT}; do
24+
echo " Match Text ${entry} ${TEST_TIMEOUT}" >> ${TEST_ROBOT_FILE}
25+
export TEST_TIMEOUT=""
26+
done
27+
echo " Sleep 5" >> ${TEST_ROBOT_FILE}
28+
for entry in ${TEST_WAITTEXT}; do
29+
echo " Match Text ${entry}" >> ${TEST_ROBOT_FILE}
30+
done
31+
else
32+
cat >> $TEST_ROBOT_FILE <<EOF
33+
Match Text ${TEST_WAITTEXT} ${TEST_TIMEOUT}
34+
Sleep 5
35+
Match Text ${TEST_WAITTEXT}
36+
EOF
37+
fi
38+
cat >> $TEST_ROBOT_FILE <<EOF
39+
Keys Combo Alt_L F4
40+
[Teardown] Run Keyword Log Screenshot
41+
EOF
42+
43+
echo "Test robot file:"
44+
cat ${TEST_ROBOT_FILE}
45+
sudo snap install ${TEST_SNAPNAME} || echo Snap already installed
46+
# This is needed because the gnome runtime has been installed manually with --dangerous
47+
sudo snap connect ${TEST_SNAPNAME}:gnome-46-2404 gnome-46-2404:gnome-46-2404
48+
for plug in ${TEST_IFACE_CONNECTIONS}; do
49+
sudo snap connect ${TEST_SNAPNAME}:${plug}
50+
done
51+
sudo /usr/lib/snapd/snap-discard-ns ${TEST_SNAPNAME}
52+
echo Current connections:
53+
snap connections ${TEST_SNAPNAME}
54+
echo
55+
56+
MYUID=$(id -u)
57+
export WAYLAND_DISPLAY=/run/user/${MYUID}/wayland-0
58+
export MIR_SERVER_ADD_WAYLAND_EXTENSIONS=zwlr_screencopy_manager_v1:zwlr_virtual_pointer_manager_v1
59+
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${MYUID}/bus
60+
export LANG=en_US.UTF-8
61+
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
62+
export XDG_MENU_PREFIX=gnome-
63+
export XDG_SESSION_DESKTOP=ubuntu
64+
export XDG_SESSION_TYPE=wayland
65+
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
66+
export XDG_SESSION_CLASS=user
67+
export XDG_RUNTIME_DIR=/run/user/${MYUID}
68+
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
69+
export GNOME_SHELL_SESSION_MODE=ubuntu
70+
export GNOME_SETUP_DISPLAY=:1
71+
72+
# use only GTK portal, since mutter isn't running
73+
sudo sed -i -e 's/gnome;gtk;/gtk;/g' /usr/share/xdg-desktop-portal/gnome-portals.conf
74+
75+
# this must be defined after launching the demo server; if not, it won't launch
76+
unset DISPLAY
77+
export ENABLE_X11_PROP=""
78+
if [[ "${TEST_DO_ENABLE_X11}" == "true" ]]; then
79+
export ENABLE_X11_PROP="--enable-x11=true"
80+
fi
81+
82+
# required to work in a no-DRM environment
83+
export XWAYLAND_NO_GLAMOR=1
84+
mir-test-tools.demo-server --platform-display-libs mir:virtual --virtual-output 1920x1080 ${ENABLE_X11_PROP} & MIR_PID=$! # starts the demo Mir compositor
85+
86+
counter=0
87+
until wayland-info > /dev/null || (( ${counter} > 30 )); do
88+
echo waiting for mir server...
89+
sleep 1
90+
counter=$((counter+1))
91+
done
92+
93+
if [[ "${TEST_DO_ENABLE_X11}" == "true" ]]; then
94+
export DISPLAY=:0
95+
counter=0
96+
until (( ${counter} > 30 )); do
97+
timeout 2 xclock || EXIT_CODE=$?
98+
# 124 is "timeout"
99+
if (( "EXIT_CODE" == "124" )); then
100+
# end loop if timed out
101+
echo XWayland available
102+
counter=50
103+
else
104+
echo Waiting for XWayland to be available
105+
sleep 1
106+
fi
107+
counter=$((counter+1))
108+
done
109+
unset WAYLAND_DISPLAY
110+
export XDG_SESSION_TYPE=x11
111+
fi
112+
113+
echo Launching ${TEST_COMMAND_NAME}
114+
${TEST_COMMAND_NAME} & command_pid=$!
115+
116+
echo Launching YARF
117+
YARF_RETERR=0
118+
APP_RETERR=0
119+
MIR_RETERR=0
120+
yarf --platform Mir ./testRobot || YARF_RETERR=$?
121+
122+
echo Journal
123+
journalctl --user --no-pager
124+
125+
echo Waiting for application to die
126+
# wait up to 10 seconds for the snap to finish.
127+
timeout 10 tail --pid=${command_pid} -f /dev/null || /bin/true
128+
129+
echo killing MIR server
130+
# kill DBus and MIR and wait for it to fully finish.
131+
kill $MIR_PID
132+
wait $MIR_PID
133+
134+
echo Cleaning up
135+
# remove user data, just in case
136+
rm -rf ~/snap/${TEST_SNAPNAME}
137+
sudo snap remove ${TEST_SNAPNAME} || echo Failed to remove the snap
138+
rm -rf ./testRobot
139+
# only fail after cleanup
140+
exit ${YARF_RETERR}

0 commit comments

Comments
 (0)