Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/demo-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Opens every demo in maps-app on an emulator, directly and through the menu, and checks that it
# starts, its map loads, and it survives a zoom and a configuration change. The tests live in
# maps-app/src/androidTest/.../compose/smoke and are excluded from the instrumentation workflow.
name: Demo smoke test

on:
repository_dispatch:
types: [test]
pull_request:
branches-ignore: ['gh-pages']
workflow_dispatch:

permissions:
contents: read

jobs:
demo-smoke-test:
# Ubuntu runners support KVM, which boots the API 36 emulator in about a minute.
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Secrets are not available to pull requests from forks or Dependabot. Without a real key
# the maps never load, so skip the emulator run instead of reporting noise.
- name: Check for Maps API key
id: key
env:
MAPS_API_KEY: ${{ secrets.ACTIONS_API_KEY }}
run: |
if [ -z "$MAPS_API_KEY" ]; then
echo "::notice::ACTIONS_API_KEY is not available, skipping the demo smoke test."
echo "available=false" >> "$GITHUB_OUTPUT"
else
echo "MAPS_API_KEY=$MAPS_API_KEY" > secrets.properties
echo "available=true" >> "$GITHUB_OUTPUT"
fi

- name: Set up JDK 21
if: steps.key.outputs.available == 'true'
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
if: steps.key.outputs.available == 'true'
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0

- name: Enable KVM
if: steps.key.outputs.available == 'true'
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Build demo and test APKs
if: steps.key.outputs.available == 'true'
run: ./gradlew :maps-app:assembleDebug :maps-app:assembleDebugAndroidTest --stacktrace

- name: Run demo smoke test
if: steps.key.outputs.available == 'true'
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
# Emulators never update Google Play services, so the image's bundled version is what the
# maps run on. Older images bundle a version where adding advanced markers crashes inside
# Play services. API 36 images bundle 25.26, which works.
api-level: 36
target: google_apis
arch: x86_64
disable-animations: true
script: >-
./gradlew :maps-app:connectedDebugAndroidTest --stacktrace
-Pandroid.testInstrumentationRunnerArguments.package=com.google.maps.android.compose.smoke
-Pandroid.testInstrumentationRunnerArguments.requireMapLoaded=true

- name: Upload test reports
if: always() && steps.key.outputs.available == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: demo-smoke-test-reports
path: |
maps-app/build/reports/androidTests
maps-app/build/outputs/androidTest-results
3 changes: 2 additions & 1 deletion .github/workflows/instrumentation-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jobs:
target: google_apis
arch: x86
disable-animations: true
script: ./gradlew createDebugCoverageReport --stacktrace
# The demo smoke tests run in their own workflow, see demo-smoke-test.yml.
script: ./gradlew createDebugCoverageReport --stacktrace -Pandroid.testInstrumentationRunnerArguments.notPackage=com.google.maps.android.compose.smoke

# Stage the coverage reports flat, named after their module, and publish
# them so the post-merge "Record coverage history" workflow can read them
Expand Down
16 changes: 16 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ Note that the library modules currently have almost no unit tests. The bulk of
the suite is instrumentation tests under `maps-app/src/androidTest`, so the
`unit` numbers are near zero by nature rather than by regression.

The demo smoke tests in `maps-app/src/androidTest/.../compose/smoke` run in
their own `Demo smoke test` workflow on API 36, and are excluded from the
instrumentation workflow above, so they do not count towards instrumentation
coverage. `DemoAppSmokeTest` launches every demo directly, `DemoMenuNavigationTest`
opens each one from the menu and navigates back, and `DemoRegistryTest` keeps the
menu and the manifest in sync. Add new demos to `allActivityGroups` in `Demo.kt`
and they are covered automatically. To run them with a device or emulator attached:

```bash
./gradlew :maps-app:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.package=com.google.maps.android.compose.smoke
```

Add `-Pandroid.testInstrumentationRunnerArguments.requireMapLoaded=true` to also
wait for map tiles to render, which needs a real key.

Running `maps-app` requires a Maps API key: put `MAPS_API_KEY=...` in
`secrets.properties` at the repo root (see `local.defaults.properties` for the
template). Never hardcode or commit API keys.
Expand Down
Loading
Loading