Skip to content

[build-tools] Upload Android simulator session logs - #4795

Draft
vonovak wants to merge 1 commit into
mainfrom
codex/android-session-logs
Draft

vonovak wants to merge 1 commit into
mainfrom
codex/android-session-logs

Conversation

@vonovak

@vonovak vonovak commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

Android simulator sessions already write emulator stdout/stderr and native logcat on the worker, but those files are unavailable after the session. When an emulator disappears during a transition or video playback, the existing session logs cannot explain why.

How

Summary

Android boot (standalone or agent device session)
  register the job's log directory before boot/retries
  keep existing emulator/logcat capture
cleanup: eas/collect_android_emulator_logs
  snapshot each launch's emulator.log and logcat.log
  upload through the existing session artifact API

The new Linux-only step has no required inputs. It collects only registered workflow directories, retains at most the last 20 MiB per file, and labels truncated artifacts visibly and in metadata. Files retain their unique launch-prefixed names and use kind simulator-log.

Each upload gets an independent 30-second budget and two attempts. Growing files have a fixed byte-range snapshot; retries reuse those bytes. Collection, upload, and snapshot cleanup failures are nonfatal. Concurrent or repeated collection does not duplicate successful artifacts. This includes a patch changeset for @expo/build-tools.

The companion Universe PR #32975 appends the step with if: '${{ always() }}' for Android device sessions. Deploy a worker containing this step before enabling that workflow change. Collection requires cleanup to run while the worker survives; this does not add crash classification, kernel logs, or periodic upload.

Test Plan

Evidence

  • Before: a real-file/HTTP regression reproduced an early HTTP 503 aborting an unfinished request body and incorrectly cancelling the remaining upload attempt.
  • After: the collector preserves retries for transport aborts while still stopping genuine file-read failures. The regression verifies the default 20 MiB cap, one artifact registration across retries, and repeated-collection deduplication.

Codex ran the following locally; all passed:

yarn workspace @expo/build-tools jest-unit --runInBand \
  androidEmulatorLogs.test.ts androidEmulatorLogsUpload.test.ts \
  collectAndroidEmulatorLogs.test.ts startAndroidEmulator.test.ts \
  startAgentDeviceSession.test.ts AndroidEmulatorUtils.test.ts \
  uploadWithSignedUrl.test.ts
# 7 suites, 94 tests passed

yarn workspace @expo/build-tools typecheck

Type-aware Oxlint passed on all 11 changed TypeScript files with zero warnings/errors. Oxfmt checked all 12 changed files, the formatter ran again before commit, and git diff --check passed.

GitHub CI passed on Node 22 and Node 24.

Staging validation

Codex executed six live cases on 2026-10-30 using the internal expo/eas-sim-create-test staging project and Android API 35:

  • Normal stop on Argent and agent-device: both logs uploaded and downloaded after job completion.
  • Emulator termination on Argent and agent-device: both logs remained downloadable after session-scoped adb emu kill and cleanup. This does not simulate host SIGKILL/OOM.
  • A native test app generated more than 20 MiB of logcat. Both marked runs retained exactly 20,971,520 bytes, reported truncation correctly, and preserved the final unique marker. Downloads had no duplicate filenames.
  • Invalid-APK setup failure: both logs uploaded while the job and session retained ERRORED. This tests failure after emulator boot; actual boot failure is covered by unit tests.
  • iOS smoke: finished successfully with existing recording, preview, and event artifacts and no Android artifacts.

All test sessions are terminal. The original staging Android worker was restored and its original checksum verified; the temporary PR API/website deployments were removed. Production and customer sessions were unchanged. The tests used the PR runtime code; a separate temporary branch only changed the artifact-building workflow. Worker archive build, preview deployment and E2E checks.

Merge Danger

Door: two-way

The new collector can be disabled in the generated workflow. Roll out the worker step before its universe caller.

Blast Radius: Android

Android device-session cleanup adds bounded log uploads through existing artifact permissions. Worker loss can still prevent collection. The draft remains open for human review.

Authorship and LLM use

The human scoped the work to existing emulator/logcat artifacts and authorized staging-only validation. Codex authored the implementation and tests and ran the local checks above. Parent-agent and separate read-only agent review identified cleanup deduplication, visible truncation, and retry handling issues; those were addressed, and final agent review found no remaining actionable issues. Human inspection and approval of the final diff are pending. Codex executed the staging checks above; human inspection and approval remain pending. This PR must remain a draft.

@github-actions

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.95833% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.42%. Comparing base (6f0f90b) to head (c492056).

Files with missing lines Patch % Lines
...build-tools/src/steps/utils/androidEmulatorLogs.ts 98.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4795      +/-   ##
==========================================
+ Coverage   76.38%   76.42%   +0.04%     
==========================================
  Files        1093     1095       +2     
  Lines       54720    54815      +95     
  Branches    12026    12043      +17     
==========================================
+ Hits        41794    41887      +93     
- Misses      11939    11941       +2     
  Partials      987      987              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant