From 0e7fd48d41db0ea00f4baa60d36d4fdfce31df40 Mon Sep 17 00:00:00 2001 From: Wes Date: Sat, 21 Nov 2026 16:41:55 -0700 Subject: [PATCH] ci(mobile): run the Mobile Swift Native lane only for native changes (#9847) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What changes The Mobile Swift Native job rebuilds the iOS simulator app from scratch. On the run in #9809, `xcodebuild build-for-testing` took about 19 minutes and RunnerTests took about a minute. That PR changed the pubspec files, so it would select Native under this filter. For PRs, select Native for changes to `mobile/ios/`, `mobile/packages/`, `mobile/assets/`, `mobile/scripts/`, the pubspec files, the Flutter SDK pin, the four native test scripts, or either CI workflow that configures it. Changes to the SDK pin or the four native test scripts also select mobile CI. At GitHub’s 3,000-file listing limit, the selector runs all suites. When a PR selects mobile CI and touches none of the Native paths, Mobile Swift runs the unsigned iOS release build and skips the debug simulator build and its Apple Silicon linking check (#7646). Dart-only and Android-only mobile PRs are examples. Pushes to `main` and `release` run both Swift lanes whenever mobile CI is selected. A RunnerTest starts the normal Dart entry point in a Flutter engine. A Dart change that passes PR checks can therefore fail a simulator test on the merge commit. ## Validation - The local CI selection suite passed against the pinned `dorny/paths-filter` action with 83 passes and eight Linux-only skips. The required-context isolation contract also passed. - GitHub scheduled both Swift lanes on the initial revision `a34746e6`. Native passed in 14m35s and Release passed in 6m24s. [CI run](https://github.com/block/buzz/actions/runs/44863694135) - To verify hosted Release-only scheduling after merge, check the next mobile PR that changes none of the Native paths. Mobile Swift should show Release only, and the required Mobile check should report its result. --------- Signed-off-by: Wes Co-authored-by: Gamora --- .github/workflows/_ci-clients.yml | 13 ++++--- .github/workflows/ci.yml | 33 +++++++++++++++++ scripts/ci-runtime-selection.mjs | 9 ++++- scripts/ci-selection.test.mjs | 59 +++++++++++++++++++++++++++---- 4 files changed, 102 insertions(+), 12 deletions(-) diff --git a/.github/workflows/_ci-clients.yml b/.github/workflows/_ci-clients.yml index a6bdb4d1fc..bf2d81aa81 100644 --- a/.github/workflows/_ci-clients.yml +++ b/.github/workflows/_ci-clients.yml @@ -8,6 +8,11 @@ on: mobile: required: true type: boolean + # Whether the change touches what the Mobile Swift Native lane builds. + mobile_native: + required: false + type: boolean + default: true lane: required: true type: string @@ -236,12 +241,10 @@ jobs: if: inputs.lane == 'mobile-swift' && inputs.mobile strategy: fail-fast: false + # The Native lane spends most of its time on a cold simulator build, so + # it runs only when the change touches what that build compiles. matrix: - include: - - name: Native - lane: native - - name: Release - lane: release + include: ${{ fromJSON(inputs.mobile_native && '[{"name":"Native","lane":"native"},{"name":"Release","lane":"release"}]' || '[{"name":"Release","lane":"release"}]') }} steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77e51db63c..e85fd07876 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: desktop-rust: ${{ steps.selection.outputs.desktop-rust }} web: ${{ steps.selection.outputs.web }} mobile: ${{ steps.selection.outputs.mobile }} + mobile-native: ${{ steps.selection.outputs.mobile-native }} steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: @@ -100,8 +101,15 @@ jobs: - 'pnpm-lock.yaml' mobile: - 'mobile/**' + - 'bin/flutter' + - 'bin/dart' + - 'bin/.flutter-*.pkg' - 'Justfile' - 'scripts/test-mobile-gateway-recipes.sh' + - 'scripts/test-mobile-pagination.sh' + - 'scripts/test-mobile-pagination-accessibility.sh' + - 'scripts/test-mobile-carousel.sh' + - 'scripts/test-mobile-member-picker.sh' - 'scripts/mobile-release.sh' - 'scripts/mobile-release-source.sh' - 'scripts/mobile-worktree-overrides.sh' @@ -112,6 +120,27 @@ jobs: - 'scripts/ci-hermit-retry.sh' - '.github/workflows/ci.yml' - '.github/workflows/_ci-*.yml' + # What the Mobile Swift Native lane compiles and runs. Dart-only + # changes skip its simulator build; the Release lane still builds + # iOS for every mobile change. + mobile-native: + - 'mobile/ios/**' + - 'mobile/packages/**' + # Native code loads fonts and emoji data from the Flutter asset + # bundle, and the Xcode build runs a script from mobile/scripts. + - 'mobile/assets/**' + - 'mobile/scripts/**' + - 'mobile/pubspec.yaml' + - 'mobile/pubspec.lock' + - 'bin/flutter' + - 'bin/dart' + - 'bin/.flutter-*.pkg' + - 'scripts/test-mobile-pagination.sh' + - 'scripts/test-mobile-pagination-accessibility.sh' + - 'scripts/test-mobile-carousel.sh' + - 'scripts/test-mobile-member-picker.sh' + - '.github/workflows/ci.yml' + - '.github/workflows/_ci-clients.yml' - name: Select runtime suites conservatively at the PR file-list limit id: selection env: @@ -267,6 +296,10 @@ jobs: with: web: ${{ needs.changes.outputs.web == 'true' }} mobile: ${{ needs.changes.outputs.mobile == 'true' }} + # Pull requests skip the Native lane for changes outside its paths. A + # push still runs it for every mobile change, so a Dart change that + # breaks a native test fails on its own commit. + mobile_native: ${{ github.event_name == 'push' || needs.changes.outputs.mobile-native == 'true' }} lane: mobile-swift # Advisory flake check: repeats the tests a pull request changes. Its lanes diff --git a/scripts/ci-runtime-selection.mjs b/scripts/ci-runtime-selection.mjs index bef2a2b1a4..08ba4e3ea1 100644 --- a/scripts/ci-runtime-selection.mjs +++ b/scripts/ci-runtime-selection.mjs @@ -14,7 +14,14 @@ if (process.env.GITHUB_EVENT_NAME === "pull_request") { // potentially incomplete list to skip a runtime suite. runAll = count >= 3000; } -for (const key of ["rust", "desktop", "desktop-rust", "web", "mobile"]) { +for (const key of [ + "rust", + "desktop", + "desktop-rust", + "web", + "mobile", + "mobile-native", +]) { assert.ok( ["true", "false"].includes(filters[key]), `Invalid ${key} selection`, diff --git a/scripts/ci-selection.test.mjs b/scripts/ci-selection.test.mjs index 821d4f0884..0c73276ff2 100644 --- a/scripts/ci-selection.test.mjs +++ b/scripts/ci-selection.test.mjs @@ -181,7 +181,7 @@ async function select(paths, pullRequest = false, apiStatus = 200) { const rawOutputs = Object.fromEntries( [ ...readFileSync(output, "utf8").matchAll( - /^(rust|desktop|desktop-rust|web|mobile)<<([^\n]+)\n(true|false)\n\2/gm, + /^(rust|desktop|desktop-rust|web|mobile|mobile-native)<<([^\n]+)\n(true|false)\n\2/gm, ), ].map(([, key, , value]) => [key, value]), ); @@ -216,7 +216,47 @@ const scenarios = [ ], ["mobile"], ], - ["mobile lockfile", ["mobile/pubspec.lock"], ["mobile"]], + ["mobile lockfile", ["mobile/pubspec.lock"], ["mobile", "mobile-native"]], + [ + "Flutter SDK pin", + ["bin/.flutter-3.47.9.pkg"], + ["mobile", "mobile-native"], + ], + [ + "mobile bundled font", + ["mobile/assets/fonts/InterVariable.ttf"], + ["mobile", "mobile-native"], + ], + [ + "mobile build script", + ["mobile/scripts/require-push-gateway-origin.sh"], + ["mobile", "mobile-native"], + ], + [ + "mobile iOS source", + ["mobile/ios/Runner/IosMediaCarousel.swift"], + ["mobile", "mobile-native"], + ], + [ + "mobile native package", + ["mobile/packages/buzz_secp256k1/src/buzz_secp256k1_ecdh.c"], + ["mobile", "mobile-native"], + ], + [ + "mobile Android source", + ["mobile/android/app/build.gradle.kts"], + ["mobile"], + ], + [ + "mobile native control script", + ["scripts/test-mobile-carousel.sh"], + ["mobile", "mobile-native"], + ], + [ + "clients workflow", + [".github/workflows/_ci-clients.yml"], + ["mobile", "mobile-native", "rust"], + ], [ "mobile release source helper", ["scripts/mobile-release-source.sh"], @@ -235,7 +275,7 @@ const scenarios = [ [ "shared workflow", [".github/workflows/ci.yml"], - ["desktop", "mobile", "rust"], + ["desktop", "mobile", "mobile-native", "rust"], ], [ "desktop workflow", @@ -300,7 +340,7 @@ const scenarios = [ for (const [name, paths, expected] of scenarios) { test(`real paths-filter: ${name}`, async () => { const outputs = await select(paths); - assert.equal(Object.keys(outputs).length, 5); + assert.equal(Object.keys(outputs).length, 6); assert.deepEqual( Object.keys(outputs) .filter((key) => outputs[key] === "true") @@ -329,7 +369,7 @@ for (const [name, paths, expected] of [ ]) { test(`PR file list ignores newer base changes: ${name}`, async () => { const outputs = await select(paths, true); - assert.equal(Object.keys(outputs).length, 5); + assert.equal(Object.keys(outputs).length, 6); assert.deepEqual( Object.keys(outputs) .filter((key) => outputs[key] === "true") @@ -341,7 +381,14 @@ for (const [name, paths, expected] of [ test("workflow consumes guarded selection outputs", () => { const outputs = workflow.match(/ {4}outputs:\n([\s\S]*?) {4}steps:/)[1]; - for (const key of ["rust", "desktop", "desktop-rust", "web", "mobile"]) { + for (const key of [ + "rust", + "desktop", + "desktop-rust", + "web", + "mobile", + "mobile-native", + ]) { assert.ok(outputs.includes(`steps.selection.outputs.${key}`)); } assert.match(