Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/scripts/android-emulator-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@ mkdir -p logs
appium --port 4723 --allow-insecure 'uiautomator2:chromedriver_autodownload' > logs/appium.log 2>&1 &
APPIUM_PID=$!

# The Appium log does not show the state of the device, for example when the screen stays black and taps and key events
# fail for the whole job. Save it in logs/ (uploaded when the job fails) before the action stops the emulator.
save_device_state() {
# A failure here must not stop the cleanup (set -e also applies in the EXIT trap)
mkdir -p logs/device || return 0
echo "::group::Save the device state"
timeout 30 adb exec-out screencap -p > logs/device/screen.png || true
timeout 60 adb logcat -d -v threadtime > logs/device/logcat.txt || true
local dumps=('window windows' 'activity activities' 'input' 'power' 'display' 'SurfaceFlinger')
for dump in "${dumps[@]}"; do
# shellcheck disable=SC2086 # split the service name from its arguments
timeout 30 adb shell dumpsys $dump > "logs/device/dumpsys-${dump%% *}.txt" 2>&1 || true
done
echo "::endgroup::"
}

cleanup() {
local status=$?
if [ "$status" -ne 0 ]; then
save_device_state
fi
kill "$APPIUM_PID" 2> /dev/null || true
# When the action stops the emulator, it waits for all emulator processes, but the emulator leaves its
# crashpad_handler processes running, so the job hangs (ReactiveCircus/android-emulator-runner#385).
Expand Down
Loading