Skip to Content
Spawndroid
Guides

Test every PR on a real Android device

Add one GitHub Actions step and every pull request's APK opens on a hosted Android device, with the result, a live link and the recording in one PR comment.

Every pull request builds an APK. This guide sends that APK to a Spawndroid device, opens the app, and keeps it open for 30 seconds. If it crashes or stops responding, the pull request says so in plain words, with the first error from the log. Reviewers can open the same build in their browser without an account.

It works on the Hobby plan, inside its monthly device minutes. A 30 second smoke test uses one device minute.

The workflow

Add your API key as a repository secret named SPAWNDROID_API_KEY (API & CI/CD → API keys, upload scope), then commit this file as .github/workflows/spawndroid.yml:

on: pull_request
permissions: { contents: read, pull-requests: write }
jobs:
  device:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./gradlew assembleDebug
      - uses: spawndroid/cli@v0.3.1
        with: { api-key: "${{ secrets.SPAWNDROID_API_KEY }}", app: "app/build/outputs/apk/debug/*.apk" }

pull-requests: write lets the Action keep its comment on the pull request. If your build needs a specific JDK, add actions/setup-java before the Gradle step.

What the pull request shows

One comment, edited in place on every push. A rerun updates it; it never adds a second one. Results from earlier pushes fold into a collapsed Earlier pushes list.

ResultWhat it means
✅ PassedThe app opened, stayed running for the whole smoke test, and answered two taps near the end. Going to the background still counts as running.
❌ CrashedThe app crashed, or closed on its own. The comment names the exception and the line in your code, with the first error from the log folded underneath.
❌ Not respondingAndroid reported the app as not responding (an ANR). The smoke test taps the app 8 seconds before the end, so a hung main thread shows up even when nothing else touches the screen.
❌ FailedThe build would not install, for example an APK without arm64 libraries. The comment uses the same words as the run page.
⚪ Could not runThe test did not happen: no device was free, or the month's minutes are used up. It counts as neither a pass nor a fail.

Each result also has:

  • Try it live: this pull request's build on a device in the browser, no account needed. It needs the Spawndroid GitHub App on the repository: connect it under Settings → Integrations → GitHub. Public repositories start with previews off, because anyone who can see the pull request could use the workspace's minutes; turn them on per repository on the Integrations page.
  • Watch the recording: a read only page with the run's result, its screen recording and the screen it ended on. It opens without an account, never shows other runs, and expires after 30 days; any workspace member can revoke it from the run. For a private repository it is off until a workspace admin turns on Settings → Workspace → Public run links for private repositories; until then the comment links the run page, which needs an account.
  • The screen the run ended on, so a blank screen or a login wall shows in the pull request.
  • The run time and the device minutes it used.

When the minutes are used up, the comment says so and links to the upgrade. The job stays green.

Exit codes

ResultJob
Passedpasses
Crashed, not responding, tests failedfails
Failed: the build would not installfails, because the build itself is broken
Could not run for any other reasonpasses, with a warning. Set fail-on-could-not-run: true to fail it.

Pull requests from forks

GitHub gives pull requests from forks no secrets and a read only token, so the Action can neither run the test nor comment. It writes a note to the job summary and passes. A maintainer can test such a pull request by pushing its branch to the repository.

Run your own tests instead

Pass a command and the Action runs your Appium suite against the device instead of the smoke test. The command gets SPAWNDROID_WD_URL and the other session variables.

- uses: spawndroid/cli@v0.3.1
  with:
    api-key: ${{ secrets.SPAWNDROID_API_KEY }}
    app: app/build/outputs/apk/debug/*.apk
    command: npx wdio run wdio.conf.js

A suite that passes while the app crashed along the way stays a pass, and the comment adds a line saying the app crashed during the run.

Build in one job, test in another

Upload the APK as an artifact and pass its name:

- uses: spawndroid/cli@v0.3.1
  with:
    api-key: ${{ secrets.SPAWNDROID_API_KEY }}
    artifact: app-debug

The artifact must hold exactly one APK.

Several devices or builds

Every matrix job gets its own section in the same comment, named after its matrix leg, even when the jobs test files with the same name. Set label to name a section yourself. A matrix over profile:

strategy:
  matrix:
    profile: [android-14-phone, android-13-phone]
steps:
  - uses: spawndroid/cli@v0.3.1
    with:
      api-key: ${{ secrets.SPAWNDROID_API_KEY }}
      app: app/build/outputs/apk/debug/*.apk
      profile: ${{ matrix.profile }}

Inputs

InputDefault
api-keyYour upload key.
appPath or glob of the APK.
artifactArtifact holding the APK. Use this or app.
commandYour test command. Omit it for the smoke test.
smoke-seconds30How long the app stays open, 10 to 300.
profileDevice profile.
labelthe matrix legNames this job's section in the comment.
commenttrueKeep the pull request comment. On pushes the result goes to the job summary.
fail-on-could-not-runfalseFail the job when the test could not happen.

Outputs: status (passed, crashed, not-responding, failed, could-not-run, install-failed, minutes-out, no-key or fork), result, session-id and run-url.

Was this page helpful?

On this page