Skip to content

Add workflow for recording Android screenshots with hardware-accelerated emulator#578

Merged
mmathieum merged 36 commits into
masterfrom
copilot/create-ci-workflow-screenshots
Feb 20, 2026
Merged

Add workflow for recording Android screenshots with hardware-accelerated emulator#578
mmathieum merged 36 commits into
masterfrom
copilot/create-ci-workflow-screenshots

Conversation

Copilot AI commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Adds manually-triggered GitHub Actions workflow to record Play Store screenshots using hardware-accelerated emulators with automated app setup.

Implementation

  • Dynamic API level: Parses sdk-target from commons/gradle/libs.versions.toml (currently 35) rather than hardcoding
  • Hardware acceleration: Enables KVM for GitHub's hardware-accelerated Android virtualization (10x+ faster than software emulation)
  • Emulator config:
    • Google APIs, x86_64 architecture
    • Pixel 7 Pro device profile for realistic screenshots
    • GPU set to swiftshader_indirect for Linux runner compatibility
    • Animations and spellchecker disabled for consistency
    • Optional timezone configuration from gtfs_rts_values_gen.xml
    • 180 second boot timeout for reliable startup
  • No AVD caching: Workflow intended for infrequent use (quarterly/yearly)
  • Workspace setup: Uses ./.github/actions/setup for consistent environment configuration (submodules, JDK, Gradle)
  • Flexible output modes: Boolean workflow input commitDirectly allows choosing between:
    • Creating a new branch with pull request (default)
    • Committing directly to the current branch
  • Automated setup: Script in shared/setup-and-all-app-screenshots.sh handles:
    • Downloading and installing main mtransit-for-android app from latest GitHub release
    • Granting location permissions to org.mtransit.android package
    • Setting GPS coordinates based on transit service area (supports both GTFS and bike station coordinate formats)
    • Optional timezone configuration from GTFS metadata
    • Downloading and installing current repository's module app from latest release
    • Disabling Pixel Launcher to prevent crash dialogs
    • Launching main app and waiting 10 seconds for initialization before screenshot capture
    • Calling commons-android/pub/all-app-screenshots.sh to capture screenshots
  • GPS Location Setup: Automatically parses area bounds from XML files:
    • GTFS transit: app-android/src/main/res-current/values/current_gtfs_rts_values_gen.xml (min/max lat/lng)
    • Bike stations: app-android/src/main/res/values/bike_station_values.xml (bike_station min/max lat/lng)
    • Calculates center point of service area and sets emulator GPS location
  • Timezone Configuration (optional): Reads timezone from gtfs_rts_values_gen.xml and configures emulator accordingly
  • Screenshot Quality Improvements:
    • Disables Pixel Launcher to prevent "not responding" crash dialogs
    • Adds -no-snapshot-save to emulator options to prevent saving corrupted launcher state
    • Launches main app before screenshot capture to ensure proper initialization
    • Results in clean, production-ready Play Store screenshots
  • Screenshot recording: Captures screenshots for all configured languages and places them in app-android/src/main/play/listings/*/graphics/*-screenshots/*.png
  • Output handling:
    • Uploads screenshot artifacts (30-day retention)
    • Creates/updates PR with new screenshots automatically against the correct base branch (when commitDirectly is false)
    • Commits directly to current branch (when commitDirectly is true)
    • Uses explicit title/body from commit message for PR creation

Workflow Location

Workflow placed in shared-overwrite/.github/workflows/ for distribution to all main repos via submodule sync.

Setup script placed in shared/ to be available during workflow execution without persisting in target repos.

Note: The workflow uses commons/gradle/libs.versions.toml path and supports multiple repository types (GTFS transit and bike stations) to correctly work when distributed to repositories that use commons as a submodule.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create CI workflow to record new screenshots</issue_title>
<issue_description>Add a new CI workflow that can be triggered manually to record screenshots.

GitHub-hosted Linux runners support hardware acceleration for Android SDK tools, which makes running Android tests much faster and consumes fewer minutes. For more information on Android hardware acceleration, see Configure hardware acceleration for the Android Emulator in the Android Developers documentation.

Read api-level from sdk-target in gradle/libs.versions.toml.

AVD snapshot caching is not necessary as this workflow with be use every few months/yearly at the most.

Links:

<agent_instructions>This workflow should be in https://github.com/mtransitapps/commons/tree/master/shared-overwrite/.github/workflows in order to be distributed to all main repos in next submodule sync.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 18, 2026 01:43
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
…references

Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CI workflow to record new screenshots Add workflow for recording Android screenshots with hardware-accelerated emulator Feb 18, 2026
Copilot AI requested a review from mmathieum February 18, 2026 01:46
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml Outdated
Copilot AI and others added 3 commits February 18, 2026 19:50
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Copilot AI and others added 3 commits February 18, 2026 20:00
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Comment thread shared-overwrite/setup-and-all-app-screenshots.sh Outdated
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml Outdated
Copilot AI and others added 2 commits February 18, 2026 20:10
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml Outdated
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Copilot AI requested a review from mmathieum February 19, 2026 14:07
mmathieum added a commit to mtransitapps/ca-dawson-creek-transit-system-bus-android that referenced this pull request Feb 19, 2026
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Copilot AI requested a review from mmathieum February 19, 2026 14:24
mmathieum added a commit to mtransitapps/ca-dawson-creek-transit-system-bus-android that referenced this pull request Feb 19, 2026
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
mmathieum added a commit to mtransitapps/ca-dawson-creek-transit-system-bus-android that referenced this pull request Feb 19, 2026
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Copilot AI requested a review from mmathieum February 19, 2026 15:18
mmathieum added a commit to mtransitapps/ca-dawson-creek-transit-system-bus-android that referenced this pull request Feb 19, 2026
@mmathieum

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces a new GitHub Actions workflow to automate the recording of Android screenshots. The workflow dynamically determines the API level, sets up the emulator, downloads APKs, sets GPS location and timezone, and then captures and uploads screenshots. It also handles committing the screenshots either directly to the branch or by creating a pull request. The changes are well-structured and address the requirements. I've identified a few areas for improvement regarding script reusability, error handling, and workflow logic, with specific attention to exit codes and their implications for subsequent steps, aligning with best practices for GitHub Actions workflows that generate and commit files.

Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared-overwrite/.github/workflows/mt-record-screenshots.yml
Comment thread shared/download_latest_apk.sh
Comment thread shared/download_latest_apk.sh
Comment thread shared/setup-and-all-app-screenshots.sh
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.

Create CI workflow to record new screenshots

2 participants