StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
Make platform smoke failures diagnosable
David Nashash9616705c6df0
diff --git a/.github/workflows/platform-smoke.yml b/.github/workflows/platform-smoke.ymlnew file mode 100644index 00000000..bd459e9d--- /dev/null+++ b/.github/workflows/platform-smoke.yml@@ -0,0 +1,88 @@+name: Android Platform Smoke++on:+ workflow_call:+ workflow_dispatch:++permissions:+ contents: read++jobs:+ platform-smoke:+ strategy:+ fail-fast: false+ matrix:+ include:+ - api-level: 25+ runner: ubuntu-latest+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 26+ runner: ubuntu-latest+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 28+ runner: ubuntu-latest+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 32+ runner: ubuntu-latest+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 33+ runner: ubuntu-latest+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 35+ runner: macos-15-intel+ arch: x86_64+ target: default+ gpu: swiftshader_indirect+ - api-level: 36+ runner: macos-15-intel+ arch: x86+ target: android-tv+ gpu: software++ runs-on: ${{ matrix.runner }}++ steps:+ - uses: actions/checkout@v4++ - name: Set up JDK 17+ uses: actions/setup-java@v4+ with:+ java-version: '17'+ distribution: 'temurin'+ cache: gradle++ - name: Run compatibility instrumentation suite+ uses: reactivecircus/android-emulator-runner@v2+ with:+ api-level: ${{ matrix.api-level }}+ arch: ${{ matrix.arch }}+ target: ${{ matrix.target }}+ emulator-options: -no-window -gpu ${{ matrix.gpu }} -no-snapshot -noaudio -no-boot-anim+ profile: tv_1080p+ script: |+ chmod +x gradlew tools/run-platform-smoke.sh tools/wait-for-emulator.sh+ ./tools/run-platform-smoke.sh "${{ matrix.api-level }}" "${{ matrix.arch }}"++ - name: Upload platform smoke diagnostics+ if: always()+ uses: actions/upload-artifact@v4+ with:+ name: platform-smoke-api-${{ matrix.api-level }}-diagnostics+ if-no-files-found: warn+ retention-days: 14+ path: |+ build/platform-smoke-diagnostics/+ app/build/outputs/androidTest-results/+ app/build/reports/androidTests/+ data/build/outputs/androidTest-results/+ data/build/reports/androidTests/diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex bc56f67f..f7893ade 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -71,7 +71,11 @@ jobs:run: chmod +x gradlew- name: Test CI helper scripts- run: bash tools/tests/wait-for-emulator-test.sh+ shell: bash+ run: |+ for test_script in tools/tests/*-test.sh; do+ bash "$test_script"+ done- name: Run unit tests, lint, and coveragerun: ./gradlew --console=plain testDebugUnitTest :app:lintDebug :data:lintDebug :player:lintDebug verifyLintBaseline koverXmlReportCi koverHtmlReportCi@@ -191,77 +195,6 @@ jobs:platform-smoke:needs: build- strategy:- fail-fast: false- matrix:- include:- - api-level: 25- runner: ubuntu-latest- arch: x86_64- target: default- gpu: swiftshader_indirect- - api-level: 26- runner: ubuntu-latest- arch: x86_64- target: default- gpu: swiftshader_indirect- - api-level: 28- runner: ubuntu-latest- arch: x86_64- target: default- gpu: swiftshader_indirect- - api-level: 32- runner: ubuntu-latest- arch: x86_64- target: default- gpu: swiftshader_indirect- - api-level: 33- runner: ubuntu-latest- arch: x86_64- target: default- gpu: swiftshader_indirect- - api-level: 35- runner: macos-15-intel- arch: x86_64- target: default- gpu: software- - api-level: 36- runner: macos-15-intel- arch: x86- target: android-tv- gpu: software-- runs-on: ${{ matrix.runner }}-- steps:- - uses: actions/checkout@v4-- - name: Set up JDK 17- uses: actions/setup-java@v4- with:- java-version: '17'- distribution: 'temurin'- cache: gradle-- - name: Precompile platform smoke APKs- run: |- chmod +x gradlew- ./gradlew --console=plain \- :app:assembleDebug \- :app:assembleDebugAndroidTest \- :data:assembleDebugAndroidTest \- "-PcompatApi=${{ matrix.api-level }}" \- "-PcompatAbi=${{ matrix.arch }}" \- --no-daemon-- - name: Run compatibility instrumentation suite- uses: reactivecircus/android-emulator-runner@v2- with:- api-level: ${{ matrix.api-level }}- arch: ${{ matrix.arch }}- target: ${{ matrix.target }}- emulator-options: -no-window -gpu ${{ matrix.gpu }} -no-snapshot -noaudio -no-boot-anim- profile: tv_1080p- script: |- chmod +x gradlew tools/run-platform-smoke.sh tools/wait-for-emulator.sh- ./tools/run-platform-smoke.sh "${{ matrix.api-level }}" "${{ matrix.arch }}"+ permissions:+ contents: read+ uses: ./.github/workflows/platform-smoke.ymldiff --git a/docs/superpowers/plans/2026-08-22-platform-smoke-reliability.md b/docs/superpowers/plans/2026-08-22-platform-smoke-reliability.mdnew file mode 100644index 00000000..00c79863--- /dev/null+++ b/docs/superpowers/plans/2026-08-22-platform-smoke-reliability.md@@ -0,0 +1,66 @@+# Platform Smoke Reliability Implementation Plan++> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.++**Goal:** Make platform-smoke failures diagnosable and validate the exact release matrix on `develop` before merging to `master`.++**Architecture:** Extract the matrix into a reusable/manual GitHub Actions workflow and make release delegate to it. Run Gradle only while the emulator is active, and capture Android failure evidence from an exit trap before the emulator is destroyed.++**Tech Stack:** GitHub Actions YAML, POSIX shell, Gradle Android instrumentation, adb++**Spec:** `docs/superpowers/specs/2026-08-22-platform-smoke-reliability-design.md`++## Global Constraints++- Do not trigger or publish a master release during implementation.+- Preserve API 25, 26, 28, 32, 33, 35, and 36 coverage.+- Preserve the original failing exit status when collecting diagnostics.+- API 25–35 use their last known-good execution path without a precompile stage.+- API 36 remains isolated as Android TV x86 until CI evidence supports another configuration.++---++### Task 1: Failure diagnostics++**Files:**+- Create: `tools/capture-platform-smoke-diagnostics.sh`+- Modify: `tools/run-platform-smoke.sh`+- Create: `tools/tests/platform-smoke-diagnostics-test.sh`++**Interfaces:**+- Consumes: `PLATFORM_SMOKE_ARTIFACT_DIR`, `PLATFORM_SMOKE_ACTIVE_SUITE`, `ANDROID_SERIAL`+- Produces: diagnostic text/log files without altering the test command's exit status++- [x] Write a shell test with fake `adb` and failing `gradlew`; assert a nonzero status, active-suite record, crash-buffer call, and DropBox call.+- [x] Run `bash tools/tests/platform-smoke-diagnostics-test.sh`; expect failure because diagnostics do not exist.+- [x] Add the diagnostic collector and an exit trap installed before the first Gradle suite.+- [x] Run the shell test and existing emulator-wait test; expect both to pass.++### Task 2: Reusable workflow++**Files:**+- Create: `.github/workflows/platform-smoke.yml`+- Modify: `.github/workflows/release.yml`+- Create: `tools/tests/platform-smoke-workflow-test.sh`++**Interfaces:**+- Produces: reusable `platform-smoke.yml` callable by release and manually on develop+- Produces: artifacts named `platform-smoke-api-<api>-diagnostics`++- [x] Write static assertions for workflow-call/manual triggers, release delegation, no precompile stage, and connected-test artifact paths.+- [x] Run `bash tools/tests/platform-smoke-workflow-test.sh`; expect failure while the matrix remains embedded in release.+- [x] Move the matrix job into the reusable workflow and replace the release matrix with a local reusable-workflow call.+- [x] Add always-run artifact upload per matrix entry.+- [x] Run both CI helper tests and parse both workflow YAML files.++### Task 3: Verification and handoff++**Files:**+- Modify only files required by verification findings.++- [x] Run all shell helper tests.+- [x] Run instrumentation compile gates and relevant host tests.+- [x] Run `graphify update .` and review the final diff.+- [ ] Commit and push the isolated branch to `origin/develop`.+- [ ] Manually dispatch `platform-smoke.yml` against `develop`, never `release.yml` or master.+- [ ] Inspect every matrix job; if one fails, use its uploaded diagnostics to identify the exact Android exception before changing configuration.diff --git a/docs/superpowers/specs/2026-08-22-platform-smoke-reliability-design.md b/docs/superpowers/specs/2026-08-22-platform-smoke-reliability-design.mdnew file mode 100644index 00000000..9c6241db--- /dev/null+++ b/docs/superpowers/specs/2026-08-22-platform-smoke-reliability-design.md@@ -0,0 +1,25 @@+# Platform Smoke Reliability Design++## Problem++The release workflow is currently the only practical place to exercise the full Android API matrix. That makes `master` the feedback loop for CI experiments. The latest workflow also prebuilds instrumentation APKs in a separate Gradle invocation before starting the emulator. After that change, API 33 and API 35 regressed from passing to dying before test discovery, while API 36 remained unresolved. Failed jobs preserve neither device crash diagnostics nor connected-test reports.++## Design++Move the platform matrix into a reusable workflow that supports both `workflow_call` and manual execution on any branch. The release workflow will call it after the host build; maintainers can run the exact same gate against `develop` before merging.++Each matrix entry will build, install, and execute from the emulator runner's script, matching the last known-good API 25–35 execution path. API 36 remains an explicitly isolated Android TV x86 configuration. There will be no separate precompile invocation.++The smoke runner will register failure handling before its first Gradle command. On failure it will capture the active suite, device properties, instrumentation/package state, the Android crash log buffer, recent logcat, and DropBox app-crash records. The workflow will always upload these diagnostics together with app/data connected-test outputs and reports, with a unique artifact name per API.++## Safety and Release Behavior++- Manual execution of the reusable smoke workflow never publishes an APK or release.+- Release publication still requires both the host build and the reusable platform matrix to pass.+- Matrix jobs remain independent with `fail-fast: false`.+- Diagnostics commands are best-effort and cannot replace the original test exit status.+- Existing API coverage and API 35/36 foreground-service suites remain unchanged.++## Verification++Shell tests will use fake `adb` and `gradlew` executables to prove that failure diagnostics run after the first suite fails, preserve the failing status, and record the suite name. Static workflow tests will prove that release delegates to the reusable workflow, the reusable workflow can run manually, connected-test artifacts are uploaded, and the removed precompile stage cannot return unnoticed.diff --git a/tools/capture-platform-smoke-diagnostics.sh b/tools/capture-platform-smoke-diagnostics.shnew file mode 100755index 00000000..024ef778--- /dev/null+++ b/tools/capture-platform-smoke-diagnostics.sh@@ -0,0 +1,26 @@+#!/usr/bin/env sh++set -u++artifact_dir="${PLATFORM_SMOKE_ARTIFACT_DIR:-build/platform-smoke-diagnostics}"+device_serial="${ANDROID_SERIAL:-emulator-5554}"+active_suite="${PLATFORM_SMOKE_ACTIVE_SUITE:-unknown}"++mkdir -p "$artifact_dir"+printf '%s\n' "$active_suite" > "$artifact_dir/active-suite.txt"++capture() {+ output_file=$1+ shift+ "$@" > "$artifact_dir/$output_file" 2>&1 || true+}++capture adb-devices.txt adb devices -l+capture device-properties.txt adb -s "$device_serial" shell getprop+capture instrumentation.txt adb -s "$device_serial" shell pm list instrumentation+capture app-package.txt adb -s "$device_serial" shell dumpsys package com.streamvault.app.debug+capture app-processes.txt adb -s "$device_serial" shell dumpsys activity processes com.streamvault.app.debug+capture crash-buffer.log adb -s "$device_serial" logcat -b crash -d -v threadtime+capture recent-logcat.log adb -s "$device_serial" logcat -d -v threadtime -t 4000+capture dropbox-app-crash.txt adb -s "$device_serial" shell dumpsys dropbox --print data_app_crash+capture app-crash-report.txt adb -s "$device_serial" shell run-as com.streamvault.app.debug cat files/diagnostics/crash/latest-crash.txtdiff --git a/tools/run-platform-smoke.sh b/tools/run-platform-smoke.shindex 7f5bdf6f..bf4dc83a 100755--- a/tools/run-platform-smoke.sh+++ b/tools/run-platform-smoke.sh@@ -4,11 +4,35 @@ set -euapi_level="${1:?API level is required}"compat_abi="${2:-x86_64}"+artifact_dir="${PLATFORM_SMOKE_ARTIFACT_DIR:-build/platform-smoke-diagnostics}"+PLATFORM_SMOKE_ACTIVE_SUITE="startup"+PLATFORM_SMOKE_ARTIFACT_DIR="$artifact_dir"+export PLATFORM_SMOKE_ACTIVE_SUITE PLATFORM_SMOKE_ARTIFACT_DIR++cleanup_platform_smoke() {+ status=$?+ trap - EXIT++ if [ "$status" -ne 0 ]; then+ sh ./tools/capture-platform-smoke-diagnostics.sh || true+ fi++ if [ "$api_level" = "35" ] || [ "$api_level" = "36" ]; then+ adb shell device_config delete activity_manager data_sync_fgs_timeout_duration >/dev/null 2>&1 || true+ adb shell am compat disable FGS_INTRODUCE_TIME_LIMITS com.streamvault.app.debug >/dev/null 2>&1 || true+ fi++ exit "$status"+}++trap cleanup_platform_smoke EXITif [ "$api_level" = "35" ] || [ "$api_level" = "36" ]; then./tools/wait-for-emulator.shfi+PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.app.compat.PlatformCompatibilityMatrixTest"+export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:app:connectedDebugAndroidTest \"-PcompatApi=${api_level}" \@@ -16,36 +40,36 @@ fi-Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.app.compat.PlatformCompatibilityMatrixTest \--no-daemon-cleanup_api_35_or_36() {- status=$?- adb shell device_config delete activity_manager data_sync_fgs_timeout_duration >/dev/null 2>&1 || true- adb shell am compat disable FGS_INTRODUCE_TIME_LIMITS com.streamvault.app.debug >/dev/null 2>&1 || true- exit "$status"-}-if [ "$api_level" = "35" ] || [ "$api_level" = "36" ]; then- trap cleanup_api_35_or_36 EXITadb shell am compat enable FGS_INTRODUCE_TIME_LIMITS com.streamvault.app.debugadb shell device_config put activity_manager data_sync_fgs_timeout_duration 5000+ PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.app.service.DownloadForegroundServiceInstrumentationTest"+ export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:app:connectedDebugAndroidTest \"-PcompatAbi=${compat_abi}" \-Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.app.service.DownloadForegroundServiceInstrumentationTest \--no-daemon+ PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.app.service.DownloadForegroundServiceQuotaInstrumentationTest"+ export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:app:connectedDebugAndroidTest \"-PcompatAbi=${compat_abi}" \-Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.app.service.DownloadForegroundServiceQuotaInstrumentationTest \--no-daemon+ PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.app.service.DownloadForegroundServiceRecoveryInstrumentationTest"+ export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:app:connectedDebugAndroidTest \"-PcompatAbi=${compat_abi}" \-Pandroid.testInstrumentationRunnerArguments.class=com.streamvault.app.service.DownloadForegroundServiceRecoveryInstrumentationTest \--no-daemon+ PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.data.manager.recording.PlatformReleaseSafetyInstrumentationTest"+ export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:data:connectedDebugAndroidTest \"-PcompatAbi=${compat_abi}" \@@ -54,6 +78,8 @@ if [ "$api_level" = "35" ] || [ "$api_level" = "36" ]; thenfiif [ "$api_level" = "25" ] || [ "$api_level" = "36" ]; then+ PLATFORM_SMOKE_ACTIVE_SUITE="com.streamvault.data.local.StreamVaultDatabaseMigrationTest"+ export PLATFORM_SMOKE_ACTIVE_SUITE./gradlew --console=plain \:data:connectedDebugAndroidTest \"-PcompatAbi=${compat_abi}" \diff --git a/tools/tests/platform-smoke-diagnostics-test.sh b/tools/tests/platform-smoke-diagnostics-test.shnew file mode 100755index 00000000..017ff966--- /dev/null+++ b/tools/tests/platform-smoke-diagnostics-test.sh@@ -0,0 +1,58 @@+#!/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++workspace="$temp_dir/workspace"+artifact_dir="$workspace/platform-smoke-artifacts"+adb_calls="$temp_dir/adb-calls"+mkdir -p "$workspace/tools" "$artifact_dir"+cp "$repo_root/tools/run-platform-smoke.sh" "$workspace/tools/run-platform-smoke.sh"+if [ -f "$repo_root/tools/capture-platform-smoke-diagnostics.sh" ]; then+ cp "$repo_root/tools/capture-platform-smoke-diagnostics.sh" "$workspace/tools/capture-platform-smoke-diagnostics.sh"+fi++cat > "$workspace/gradlew" <<'FAKE_GRADLEW'+#!/usr/bin/env sh+printf 'intentional instrumentation failure\n' >&2+exit 23+FAKE_GRADLEW+chmod +x "$workspace/gradlew" "$workspace/tools/run-platform-smoke.sh"++cat > "$temp_dir/adb" <<'FAKE_ADB'+#!/usr/bin/env sh+set -eu+printf '%s\n' "$*" >> "${FAKE_ADB_CALLS:?}"+case "$*" in+ *"getprop"*) printf '[ro.build.version.sdk]: [33]\n' ;;+ *"pm list instrumentation"*) printf 'instrumentation:fixture/runner (target=fixture)\n' ;;+ *"logcat"*) printf 'fixture crash evidence\n' ;;+ *"dumpsys dropbox"*) printf 'fixture dropbox evidence\n' ;;+ *"dumpsys package"*) printf 'fixture package evidence\n' ;;+ *"devices"*) printf 'List of devices attached\nemulator-5554 device\n' ;;+esac+FAKE_ADB+chmod +x "$temp_dir/adb"++set +e+(+ cd "$workspace"+ PATH="$temp_dir:$PATH" \+ FAKE_ADB_CALLS="$adb_calls" \+ PLATFORM_SMOKE_ARTIFACT_DIR="$artifact_dir" \+ ./tools/run-platform-smoke.sh 33 x86_64+)+status=$?+set -e++[ "$status" -eq 23 ]+grep -F 'PlatformCompatibilityMatrixTest' "$artifact_dir/active-suite.txt" >/dev/null+grep -F 'logcat -b crash -d' "$adb_calls" >/dev/null+grep -F 'dumpsys dropbox --print data_app_crash' "$adb_calls" >/dev/null+grep -F 'fixture crash evidence' "$artifact_dir/crash-buffer.log" >/dev/null++printf 'platform smoke diagnostics test passed\n'diff --git a/tools/tests/platform-smoke-workflow-test.sh b/tools/tests/platform-smoke-workflow-test.shnew file mode 100755index 00000000..ad7d95f6--- /dev/null+++ b/tools/tests/platform-smoke-workflow-test.sh@@ -0,0 +1,32 @@+#!/usr/bin/env sh++set -eu++script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)+repo_root=$(CDPATH= cd -- "$script_dir/../.." && pwd)+smoke_workflow="$repo_root/.github/workflows/platform-smoke.yml"+release_workflow="$repo_root/.github/workflows/release.yml"++[ -f "$smoke_workflow" ]+grep -F 'workflow_call:' "$smoke_workflow" >/dev/null+grep -F 'workflow_dispatch:' "$smoke_workflow" >/dev/null+grep -F 'uses: ./.github/workflows/platform-smoke.yml' "$release_workflow" >/dev/null+grep -F 'for test_script in tools/tests/*-test.sh' "$release_workflow" >/dev/null++if grep -F 'Precompile platform smoke APKs' "$smoke_workflow" "$release_workflow" >/dev/null; then+ printf 'platform smoke must build and install in one emulator-scoped invocation\n' >&2+ exit 1+fi++for api_level in 25 26 28 32 33 35 36; do+ grep -F -- "- api-level: $api_level" "$smoke_workflow" >/dev/null+done++grep -F 'platform-smoke-api-${{ matrix.api-level }}-diagnostics' "$smoke_workflow" >/dev/null+grep -F 'build/platform-smoke-diagnostics/' "$smoke_workflow" >/dev/null+grep -F 'app/build/outputs/androidTest-results/' "$smoke_workflow" >/dev/null+grep -F 'app/build/reports/androidTests/' "$smoke_workflow" >/dev/null+grep -F 'data/build/outputs/androidTest-results/' "$smoke_workflow" >/dev/null+grep -F 'data/build/reports/androidTests/' "$smoke_workflow" >/dev/null++printf 'platform smoke workflow test passed\n'