Skip to content

Commit b7a62d3

Browse files
committed
Create Firebase Test Lab GitHub Actions workflow
This commit introduces a new GitHub Actions workflow to run Android UI tests on Firebase Test Lab. - The workflow is triggered on pushes and pull requests to the `main` branch. - It builds the debug app and test APKs. - It authenticates with Google Cloud and runs instrumentation tests on a Pixel 6 device. - A link to the Firebase Test Lab results is provided in the workflow output.
1 parent 2a13d6c commit b7a62d3

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Android UI Tests (Firebase Test Lab)
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
firebase-test-lab:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
14+
steps:
15+
# 1. Checkout code
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
# 2. Set up JDK (adjust version if needed)
20+
- name: Set up JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: temurin
24+
java-version: 21
25+
26+
# 3. Cache Gradle (important for speed)
27+
- name: Cache Gradle
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.gradle/caches
32+
~/.gradle/wrapper
33+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
34+
restore-keys: |
35+
${{ runner.os }}-gradle-
36+
37+
# 4. Build APKs (app + androidTest)
38+
- name: Build app and test APKs
39+
run: |
40+
./gradlew assembleDebug assembleDebugAndroidTest
41+
42+
# 5. Authenticate to Google Cloud
43+
- name: Authenticate to Google Cloud
44+
uses: google-github-actions/auth@v2
45+
with:
46+
credentials_json: ${{ secrets.GCP_SA_KEY }}
47+
48+
# 6. Set up gcloud CLI
49+
- name: Set up gcloud
50+
uses: google-github-actions/setup-gcloud@v2
51+
with:
52+
project_id: ${{ secrets.GCP_PROJECT_ID }}
53+
54+
# 7. Run Firebase Test Lab instrumentation tests
55+
- name: Run tests on Firebase Test Lab
56+
run: |
57+
gcloud firebase test android run \
58+
--type instrumentation \
59+
--app app/build/outputs/apk/debug/app-debug.apk \
60+
--test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
61+
--device model=Pixel6,version=33,locale=en,orientation=portrait \
62+
--timeout 15m \
63+
--results-bucket=${{ secrets.GCP_PROJECT_ID }}-test-lab-results
64+
65+
# 8. (Optional) Always print link to results
66+
- name: Firebase Test Lab results info
67+
if: always()
68+
run: |
69+
echo "View test results in the Firebase Console:"
70+
echo "https://console.firebase.google.com/project/${{ secrets.GCP_PROJECT_ID }}/testlab"

0 commit comments

Comments
 (0)