Skip to content

ci(android): Add a dispatch-only verify-pr test workflow - #7131

Merged
antonis merged 2 commits into
mainfrom
chore/verify-pr-spike-workflow
Nov 27, 2026
Merged

antonis merged 2 commits into
mainfrom
chore/verify-pr-spike-workflow

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Enhancement

📜 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.yml and .github/verify-pr-spike/spike.py, based on the Linux spike on chore/verify-pr-linux-spike (8b0c168).

The workflow is started by hand only (workflow_dispatch), with the inputs ref, pr and merge_sha. They reach steps only through env:.

Build job. Permissions are contents: read, and the job has no secrets.

  • Its first step rejects bad inputs before any checkout. ref must match ^verify/[A-Za-z0-9._-]+$, pr must be digits only, and merge_sha must be 40 hex characters.
  • It checks out inputs.ref with persist-credentials: false, and still fails if SENTRY_AUTH_TOKEN is in the environment.
  • It writes no cache. setup-node no longer caches yarn, and setup-gradle restores the Gradle cache with cache-read-only: true. The run starts on main but builds branch code, and other workflows on main restore those caches.
  • The run ids gh<run_id>-<run_attempt>-without and gh<run_id>-<run_attempt>-with are built in the workflow file and passed to the script.
  • Its only outputs are the two crash event ids.

Fetch job. Permissions are contents: read, and it has no checkout.

  • It is the only place that references secrets.SENTRY_AUTH_TOKEN.
  • It checks the event ids against the 32-hex pattern and refuses redirects.
  • It builds the expected run ids itself from github.run_id and github.run_attempt, in the same format, and refuses any event whose verify.run_id differs.
  • It reads tags from the event detail endpoint, which keeps null values, and publishes the same limited fields as before.
  • Each request may take at most 180 s, so four requests fit in 12 of the job's 20 minutes.

💡 Motivation and Context

#7127 needs this file on main, so it can be started with a branch as an input and use SENTRY_AUTH_TOKEN. Once it is on main, #7127 uses it for three things:

  1. A normal run, for fix(core): Remove native scope tags set to an empty value #7087.
  2. Showing that the workflow file comes from main: a marker step added to an input branch's copy of the file must not run.
  3. Showing that bad inputs stop the run before checkout.

Open question:

  • The script runs from the ref checkout, so ref must be a branch made from main after this merges. The real workflow should take the script from the workflow's own commit.

#skip-changelog

via Antonis Lilis.

--

View Session [Sentry]

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>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against cc653af

…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>
@antonis
antonis marked this pull request as ready for review November 27, 2026 14:41
@antonis
antonis merged commit 6f43f28 into main Nov 27, 2026
59 of 67 checks passed
@antonis
antonis deleted the chore/verify-pr-spike-workflow branch November 27, 2026 14:42
Comment on lines +41 to +45
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})")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_LINE requires date time pid tid level tag: msg (threadtime).
  • run_side dumps logs with adb logcat -d and no -v threadtime (line 234).
  • adb logcat defaults to brief (D/tag( pid): msg), which does not match this regex.
  • cmd_run fails when crash_event_ids does not return exactly one id, so without_event_id / with_event_id are never published.

Identified by Warden · code-review · 5HL-AVA

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem. Current adb prints threadtime by default, and the parsing found the right event ids in runs 45988566306, 46002801706 and 46018629282.

Comment on lines +123 to +133

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,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 build before revert, and packages/core/package.json points main at dist/js/index.js, which Metro bundles.
  • cmd_revert and cmd_restore apply source patches; cmd_build only invokes scripts/build-android.sh and does not rebuild packages/core or clear generated bundle outputs.
  • The Android verification instructions state Gradle does not track packages/core/dist as 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and known. This test workflow only handles PRs that change no JavaScript. The real workflow will rebuild packages/core on each side.

Comment on lines +412 to +419
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_WITHOUT and RUN_ID_WITH from github.run_id and github.run_attempt, passes them to Maestro, and the flow tags events with those values as verify.run_id.
  • The fetch job independently constructs EXPECTED_RUN_ID_* from the current github.run_attempt and passes them to summarize, where check_run_id rejects a differing tag.
  • On a failed-jobs rerun, GitHub increments run_attempt without 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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&lt;run_id&gt;-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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cc653af. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cc653af. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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