Skip to content

Commit 852e5fd

Browse files
committed
Extract Android template download to script
1 parent 6053032 commit 852e5fd

File tree

2 files changed

+57
-31
lines changed

2 files changed

+57
-31
lines changed

.github/workflows/test_android.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,10 @@ jobs:
2121
with:
2222
arch: x86_64
2323

24-
# TODO: move to prepare testing
25-
- name: Download Android template
26-
shell: bash
24+
- name: Deploy Android build template
2725
env:
2826
GODOT_VERSION: 4.5.1-stable
29-
run: |
30-
archive_file=Godot_v${GODOT_VERSION}_export_templates.tpz
31-
url=https://github.com/godotengine/godot-builds/releases/download/${GODOT_VERSION}/${archive_file}
32-
curl -L -o templates.zip "${url}"
33-
unzip -j templates.zip templates/android_source.zip -d exports/
34-
rm templates.zip
35-
36-
# TODO: need to cache it
37-
38-
mkdir -p project/android/build
39-
unzip exports/android_source.zip -d project/android/build
40-
41-
# NOTE: Godot expects build version file
42-
echo "../exports/android_source.zip [$(md5sum exports/android_source.zip | cut -d' ' -f1)]" > project/android/.build_version
43-
44-
ls -lR project/android/
27+
run: ./scripts/deploy-android-template.sh $GODOT_VERSION
4528

4629
- name: Export project
4730
shell: bash
@@ -51,7 +34,6 @@ jobs:
5134
SENTRY_TEST_INCLUDE: "res://test/suites/"
5235
run: |
5336
cp exports/export_presets.cfg project/export_presets.cfg
54-
mkdir -p exports/android/
5537
${GODOT} --path project/ --headless --export-debug "Android CI" ${GITHUB_WORKSPACE}/exports/android.apk
5638
5739
ls -lR exports/

scripts/run-android-tests.sh

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
#!/bin/bash
2-
#
32
# Run unit tests on a local Android device.
4-
#
5-
# Prerequisites:
6-
# - Godot Engine 4.5 or later with Android export templates installed
7-
# - Android SDK with ADB (Android Debug Bridge) tools
8-
# - Android device connected and authorized for debugging
93

104
# Configuration
11-
TEST_TIMEOUT=60 # seconds
5+
TEST_TIMEOUT=120 # seconds
126
INSTALL_RETRIES=5
137
LAUNCH_RETRIES=3
148
LOCKSCREEN_RETRIES=20
9+
LOGCAT_FILTERS="Godot,godot,sentry-godot,sentry-native"
1510

1611
# Formatted output
1712
highlight() { echo -e "\033[1;34m$1\033[0m"; }
@@ -35,6 +30,51 @@ abort() {
3530
exit 1
3631
}
3732

33+
# Display usage information
34+
usage() {
35+
echo "Usage: $0 [OPTIONS]"
36+
echo ""
37+
echo "Run unit tests on a local Android device."
38+
echo ""
39+
echo "OPTIONS:"
40+
echo " -v, --verbose Enable additional output"
41+
echo " -h, --help Display this help message"
42+
echo ""
43+
echo "PREREQUISITES:"
44+
echo " - Godot Engine 4.5 or later with Android export templates installed"
45+
echo " - Android SDK with ADB (Android Debug Bridge) tools"
46+
echo " - Android device connected and authorized for debugging"
47+
echo ""
48+
echo "ENVIRONMENT VARIABLES:"
49+
echo " GODOT Path to Godot executable (if not in PATH)"
50+
}
51+
52+
# Parse command line options
53+
verbose=false
54+
55+
while [[ $# -gt 0 ]]; do
56+
case $1 in
57+
--verbose|-v)
58+
verbose=true
59+
shift
60+
;;
61+
--help|-h)
62+
usage
63+
exit 0
64+
;;
65+
-*)
66+
error "Unknown option: $1"
67+
usage
68+
exit 1
69+
;;
70+
*)
71+
error "Unexpected argument: $1"
72+
usage
73+
exit 1
74+
;;
75+
esac
76+
done
77+
3878
highlight "Exporting project..."
3979

4080
# Export project to "exports/android.apk".
@@ -61,6 +101,10 @@ for i in $(seq 1 $INSTALL_RETRIES); do
61101
fi
62102
done
63103

104+
# Enable Sentry Android output if verbose
105+
if [ "$verbose" = true ]; then
106+
LOGCAT_FILTERS="$LOGCAT_FILTERS,Sentry"
107+
fi
64108

65109
# Run tests on device
66110
run_tests() {
@@ -105,7 +149,7 @@ run_tests() {
105149
highlight "Reading logs..."
106150

107151
local exit_code=1 # Default general failure
108-
local clean_exit=0
152+
local clean_exit=false
109153

110154
# Process logcat output
111155
while IFS= read -r line; do
@@ -119,11 +163,11 @@ run_tests() {
119163

120164
# Check Godot exit condition
121165
if echo "$line" | grep -q "OnGodotTerminating"; then
122-
clean_exit=1
166+
clean_exit=true
123167
timeout 2 cat || true # Continue reading for a bit in case there are remaining logs
124168
break
125169
fi
126-
done < <(timeout $TEST_TIMEOUT adb logcat --pid=$pid -s Godot,godot,sentry-godot,sentry-native)
170+
done < <(timeout $TEST_TIMEOUT adb logcat --pid=$pid -s $LOGCAT_FILTERS)
127171

128172
# Check if never finished
129173
if [ $exit_code -eq 1 ]; then
@@ -138,7 +182,7 @@ run_tests() {
138182
fi
139183
error "Godot app process still running"
140184
# Check if not exited cleanly
141-
elif [ $clean_exit -eq 0 ]; then
185+
elif [ "$clean_exit" = false ]; then
142186
warning "Unclean exit detected. Godot possibly crashed."
143187
fi
144188

0 commit comments

Comments
 (0)