Skip to content

Commit d44e36d

Browse files
authored
Merge pull request #166 from synonymdev/ci/archive-android-app-logs
ci: archive android app logs
2 parents a97ec48 + e201956 commit d44e36d

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

ci_run_android.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,34 @@ fi
1515

1616
mkdir -p "${ARTIFACTS_DIR}"
1717

18+
APP_ID="${APP_ID_ANDROID:-to.bitkit.dev}"
19+
APP_LOGS_DIR="$ARTIFACTS_DIR/app-logs"
20+
1821
adb logcat -c
1922
LOGFILE="$ARTIFACTS_DIR/logcat.txt"
2023

2124
adb logcat -v threadtime -T 1 -b all > "$LOGFILE" &
2225
LOGCAT_PID=$!
2326

27+
collect_app_logs() {
28+
mkdir -p "$APP_LOGS_DIR"
29+
set +e
30+
adb exec-out run-as "$APP_ID" tar -cf - -C "/data/data/$APP_ID/files" logs \
31+
| tar -xf - -C "$APP_LOGS_DIR" 2>/dev/null
32+
local status=$?
33+
set -e
34+
35+
if [[ "$status" -eq 0 ]]; then
36+
echo "Saved app logs to $APP_LOGS_DIR"
37+
else
38+
echo "Could not collect app logs for $APP_ID" >&2
39+
fi
40+
}
41+
2442
cleanup() {
2543
kill "$LOGCAT_PID" 2>/dev/null || true
2644
wait "$LOGCAT_PID" 2>/dev/null || true
45+
collect_app_logs
2746
}
2847
trap cleanup EXIT INT TERM
2948

0 commit comments

Comments
 (0)