Skip to content

Run the Android Robolectric tests in CI - #172

Draft
simonhamp wants to merge 4 commits into
mainfrom
claude/ci-android-robolectric-512a2b
Draft

simonhamp wants to merge 4 commits into
mainfrom
claude/ci-android-robolectric-512a2b

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

#147 added a Robolectric/Compose module under tests/android that only runs by hand against a local core checkout. This adds .github/workflows/android-tests.yml so it runs in CI.

How it works:

  • composer update --no-dev installs nativephp/mobile, and the module stages KeyboardFocusPolicy.kt and NativeUINode.kt from vendor/nativephp/mobile. mobile-air has no export-ignore rules, so the Composer dist includes resources/androidstudio.
  • Gradle runs through core's own wrapper in vendor/nativephp/mobile/resources/androidstudio/gradlew (8.14.5 today), the same command the module's README already documents. The module pins the same AGP as core (8.13.2), so the two move together.
  • JDK 21 from setup-java, with its Gradle cache. The runner's SDK is checked for platform 36 and it's installed if missing (ubuntu-latest has it today).
  • A last step writes the test counts to the job summary, since Gradle prints nothing for passing tests.
  • Own workflow rather than a job in tests.yml because paths filters a whole workflow. It runs on changes to resources/android/**, tests/android/**, composer.json and the workflow file. main has no required status checks, so the filter can't block a merge.
  • A workflow_dispatch input takes a nativephp/mobile version (for example dev-main) to test against something other than what composer.json resolves.

Expect this check to be red until #169

#147's editors pass a flush closure to KeyboardFocusPolicy.fieldFocused, which only exists in core since mobile-air#565. 4.6.0 doesn't have it, so the module fails at compileDebugKotlin with "Too many arguments for fieldFocused". It goes green once #169 requires ^4.7.

That compile error isn't specific to the test module. Any app on nativephp/mobile 4.6.0 that installs mobile-ui main will hit the same error in its Android build, and composer.json still allows 4.6.0. So #169 needs to land before the next mobile-ui tag.

Results

Core Run Result
4.6.0, as composer.json resolves today run Fails to compile, as above
mobile-air main at 08b825f (temporary commit, since reverted) run 12 tests, 0 failed, 0 skipped

Locally I also ran the pre-#147 renderers against mobile-air main to check the tests catch the bug: 8 failed (every blur and debounce case) and the 4 live cases passed, matching what #147 reported.

The two dev-main proof commits are in the history (TEMP, then its revert). They'll disappear with the squash merge.

Not changed

I didn't use gradle/actions/setup-gradle. Its v6 moved caching into a proprietary component with separate terms of use, and setup-java's built-in Gradle cache is enough here.

The Bridge.kt, Icon.kt and Menu.kt stubs stay. The real NativeUIBridge forwards to NativeElementBridge (JNI and PHP), and the stub is where the test records events. The real MaterialIcon loads core's R.font.material_icons, which needs core's resources under the com.nativephp.mobile namespace. The real ExpressiveMenu is in ContainerRenderers.kt, which pulls in NodeView and the renderer registry.

Things to look at

  • The path list should cover everything stageSources reads. Core files come in through composer.json, and any renderer this repo adds is already under resources/android/**.
  • Using core's wrapper means a Gradle bump in core changes the Gradle version used here without a change in this repo.

🤖 Generated with Claude Code

simonhamp and others added 4 commits October 24, 2026 02:10
The tests/android module added in #147 only ran by hand against a local
core checkout. This workflow runs it on PRs that touch the Android
renderers, the module, composer.json or the workflow, using the
nativephp/mobile copy Composer installs as the source of core's
KeyboardFocusPolicy.kt and NativeUINode.kt, and core's own Gradle wrapper.

It fails to compile against 4.6.0, which lacks the flush hook from
mobile-air#565, and goes green once composer.json requires ^4.7. A
workflow_dispatch input lets it run against dev-main until then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit cc99216. The job tests what composer.json resolves again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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