Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Stabilize API 35 and 36 platform smoke CI

David Nashash12f9d8e04bdd
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 56c9cdfb..5a1764ff 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -70,6 +70,9 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
+ - name: Test CI helper scripts
+ run: bash tools/tests/wait-for-emulator-test.sh
+
- name: Run unit tests, lint, and coverage
run: ./gradlew --console=plain testDebugUnitTest :app:lintDebug :data:lintDebug :player:lintDebug verifyLintBaseline koverXmlReportCi koverHtmlReportCi
@@ -188,11 +191,33 @@ jobs:
platform-smoke:
needs: build
- runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- api-level: [25, 26, 28, 32, 33, 35, 36]
+ include:
+ - api-level: 25
+ runner: ubuntu-latest
+ arch: x86_64
+ - api-level: 26
+ runner: ubuntu-latest
+ arch: x86_64
+ - api-level: 28
+ runner: ubuntu-latest
+ arch: x86_64
+ - api-level: 32
+ runner: ubuntu-latest
+ arch: x86_64
+ - api-level: 33
+ runner: ubuntu-latest
+ arch: x86_64
+ - api-level: 35
+ runner: macos-15-intel
+ arch: x86_64
+ - api-level: 36
+ runner: macos-15-intel
+ arch: x86_64
+
+ runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
@@ -208,8 +233,8 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
- arch: x86_64
+ arch: ${{ matrix.arch }}
profile: tv_1080p
script: |
- chmod +x gradlew tools/run-platform-smoke.sh
- ./tools/run-platform-smoke.sh "${{ matrix.api-level }}" x86_64
+ chmod +x gradlew tools/run-platform-smoke.sh tools/wait-for-emulator.sh
+ ./tools/run-platform-smoke.sh "${{ matrix.api-level }}" "${{ matrix.arch }}"
diff --git a/tools/run-platform-smoke.sh b/tools/run-platform-smoke.sh
index 9e5752cf..7f5bdf6f 100755
--- a/tools/run-platform-smoke.sh
+++ b/tools/run-platform-smoke.sh
@@ -5,6 +5,10 @@ set -eu
api_level="${1:?API level is required}"
compat_abi="${2:-x86_64}"
+if [ "$api_level" = "35" ] || [ "$api_level" = "36" ]; then
+ ./tools/wait-for-emulator.sh
+fi
+
./gradlew --console=plain \
:app:connectedDebugAndroidTest \
"-PcompatApi=${api_level}" \
diff --git a/tools/tests/wait-for-emulator-test.sh b/tools/tests/wait-for-emulator-test.sh
new file mode 100644
index 00000000..c3d112a3
--- /dev/null
+++ b/tools/tests/wait-for-emulator-test.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env sh
+
+set -eu
+
+script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
+repo_root=$(CDPATH= cd -- "$script_dir/../.." && pwd)
+temp_dir=$(mktemp -d)
+trap 'rm -rf "$temp_dir"' EXIT
+
+counter_file="$temp_dir/adb-count"
+printf '0\n' > "$counter_file"
+
+cat > "$temp_dir/adb" <<'FAKE_ADB'
+#!/usr/bin/env sh
+
+set -eu
+
+count_file=${FAKE_ADB_COUNT_FILE:?FAKE_ADB_COUNT_FILE is required}
+command="$*"
+
+case "$command" in
+ "-s emulator-5554 get-state")
+ count=$(cat "$count_file")
+ count=$((count + 1))
+ printf '%s\n' "$count" > "$count_file"
+ if [ "$count" -lt 2 ]; then
+ printf 'offline\n'
+ else
+ printf 'device\n'
+ fi
+ ;;
+ *"shell getprop sys.boot_completed"*)
+ printf '1\n'
+ ;;
+ *"shell pm path android"*)
+ printf 'package:/system/framework/framework-res.apk\n'
+ ;;
+ *"shell sm list-volumes all"*)
+ printf 'private mounted null\n'
+ ;;
+ *)
+ printf 'unexpected adb invocation: %s\n' "$command" >&2
+ exit 1
+ ;;
+esac
+FAKE_ADB
+chmod +x "$temp_dir/adb"
+
+output=$(
+ PATH="$temp_dir:$PATH" \
+ FAKE_ADB_COUNT_FILE="$counter_file" \
+ ANDROID_SERIAL=emulator-5554 \
+ EMULATOR_READINESS_CHECKS=2 \
+ EMULATOR_READINESS_ATTEMPTS=5 \
+ EMULATOR_READINESS_INTERVAL=0 \
+ "$repo_root/tools/wait-for-emulator.sh"
+)
+
+printf '%s\n' "$output" | grep -F 'Emulator emulator-5554 is ready' >/dev/null
+[ "$(cat "$counter_file")" -ge 3 ]
+
+printf 'wait-for-emulator test passed\n'
diff --git a/tools/wait-for-emulator.sh b/tools/wait-for-emulator.sh
new file mode 100755
index 00000000..d645aff2
--- /dev/null
+++ b/tools/wait-for-emulator.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env sh
+
+set -eu
+
+device_serial="${ANDROID_SERIAL:-emulator-5554}"
+max_attempts="${EMULATOR_READINESS_ATTEMPTS:-90}"
+required_stable_checks="${EMULATOR_READINESS_CHECKS:-3}"
+interval_seconds="${EMULATOR_READINESS_INTERVAL:-2}"
+stable_checks=0
+
+is_storage_ready() {
+ case "$1" in
+ *" mounted "*) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+printf 'Waiting for emulator %s package and storage services...\n' "$device_serial"
+
+attempt=1
+while [ "$attempt" -le "$max_attempts" ]; do
+ state=$(adb -s "$device_serial" get-state 2>/dev/null | tr -d '\r' || true)
+ boot_completed=$(adb -s "$device_serial" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r' || true)
+ package_path=$(adb -s "$device_serial" shell pm path android 2>/dev/null | tr -d '\r' || true)
+ storage_volumes=$(adb -s "$device_serial" shell sm list-volumes all 2>/dev/null | tr -d '\r' || true)
+
+ if [ "$state" = "device" ] && \
+ [ "$boot_completed" = "1" ] && \
+ case "$package_path" in package:*) true ;; *) false ;; esac && \
+ is_storage_ready "$storage_volumes"; then
+ stable_checks=$((stable_checks + 1))
+ if [ "$stable_checks" -ge "$required_stable_checks" ]; then
+ printf 'Emulator %s is ready (%s consecutive checks).\n' "$device_serial" "$stable_checks"
+ exit 0
+ fi
+ else
+ stable_checks=0
+ fi
+
+ attempt=$((attempt + 1))
+ sleep "$interval_seconds"
+done
+
+printf 'Emulator %s did not become ready after %s checks.\n' "$device_serial" "$max_attempts" >&2
+printf ' adb state: %s\n' "$state" >&2
+printf ' boot completed: %s\n' "$boot_completed" >&2
+printf ' package path: %s\n' "$package_path" >&2
+printf ' storage volumes:\n%s\n' "$storage_volumes" >&2
+exit 1