Urgent.News

What's breaking now, across thousands of outlets.

Tech

Run Android Tests on Real Phones in GitHub Actions

Emulators in CI are fine until your app cares about being on a real device. Once a sensor check or hardware-specific behaviour enters the picture, a green pipeline stops meaning much. I run a rack of real Android phones in Singapore that people drive over adb, and this came out of running it. Here is the workflow I'd start from, including the parts that fail quietly the first time you try it on a…

Running Android tests on real devices through GitHub Actions is essential when your app relies on hardware-specific behavior or sensor checks. Emulators can only provide limited assurance, and a green pipeline in such scenarios may not be meaningful. The author has set up a rack of real Android phones in Singapore, accessible via adb from a hosted runner.

The workflow begins with setting up the job in a repository. The workflow triggers on push or pull request events and runs on Ubuntu. The steps include checking out the code, setting up Android, building the debug APK, connecting to the device, installing the app, running tests, and disconnecting from the device. The connect step retries up to five times if the connection fails initially. The disconnect step ensures the device is properly released after each test run.

The key points to note are the use of secrets for the Android Debug Bridge (adb) endpoint and any related tokens, keeping the sensitive information out of the workflow file and logs. The connect step uses a loop to handle potential network issues, and the disconnect step is always executed, regardless of test outcomes, to ensure proper cleanup.

One common issue in CI environments is the mismatch between the adb server version on the runner and the phone. Using the `setup-android` action helps ensure you have the latest platform-tools. Another issue is signature errors during installation, which can be resolved by uninstalling the previous build before installing the new one.

Tests may also hang or time out due to default adb timeouts optimized for cable connections rather than network hops. Increasing the timeouts can help mitigate this problem. Additionally, when multiple pull requests trigger simultaneously, they might compete for the same phone, causing state corruption. Using a concurrency group for device jobs helps prevent this issue by queuing the jobs instead of allowing them to collide.

If multiple phones are required, the process can be scaled using a matrix strategy. Each phone gets its own secret, and the workflow can be configured to run jobs for each phone's endpoint in parallel. This approach allows running tests on various devices simultaneously, providing a more comprehensive testing experience.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Your webhook handler was slow, so Shopify sent it again

The server reboots at two on a Saturday morning for a security update, which is what it's supposed to do. The app doesn't come back, because nobody told the process manager to start it on boot.

  • Shopify resends webhooks if app response exceeds five-second limit
  • Duplicate records occur when server takes too long to acknowledge
  • Self-hosted apps at risk due to downtime and lack of resilience

Hey all..

I’m Darshan, a software engineer, founder and builder from India. I spend most of my time building products, experimenting with AI, automating things.

More from Tuesday 6 October →