Skip to content

Commit 2381efb

Browse files
committed
test(ci): add Android e2e resource monitor
Snapshot host and guest loadavg during Detox runs, upload the log as a CI artifact, and include it in flake-summary triage.
1 parent 8394a52 commit 2381efb

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/scripts/flake-summary.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DETOX_LOG="${RNFB_DETOX_LOG:-}"
2929
summarize "testing-log" "testing.log"
3030
summarize "springboard-log" "springboard-invertase.log"
3131
summarize "resource-monitor" "resource-monitor.log"
32+
summarize "resource-monitor-android" "resource-monitor-android.log"
3233
summarize "metro-log" "metro.log"
3334
} >"$OUT"
3435

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Snapshot host and guest CPU/load during Android e2e runs.
3+
set -uo pipefail
4+
5+
INTERVAL_SEC="${RNFB_RESOURCE_MONITOR_INTERVAL_SEC:-10}"
6+
LOG_FILE="${RNFB_RESOURCE_MONITOR_LOG:-resource-monitor-android.log}"
7+
ADB="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}/platform-tools/adb"
8+
SERIAL="${ANDROID_SERIAL:-emulator-5554}"
9+
10+
if [[ ! -x "$ADB" ]]; then
11+
ADB="$(command -v adb || true)"
12+
fi
13+
14+
echo "[resource-monitor-android] interval=${INTERVAL_SEC}s log=${LOG_FILE} serial=${SERIAL} pid=$$" >>"$LOG_FILE"
15+
16+
while true; do
17+
{
18+
echo "=== $(date -u +%Y-%m-%dT%H:%M:%SZ) ==="
19+
echo "--- host load ---"
20+
uptime
21+
echo "--- host top (pid pcpu pmem rss elapsed command) ---"
22+
ps -eo pid,pcpu,pmem,rss,etime,cmd --sort=-pcpu 2>/dev/null | head -25 || true
23+
echo "--- host e2e-related ---"
24+
ps -eo pid,pcpu,pmem,rss,etime,cmd 2>/dev/null \
25+
| grep -E 'qemu-system|adb |node |java |gradle|Metro' \
26+
| grep -v grep || true
27+
if [[ -n "$ADB" && -x "$ADB" ]]; then
28+
echo "--- guest props ---"
29+
"$ADB" -s "$SERIAL" shell getprop sys.boot_completed dev.bootcomplete 2>/dev/null || true
30+
echo "--- guest load ---"
31+
"$ADB" -s "$SERIAL" shell cat /proc/loadavg 2>/dev/null || true
32+
"$ADB" -s "$SERIAL" shell uptime 2>/dev/null || true
33+
echo "--- guest e2e-related ---"
34+
"$ADB" -s "$SERIAL" shell ps -A -o PID,NAME,CPU 2>/dev/null \
35+
| grep -E 'invertase|testing' \
36+
| grep -v grep || true
37+
fi
38+
echo ""
39+
} >>"$LOG_FILE" 2>&1
40+
sleep "$INTERVAL_SEC"
41+
done

.github/workflows/tests_e2e_android.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ jobs:
269269
script: |
270270
$ANDROID_HOME/platform-tools/adb devices
271271
nohup sh -c "$ANDROID_HOME/platform-tools/adb logcat '*:D' > adb-log.txt" &
272+
chmod +x ./.github/workflows/scripts/resource-monitor-android.sh
273+
nohup ./.github/workflows/scripts/resource-monitor-android.sh &
272274
yarn tests:android:test-cover --headless
275+
pkill -f resource-monitor-android.sh || true
273276
yarn tests:android:post-e2e-coverage
274277
275278
# https://github.com/codecov/codecov-action/releases
@@ -297,6 +300,13 @@ jobs:
297300
name: adb_logs_${{ matrix.api-level}}_${{ matrix.arch }}_${{ matrix.target }}_${{ matrix.iteration }}
298301
path: adb-*.txt
299302

303+
- name: Upload Android resource monitor log
304+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
305+
if: always()
306+
with:
307+
name: resource-monitor-android-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.iteration }}
308+
path: resource-monitor-android.log
309+
300310
- name: Upload Firebase emulator script logs
301311
# https://github.com/actions/upload-artifact/releases
302312
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

0 commit comments

Comments
 (0)