Repository navigation
ci(android): Add a dispatch-only verify-pr test workflow - #7131
Conversation
Test workflow for #7127, to be replaced by the real verify-pr workflow. It builds a verify/ branch without and with a PR's merge commit, runs the example flow on an Android emulator, and has a separate job, with no checkout, fetch the two crash events from Sentry. Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
…test workflow The run starts on main but builds branch code, and other workflows on main restore those caches. Also add github.run_attempt to the run ids, so a re-run gets new ones. Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
| LOGCAT_LINE = re.compile( | ||
| r"^\S+\s+\S+\s+(?P<pid>\d+)\s+(?P<tid>\d+)\s+[VDIWEF]\s+(?P<tag>\S+)\s*: (?P<msg>.*)$" | ||
| ) | ||
| UNCAUGHT = "Uncaught exception received." | ||
| CAPTURING = re.compile(r"Capturing event: ([0-9a-f]{32})") |
There was a problem hiding this comment.
crash_event_ids never matches default adb logcat format
Crash event id parsing requires threadtime logcat lines, but the dump uses plain adb logcat -d (default brief), so ids stay empty and the run step fails before the fetch job can run.
Evidence
LOGCAT_LINErequiresdate time pid tid level tag: msg(threadtime).run_sidedumps logs withadb logcat -dand no-v threadtime(line 234).adb logcatdefaults to brief (D/tag( pid): msg), which does not match this regex.cmd_runfails whencrash_event_idsdoes not return exactly one id, sowithout_event_id/with_event_idare never published.
Identified by Warden · code-review · 5HL-AVA
There was a problem hiding this comment.
Not a problem. Current adb prints threadtime by default, and the parsing found the right event ids in runs 45988566306, 46002801706 and 46018629282.
|
|
||
| def cmd_build(args): | ||
| side = args.side | ||
| env = dict(os.environ, RN_ARCHITECTURE="new", CONFIG="release") | ||
| start = time.time() | ||
| # `yarn build-android-release` drops extra arguments, so call the script it | ||
| # wraps. x86_64 only: the emulator's ABI, instead of all four. | ||
| run( | ||
| [str(SAMPLE / "scripts/build-android.sh"), "-PreactNativeArchitectures=x86_64"], | ||
| env=env, | ||
| ) |
There was a problem hiding this comment.
The without APK keeps the PR's JS bundle after the reverse-apply
For a PR that changes packages/core/src, the without build still bundles the dist output produced before the reverse-apply, so the two APKs do not represent the intended before-and-after SDK versions.
Evidence
- The workflow runs
yarn buildbeforerevert, andpackages/core/package.jsonpointsmainatdist/js/index.js, which Metro bundles. cmd_revertandcmd_restoreapply source patches;cmd_buildonly invokesscripts/build-android.shand does not rebuildpackages/coreor clear generated bundle outputs.- The Android verification instructions state Gradle does not track
packages/core/distas a bundle input and can reuse the previous JS bundle. Thus a JS SDK change remains in the without APK, invalidating the comparison.
Also found at 1 additional location
.github/workflows/verify-pr-spike.yml:143-157
Identified by Warden · code-review · BQA-8XY
There was a problem hiding this comment.
Correct, and known. This test workflow only handles PRs that change no JavaScript. The real workflow will rebuild packages/core on each side.
| run_id = os.environ[f"EXPECTED_RUN_ID_{side.upper()}"] | ||
| if not EVENT_ID.fullmatch(event_id): | ||
| failures.append(f"{side}: malformed event id from the build job") | ||
| continue | ||
| try: | ||
| _, raw = fetch(JSON_ENDPOINT, event_id, token) | ||
| detail_status, detail = fetch(DETAIL_ENDPOINT, event_id, token, DETAIL_REFUSALS) | ||
| summary = summarize(event_id, run_id, raw, detail_status, detail) |
There was a problem hiding this comment.
Fetch rejects valid events when only the failed job is rerun
Re-running only the failed fetch job increments github.run_attempt, so its expected run IDs no longer match the verify.run_id tags from the successful build; valid events are refused and the retry fails.
Evidence
- The build constructs
RUN_ID_WITHOUTandRUN_ID_WITHfromgithub.run_idandgithub.run_attempt, passes them to Maestro, and the flow tags events with those values asverify.run_id. - The fetch job independently constructs
EXPECTED_RUN_ID_*from the currentgithub.run_attemptand passes them tosummarize, wherecheck_run_idrejects a differing tag. - On a failed-jobs rerun, GitHub increments
run_attemptwithout rerunning the successful build, so the fetch job checks the earlier build's event IDs against the next attempt's run IDs.
Identified by Warden · code-review · CB7-CTD
There was a problem hiding this comment.
Fixed in #7132. The run ids are back to gh<run_id>-without and gh<run_id>-with in both jobs, without github.run_attempt, so re-running only the fetch job accepts the build's events.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cc653af. Configure here.
| WITHOUT_EVENT_ID: ${{ needs.build.outputs.without_event_id }} | ||
| WITH_EVENT_ID: ${{ needs.build.outputs.with_event_id }} | ||
| EXPECTED_RUN_ID_WITHOUT: gh${{ github.run_id }}-${{ github.run_attempt }}-without | ||
| EXPECTED_RUN_ID_WITH: gh${{ github.run_id }}-${{ github.run_attempt }}-with |
There was a problem hiding this comment.
Rerun attempt mismatches event run IDs
Medium Severity
The fetch job rebuilds expected verify.run_id values from the current github.run_attempt. After a successful build, Re-run failed jobs increments that attempt without re-running build, so fetch looks up gh<run_id>-2-… while Sentry still has the attempt-1 tags from the original build. Those events are refused and the two-hour build has to be repeated in full.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit cc653af. Configure here.
There was a problem hiding this comment.
Fixed in #7132. The run ids are back to gh<run_id>-without and gh<run_id>-with in both jobs, without github.run_attempt, so re-running only the fetch job accepts the build's events.
| record["maestro_exit"] = maestro.returncode | ||
| time.sleep(SEND_WAIT_SECONDS) | ||
|
|
||
| logcat = adb("logcat", "-d", capture_output=True, text=True).stdout |
There was a problem hiding this comment.
Logcat decode can drop crash IDs
Medium Severity
adb logcat -d is captured with text=True, which decodes as UTF-8 in strict mode. Device logs often contain non-UTF-8 bytes, so a UnicodeDecodeError can abort run_side after Maestro has already finished and skip writing crash_event_id, failing the job even when the crash was captured.
Reviewed by Cursor Bugbot for commit cc653af. Configure here.
There was a problem hiding this comment.
Fixed in #7132. adb logcat -d is now read as bytes and decoded with errors="replace", and the saved .logcat file is written from the same decoded text.


📢 Type of change
📜 Description
This is a test workflow for #7127. It will be replaced by the real verify-pr workflow. It adds
.github/workflows/verify-pr-spike.ymland.github/verify-pr-spike/spike.py, based on the Linux spike onchore/verify-pr-linux-spike(8b0c168).The workflow is started by hand only (
workflow_dispatch), with the inputsref,prandmerge_sha. They reach steps only throughenv:.Build job. Permissions are
contents: read, and the job has no secrets.refmust match^verify/[A-Za-z0-9._-]+$,prmust be digits only, andmerge_shamust be 40 hex characters.inputs.refwithpersist-credentials: false, and still fails ifSENTRY_AUTH_TOKENis in the environment.setup-nodeno longer caches yarn, andsetup-gradlerestores the Gradle cache withcache-read-only: true. The run starts onmainbut builds branch code, and other workflows onmainrestore those caches.gh<run_id>-<run_attempt>-withoutandgh<run_id>-<run_attempt>-withare built in the workflow file and passed to the script.Fetch job. Permissions are
contents: read, and it has no checkout.secrets.SENTRY_AUTH_TOKEN.github.run_idandgithub.run_attempt, in the same format, and refuses any event whoseverify.run_iddiffers.💡 Motivation and Context
#7127 needs this file on
main, so it can be started with a branch as an input and useSENTRY_AUTH_TOKEN. Once it is onmain, #7127 uses it for three things:main: a marker step added to an input branch's copy of the file must not run.Open question:
refcheckout, sorefmust be a branch made frommainafter this merges. The real workflow should take the script from the workflow's own commit.#skip-changelog
via Antonis Lilis.
--
View Session [Sentry]