Skip to content

Add Android emulator testing to workflow #179

@marcprux

Description

@marcprux

With #172, we now have the option to build packages for Android from CI. But we don't yet have the ability to run tests.

Performing tests would involve downloading and configuring an Android emulator, ideally customizable with parameters like the Android API level to test. This sort of thing is handled nicely by the venerable android-emulator-runner action, and it is what my swift-android-action uses for testing against Android, but my understanding is that the swiftlang workflows don't want to rely on external actions. So we'd need to manage the setup of the emulator myself. I've put together a sample workflow that does this at https://github.com/swift-android-sdk/swift-android-sdk-workflow-demo/blob/main/.github/workflows/ci.yml to show how this might be accomplished.

The other issue is the complexity of running tests on a separate "host" that doesn't share the same file system. The cross-compiled test binary needs to be transferred over to the QEMU emulator, along with any resources that it depends on. This logic gets hairy, and sometimes requires special parameters to identify special files that need copying over (e.g., SwiftCrypto looks for some test files relative to the test's #filePath path … this won't work without modifying the test case to look elsewhere).

Finally, to support testing both XCTest and Swift Testing tests, there's some fancy footwork required, as discussed at swiftlang/swift-package-manager#8362 (comment). You can see how I do it at swift-android-action's action.yml.

All in all, it is achievable and I think it would be worthwhile for the benefit of actually exercising the tests on an Android emulator rather than just seeing if the source compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions