Skip to content

ci(app): upload the debug APK and run Android JVM tests in parallel - #14330

Merged
Git-on-my-level merged 3 commits into
mainfrom
task/msd-ci-v5-apk-artifact
Sep 17, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
task/msd-ci-v5-apk-artifact

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Mobile App Checks threw away the debug APK after a ~14-minute Android Compile Smoke job that also ran :app:testDevDebugUnitTest serially (baseline run 35174763226, 14.3 min). This PR uploads that APK as a short-lived, head-SHA-named artifact, moves the JVM tests onto a parallel job, and caches the Gradle User Home (build cache + wrapper dist) via setup-gradle@v6.

The APK build stays --target-platform android-arm64 on every event, matching origin/main since c8f35061fc. This PR does not change which ABIs are compiled.

Timezone second-pass (TZ=Pacific/Kiritimati bash app/test.sh and Pago_Pago) is not in this PR. It lives on stacked task/msd-ci-tz-second-pass until harness Z1 (PR #14313) merges.

First CI run broke the build (35207698338)

The first version of this PR failed on GitHub Actions. Local checks could not see it: actionlint and the workflow-shape contracts do not execute Gradle, and the Harness lane doctor has no Android SDK, so the same flutter build apk / ./gradlew invocation was never run here (and was not installed).

Android Compile Smoke (Build Flutter Android dev debug APK) failed with:

Configuration cache state could not be cached: field builtInKotlinServices$delegate of com.android.build.gradle.internal.services.ProjectServices ... error writing value of type 'kotlin.SynchronizedLazyImpl'

That came from appending org.gradle.configuration-cache=true and problems=warn to gradle.properties on the runner. This project is AGP 8.11.1, Kotlin 2.2.20, Gradle 8.14.2. Warn mode does not downgrade a serialization failure of the cache state itself. Configuration cache is removed. The real savings are the Gradle User Home cache (setup-gradle, cache-read-only off main) and running the JVM tests in parallel.

Android JVM Unit Tests (Run Android JVM unit tests) never reached that Gradle error: ./gradlew: No such file or directory (exit 127). gradlew, gradle-wrapper.jar, and local.properties are gitignored; on main they were created by flutter build apk in the same job before :app:testDevDebugUnitTest. The parallel job never builds an APK, so it now runs flutter build apk --debug --flavor dev --target-platform android-arm64 --config-only first (generate files, do not compile).

Dart Analyze & Tests failed on app/test/unit/capture_recovery_replay_scenarios_test.dart process kill mid-capture (Expected length 1, Actual []). That is a pre-existing load-sensitive flake; the Harness lane root-caused and fixed it in open PR #14331. This PR does not touch that test.

Known gap, unchanged by this PR

arm64-only since c8f3506: extra ABIs OOM'd ubuntu-latest during stripDebugSymbols. Does not compile the JNI opus shim for armeabi-v7a or x86_64.

The hosted Linux Android emulator is x86_64. When that lane is designed, this job will not have caught a non-arm64 native compile break.

Product invariants affected

none

How it was verified

  • actionlint -shellcheck "" .github/workflows/mobile-app-checks.yml — exit 0
  • uv run --python 3.11.15 --with pytest pytest --noconftest backend/tests/unit/test_workflow_contracts.py — 28 passed
  • OMI_PR_BODY_FILE=.local/pr-body-v5.md make preflight — PR preflight passed: 33 checks in 273.44s

Could not verify: the hosted-runner Gradle/AGP path (no Android SDK on this host). The next push's own CI run is the verification.

app/AGENTS.md was left at origin/main because it is already at the 11,500-byte lean budget (170 lines / 11,495 bytes).

Fork PRs / secrets / cache poison

Measured from the job YAML (enforced by test_mobile_android_compile_smoke_uploads_debug_apk_and_runs_jvm_tests_in_parallel):

  • android-compile-smoke and android-unit-tests contain no ${{ secrets. references.
  • APK upload is actions/upload-artifact@v7 of app/build/app/outputs/flutter-apk/app-dev-debug.apk; no signing, no publish, no credentials.
  • Debug keystore is the in-repo file app/setup/prebuilt/debug.keystore with password android (not a GitHub secret). CI=true makes Gradle read CM_KEYSTORE_*; those env vars point at that file.
  • gradle/actions/setup-gradle@v6 uses cache-read-only: ${{ github.ref != 'refs/heads/main' }} on both jobs, so pull requests (including forks) read the Gradle User Home cache that main writes and cannot write/poison it. No configuration-cache encryption key.

Expected new critical path

Detect Changes + max(Generated Files, Dart Analyze & Tests, Android Compile Smoke APK-only, Android JVM Unit Tests with --config-only then Gradle, Seeded Journeys (hermetic))

The remaining long pole should be APK-only compile smoke, helped on PRs by reading the Gradle User Home cache that main writes. I do not claim a sub-10-minute median. Configuration cache is not part of that path.

Measurement the coordinator should take on this PR's own CI run

On the Mobile App Checks run for the exact head SHA:

  1. Workflow wall clock: run run_started_at → last job completed_at.
  2. Per-job duration for: Detect Changes, Android Compile Smoke, Android JVM Unit Tests, Dart Analyze & Tests, Seeded Journeys (hermetic), Generated Files.
  3. Confirm Compile Smoke and JVM tests overlap (neither needs the other).
  4. Confirm artifact app-dev-debug-<pull_request.head.sha> exists, 5-day retention, no signing/publish/secrets.
  5. Confirm the APK step used --target-platform android-arm64.
  6. Confirm neither job enables org.gradle.configuration-cache.
  7. Median of ten subsequent runs after main has seeded the Gradle cache — not this first PR run.

Tests

Workflow-shape contracts in backend/tests/unit/test_workflow_contracts.py:

  • Flutter-installing jobs must use the repo pin (action_count == pin_count, floor 5)
  • android-compile-smoke still named Android Compile Smoke, builds flutter build apk --debug --flavor dev --target-platform android-arm64, uploads app-dev-debug-<head-sha>, no longer runs :app:testDevDebugUnitTest
  • android-unit-tests runs --config-only then :app:testDevDebugUnitTest in parallel (needs: changes only, same has_app_compile_smoke gate)
  • both jobs: no ${{ secrets., in-repo debug keystore, cache-read-only off main, no org.gradle.configuration-cache
  • no timezone job in this workflow

journeys-hermetic is untouched.

Failure class (fixes)

Failure-Class: none

Git-on-my-level and others added 2 commits September 17, 2026 16:34
The APK build stays android-arm64 on every event, matching main since
c8f3506. Extra ABIs still OOM ubuntu-latest.

Co-authored-by: Cursor <[email protected]>
CI wiring lives in MOBILE_VERIFY.md so app/AGENTS.md stays inside its
lean budget.

Co-authored-by: Cursor <[email protected]>
Comment on lines +413 to +492
name: Android JVM Unit Tests
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.has_app_compile_smoke == 'true'
timeout-minutes: 25
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 1

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.44.5
cache: true

- name: Cache build_runner state
uses: actions/cache@v6
with:
path: app/.dart_tool/build
key: ${{ runner.os }}-flutter-buildrunner-${{ hashFiles('app/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-buildrunner-${{ hashFiles('app/pubspec.lock') }}-
${{ runner.os }}-flutter-buildrunner-

- name: Resolve Flutter dependencies
working-directory: app
run: flutter pub get

- name: Prepare Flutter dev compile inputs
working-directory: app
run: |
flutter build apk --debug --flavor dev --target-platform android-arm64
cd android
# Tests run on the JVM; their Flutter compilation dependency must keep
# the APK's target selection to reuse its outputs instead of rebuilding all ABIs.
./gradlew :app:testDevDebugUnitTest -Ptarget-platform=android-arm64
mkdir -p android/app/src/dev/ android/app/src/prod/
cp lib/firebase_options_local.dart lib/firebase_options_dev.dart
cp lib/firebase_options_local.dart lib/firebase_options_prod.dart
cp setup/prebuilt/google-services-local.json android/app/src/dev/google-services.json
cp setup/prebuilt/google-services-local.json android/app/src/prod/google-services.json
cp setup/prebuilt/key.properties android/key.properties
{
echo "API_BASE_URL="
echo "USE_WEB_AUTH=true"
echo "USE_AUTH_CUSTOM_TOKEN=true"
echo "STAGING_API_URL="
} > .dev.env
: > .env

- name: Generate Flutter code for JVM unit tests
working-directory: app
run: dart run build_runner build --delete-conflicting-outputs

- name: Enable Gradle configuration cache
working-directory: app/android
run: |
{
echo "org.gradle.configuration-cache=true"
echo "org.gradle.configuration-cache.problems=warn"
} >> gradle.properties

- name: Setup Gradle for Android JVM unit tests
uses: gradle/actions/setup-gradle@v6
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
cache-cleanup: on-success
gradle-home-cache-includes: |
caches
notifications
wrapper

- name: Run Android JVM unit tests
working-directory: app/android
env:
CM_KEYSTORE_PATH: ${{ github.workspace }}/app/setup/prebuilt/debug.keystore
CM_KEYSTORE_PASSWORD: android
CM_KEY_ALIAS: androiddebugkey
CM_KEY_PASSWORD: android
# Same target-platform as the APK job so a shared Gradle cache hit
# does not rebuild every ABI. This job does not wait for the APK.
run: ./gradlew :app:testDevDebugUnitTest -Ptarget-platform=android-arm64
Warn mode does not downgrade a cache-state serialization failure of
builtInKotlinServices. Generate the gitignored wrapper with --config-only
so the parallel JVM job can run without an APK compile.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 3043beb into main Sep 17, 2026
55 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-ci-v5-apk-artifact branch September 17, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants