Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: firebase test lab action #446

Draft
wants to merge 2 commits into
base: staging
Choose a base branch
from
Draft
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
42 changes: 17 additions & 25 deletions .github/workflows/build_and_test_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ jobs:
name: Build and Test the SDK

steps:
- name: Install Docker to the Runner
run: sudo apt-get install docker

- name: Pull Emulator from the Repo
run: docker pull ${{ env.EMULATOR_REPO }}

- name: Checkout SDK code
uses: actions/checkout@v4

Expand All @@ -42,31 +36,29 @@ jobs:
- name: Setup Android SDK
uses: android-actions/[email protected]

- name: Start ADB Server
run: adb start-server

- name: Run Android Emulator Container
run: docker run -d -e "ADBKEY=$(cat ~/.android/adbkey)" --device /dev/kvm --publish 5555:5555/tcp ${{ env.EMULATOR_REPO }}

- name: Connect to the Emulator
run: adb connect localhost:5555

- name: Set AAPT2 for android 35
run: echo "android.aapt2FromMavenOverride=/usr/local/lib/android/sdk/build-tools/35.0.0/aapt2" | tee -a ${{ github.workspace }}/gradle.properties

- name: Build the SDK
if: always()
run: ./gradlew sdk:build

- name: Run the Android Unit Tests
if: always()
run: ./gradlew sdk:connectedAndroidTest
- name: Build the Android Test Apk
run: ./gradlew sdk:assembleAndroidTest

- name: Publish Test Results to PR
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
check_name: "Unit Test Results :rocket:"
comment_title: "Unit Test Results :rocket:"
files: |
sdk/build/outputs/androidTest-results/**/*.xml
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' #service account json

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'

- name: Set current project
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }}

- name: Run Instrumentation Tests in Firebase Test Lab
run: gcloud firebase test android run --type instrumentation --app sdk/build/outputs/apk/androidTest/debug/sdk-debug-androidTest.apk --test sdk/build/outputs/apk/androidTest/debug/sdk-debug-androidTest.apk --device model=MediumPhone.arm,version=26 --device model=MediumPhone.arm,version=27 --device model=MediumPhone.arm,version=28 --device model=MediumPhone.arm,version=29 --device model=MediumPhone.arm,version=30 --device model=MediumPhone.arm,version=31 --device model=MediumPhone.arm,version=32 --device model=MediumPhone.arm,version=33 --device model=MediumPhone.arm,version=34 --device model=MediumPhone.arm,version=35

13 changes: 12 additions & 1 deletion sdk/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ly.count.android.sdk">

<application>
<application android:allowBackup="true">
<activity
android:name=".TestUtils$Activity2"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:launchMode="singleTop"
android:exported="false"/>
<activity
android:name=".TestMainActivity"
android:exported="true"
android:excludeFromRecents="true"
android:noHistory="true">
<!-- Intent filter for launcher activity -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<uses-library android:name="android.test.runner"/>
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ly.count.android.sdk;

import android.app.Activity;
import android.os.Bundle;

public class TestMainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(android.R.layout.simple_spinner_item);
}
}

Loading