From e5cf2b48850ecdfe18d0c2f477583577e4677afc Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Tue, 7 Jan 2025 16:59:15 +0300 Subject: [PATCH] feat: firebase test lab action --- .github/workflows/build_and_test_sdk.yml | 27 ++++++++++++------- sdk/src/androidTest/AndroidManifest.xml | 13 ++++++++- .../count/android/sdk/TestMainActivity.java | 13 +++++++++ 3 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 sdk/src/androidTest/java/ly/count/android/sdk/TestMainActivity.java diff --git a/.github/workflows/build_and_test_sdk.yml b/.github/workflows/build_and_test_sdk.yml index 337a514f4..5f1c220eb 100644 --- a/.github/workflows/build_and_test_sdk.yml +++ b/.github/workflows/build_and_test_sdk.yml @@ -58,15 +58,22 @@ jobs: 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: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' #service account json + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' with: - check_name: "Unit Test Results :rocket:" - comment_title: "Unit Test Results :rocket:" - files: | - sdk/build/outputs/androidTest-results/**/*.xml + 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=Medium Phone,version=26 --device model=Medium Phone,version=27 --device model=Medium Phone,version=28 --device model=Medium Phone,version=29 --device model=Medium Phone,version=30 --device model=Medium Phone,version=31 --device model=Medium Phone,version=32 --device model=Medium Phone,version=33 --device model=Medium Phone,version=34 --device model=Medium Phone,version=35 + diff --git a/sdk/src/androidTest/AndroidManifest.xml b/sdk/src/androidTest/AndroidManifest.xml index 6d6c61e8a..2bc8a1b8d 100644 --- a/sdk/src/androidTest/AndroidManifest.xml +++ b/sdk/src/androidTest/AndroidManifest.xml @@ -2,7 +2,7 @@ - + + + + + + + + diff --git a/sdk/src/androidTest/java/ly/count/android/sdk/TestMainActivity.java b/sdk/src/androidTest/java/ly/count/android/sdk/TestMainActivity.java new file mode 100644 index 000000000..915457a94 --- /dev/null +++ b/sdk/src/androidTest/java/ly/count/android/sdk/TestMainActivity.java @@ -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); + } +} +