Skip to content

fix(ci): preinstall + cache the pinned Android NDK; re-time iOS Compile Check - #23084

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/ci-flakes
Oct 21, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/ci-flakes

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Kills the two mobile CI infra flakes from 2026-10-21 (both filed as CI debt on the rollout bus), using existing workflows only — no new workflow.

1. Android: preinstall + cache the pinned NDK (corrupt-download flake)

Every Gradle-configuring mobile job — Android Compile Smoke, Android JVM Unit Tests, Android Emulator Acceptance — auto-downloaded NDK 28.2.13676358 inside Gradle configure via AGP, which has no retry: one truncated dl.google.com response failed the job before any app code ran (Error on ZipFile unknown archive; runs 39506049904, 39469917718, 39626150998 — dead 5 s into a download that takes ~22 s when healthy; four hits in 48 h).

  • All three jobs pin NDK_VERSION in job env — the same variable app/android/app/build.gradle already resolves for ndkVersion.
  • Each job restores the extracted NDK under one shared cache key (${{ runner.os }}-android-ndk-<version>); only the Emulator job saves it (it runs in every event the readers do, and compile-smoke keeps post-job cache saves off the Mobile App Checks wall).
  • Each job preinstalls via .github/scripts/install_android_ndk.py: verifies the install from source.properties, purges the partial NDK dir + $ANDROID_HOME/.temp, retries once, 4-minute per-attempt timeout that kills sdkmanager's whole process group (the wrapper does not exec its Java worker), and passes --sdk_root so sdkmanager writes under the root the script verifies. Two attempts cost at most 8 min, which fits the 25-minute compile-smoke/JVM ceilings next to their ~13/~9 min p50 bodies.
  • On a cache hit the jobs make no NDK request to dl.google.com at all.

2. iOS Compile Check: ceiling 40 → 50 (post-job cache save was cancelled)

Run 39634604539 attempt 1 (PR #23068): real steps finished at 39:25 (16:12 manifest checks + 16:27 Xcode build, cold), then the post-job Post Setup Flutter cache save (59 s measured on the sibling success run 119312386446) hit the 40-min ceiling. The job reported cancelled after every real step passed, and Mobile Release Eligibility aggregated it as a failure. 50 keeps the wedge-guard above that measured cold path. The CI budget check counts p50 (19 min, unchanged), not the ceiling — check_ci_budget passes unchanged.

3. Contract tests (two new manifest checks)

  • mobile-ci-infra-guards — workflow invariants: the NDK pin equals build.gradle's ndkVersion fallback in all three jobs; exactly one NDK cache step per job under the shared key; exactly one cache writer whose event set covers every reader's; the installer invoked through an explicit python3; the iOS ceiling stays at 50.
  • mobile-ci-ndk-installer — installer behavior against a fake sdkmanager: present → skip; first-attempt success never retries and pins --sdk_root; corrupt first attempt is purged and retried once; double failure exits nonzero; a stale revision is not "installed"; a hung attempt has its whole process group killed (the fake's non-exec'd worker pid is proven dead) and recovers on retry; missing ANDROID_HOME is a usage error; --android-home wins over a divergent $ANDROID_HOME.

Product invariants affected

None — CI configuration, one CI helper script, and contract tests under .github/ only. No product path changes.

Failure class

Failure-Class: FC-gate-timeout-below-cold-cost

The iOS fix is exactly this class's contract: a fixed time budget must exceed the worst-case healthy cold cost, and the static timing-contract test (mobile-ci-infra-guards asserts the 50-min ceiling) keeps the value from silently regressing below the cold path again.

Verification (this worktree, base aa7e1d6)

  • run_checks.py --lane local — 8/8: mobile-ci-infra-guards 4/4, mobile-ci-ndk-installer 8/8, deferred-work-markers, workflow-checkout-stall-bounds, workflow-apt-network-bounds, ci-budget ("CI budget check passed"), main-push-ci-economy-contract 7/7, desktop-swift-ci-contract 52/52.
  • Standalone: test_check_ci_budget 12/12; manifest validation via run_checks (both new entries SELECTED).
  • actionlint on mobile-app-checks.yml: clean.

Notes

  • No deploy needed (CI config only).
  • The 14:52Z "in_progress after Complete job" anomaly on Generated Files / CodeQL Rust (~23 min of status lag at 14:37:37Z → ~15:00Z, then PASS) is GitHub-side status propagation (community discussions 15133 and 125013), not repo-fixable; documented in the rollout run records.

…le Check

Two mobile-app-checks infra flakes from 2026-10-21, both failing outside
any product code:

Android: every Gradle-configuring mobile job (compile-smoke, unit-tests,
emulator acceptance) auto-downloaded NDK 28.2.13676358 inside Gradle
configure via AGP, which has no retry. A truncated dl.google.com response
failed the job with "Error on ZipFile unknown archive" (runs 39506049904,
39469917718, 39626150998; dead 5 s into a download that takes ~22 s when
healthy). All three jobs now pin NDK_VERSION in job env (equal to
build.gradle's ndkVersion fallback, asserted by
test_mobile_ci_infra_guards.py), restore the extracted NDK from one shared
actions/cache key, and preinstall through install_android_ndk.py, which
verifies the install, purges partial NDK + sdkmanager temp state, and
retries once with a 10-minute per-attempt timeout. Only the emulator job
saves the cache: it runs in every event the readers do, and compile-smoke
keeps post-job saves off the Mobile App Checks wall. On a cache hit the
jobs make no NDK request to dl.google.com at all.

iOS: the 40-minute job ceiling sat below the measured cold path - 39:25 of
real steps plus the ~1 min post-job Post Setup Flutter cache save (run
39634604539 attempt 1) - so a healthy cold job reported cancelled after
every real step passed and Mobile Release Eligibility aggregated the
failure. The ceiling moves to 50 with the measurements recorded in the
workflow comment; the CI budget check counts p50 (19 min, unchanged), not
the ceiling.

Adds the mobile-ci-infra-guards and mobile-ci-ndk-installer manifest
checks covering both guards.

The timeout move is registered as a pinned exception in
scripts/ci/test_nightly_main_workflow.py (nightly-graph budget guard), which
asserts the exact new ceiling so any later drift still fails.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T19:36:22.638710Z 957eaf4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d2d27dd5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/scripts/install_android_ndk.py Outdated


def run_sdkmanager(sdkmanager: Path, version: str, timeout: float) -> bool:
command = [str(sdkmanager), f"ndk;{version}"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass the selected SDK root to sdkmanager

When --sdkmanager points to a tool from a different SDK than --android-home, this command installs into the SDK containing that tool rather than the directory later checked as ndk_dir; Android documents --sdk_root=path as the way to override that default (sdkmanager options). The verifier therefore reports failure and retries even if installation succeeded elsewhere. Pass the selected Android home via --sdk_root; the current override test misses this because its explicit path equals the inherited ANDROID_HOME.

Useful? React with 👍 / 👎.

…o 50

backend/tests/unit/test_workflow_contracts.py asserts the iOS Compile
Check timeout literally; it still said 40 after the ceiling moved to 50
(PR run 39654485678, backend unit shard 1/6). No other test pins the
value: the mobile-ci-infra-guards contract and the nightly budget
exception already assert 50.
…mpts in 25 min

Review round 1 (SHIP, two P2 findings) on #23084:

- A per-attempt timeout killed only the cmdline-tools sdkmanager wrapper,
  not the Java worker it spawns without exec, so a stalled extractor could
  keep writing into the tree the retry purges. sdkmanager now runs in its
  own session and the timeout kills the whole process group; the hung-
  attempt test records the worker's pid and asserts it is gone.
- A 600 s per-attempt cap did not fit the 25-minute Android Compile Smoke
  and JVM ceilings if the first attempt hung (600 s + ~22 s retry + ~20 min
  body > 25). The cap is 240 s: two attempts cost at most 8 min next to the
  ~13 / ~9 minute p50 bodies, still ~3 MB/s for a slow CDN day.
- sdkmanager receives --sdk_root=<android-home>, so it installs under the
  root this script verifies and purges even when --android-home diverges
  from $ANDROID_HOME (tested against a divergent environment).
- The writer-covers-readers guard now asserts each reader job's whole `if`
  is contained in the writer's, not only its event-name literals.
…the NDK

Review round 2 (FIX-FIRST, one P2) on #23084: after SIGKILLing the
sdkmanager process group, Popen.wait reaps only the wrapper, so the retry's
purge could start while a worker was still draining out of the run queue.
The timeout path now polls the group with signal 0 (bounded at 10 s) until
every member is gone before the purge and retry. The hung-attempt test's
fake records whether its non-exec'd worker still exists when the retry
invocation starts and asserts it is gone.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b5803eea0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +203 to +204
self.assertTrue(
pid_is_gone(child_pid),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat killed zombie workers as terminated

When this newly registered check runs in a container whose PID 1 does not reap orphaned children, the worker is successfully killed but remains a zombie, so os.kill(pid, 0) keeps succeeding and this assertion fails after five seconds. Running python3 .github/scripts/test_install_android_ndk.py for this commit in the provided container reproduced the failure with the worker in Z state; because zombies cannot continue writing, the test should recognize that state as terminated rather than requiring the PID to disappear.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 056c302 into main Oct 21, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/ci-flakes branch October 21, 2026 20:02
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