|
| 1 | +name: In-App Message E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ InApp-Display-E2E ] |
| 6 | + pull_request: |
| 7 | + branches: [ InApp-Display-E2E, master, develop ] |
| 8 | + workflow_dispatch: # Allow manual triggering |
| 9 | + |
| 10 | +jobs: |
| 11 | + inapp-e2e-tests: |
| 12 | + name: In-App Message E2E Tests |
| 13 | + runs-on: macos-13 # Intel host → HVF works, emulator boots |
| 14 | + |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + api-level: [34] # MVP testing on most relevant API level only |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up JDK 17 |
| 24 | + uses: actions/setup-java@v4 |
| 25 | + with: |
| 26 | + java-version: '17' |
| 27 | + distribution: 'temurin' |
| 28 | + |
| 29 | + - name: Set up Android SDK |
| 30 | + uses: android-actions/setup-android@v2 |
| 31 | + |
| 32 | + - name: Create local.properties |
| 33 | + run: | |
| 34 | + echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties |
| 35 | + echo "ndk.dir=$ANDROID_SDK_ROOT/ndk" >> local.properties |
| 36 | + |
| 37 | + - name: Accept Android SDK Licenses |
| 38 | + run: | |
| 39 | + echo "Accepting Android SDK licenses..." |
| 40 | + yes | sdkmanager --licenses || true |
| 41 | + echo "SDK licenses accepted" |
| 42 | + |
| 43 | + - name: Setup Google Services Configuration |
| 44 | + run: | |
| 45 | + echo "Setting up Google Services configuration for CI..." |
| 46 | + # Ensure the google-services.json file exists for the build |
| 47 | + if [ ! -f "integration-tests/google-services.json" ]; then |
| 48 | + echo "Creating google-services.json from template..." |
| 49 | + cp integration-tests/google-services.json.template integration-tests/google-services.json |
| 50 | + fi |
| 51 | + echo "Google Services configuration ready" |
| 52 | + |
| 53 | + - name: Cache Gradle packages |
| 54 | + uses: actions/cache@v3 |
| 55 | + with: |
| 56 | + path: | |
| 57 | + ~/.gradle/caches |
| 58 | + ~/.gradle/wrapper |
| 59 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-gradle- |
| 62 | + |
| 63 | + - name: Pre-download Gradle and Build (Parallel with Emulator) |
| 64 | + run: | |
| 65 | + echo "Pre-downloading Gradle and building while emulator boots..." |
| 66 | + # Download Gradle wrapper in background |
| 67 | + ./gradlew --version & |
| 68 | + # Start building APKs in background |
| 69 | + ./gradlew :integration-tests:assembleDebug :integration-tests:assembleDebugAndroidTest --no-daemon & |
| 70 | + echo "Build started in background..." |
| 71 | + |
| 72 | + - name: Run UI Tests with Emulator (Intel / x86_64) |
| 73 | + uses: ReactiveCircus/android-emulator-runner@v2 |
| 74 | + with: |
| 75 | + api-level: ${{ matrix.api-level }} |
| 76 | + target: google_apis |
| 77 | + arch: x86_64 |
| 78 | + profile: pixel_6 |
| 79 | + cores: 2 |
| 80 | + ram-size: 3072M |
| 81 | + heap-size: 576M |
| 82 | + force-avd-creation: true |
| 83 | + disable-animations: true |
| 84 | + emulator-boot-timeout: 900 |
| 85 | + emulator-options: -no-window -no-snapshot -gpu swiftshader_indirect -no-boot-anim -camera-back none -partition-size 6000 |
| 86 | + pre-emulator-launch-script: | |
| 87 | + # Clean + start adb after platform-tools exist (avoids tcp:5037 noise) |
| 88 | + adb kill-server >/dev/null 2>&1 || true |
| 89 | + adb start-server |
| 90 | + script: | |
| 91 | + echo "Emulator is ready! Running tests..." |
| 92 | + echo "Setting up permissions..." |
| 93 | + adb shell pm grant com.iterable.integration.tests android.permission.POST_NOTIFICATIONS |
| 94 | + adb shell pm grant com.iterable.integration.tests android.permission.INTERNET |
| 95 | + adb shell pm grant com.iterable.integration.tests android.permission.ACCESS_NETWORK_STATE |
| 96 | + adb shell pm grant com.iterable.integration.tests android.permission.WAKE_LOCK |
| 97 | + |
| 98 | + echo "Running In-App Message MVP test..." |
| 99 | + echo "Debug: Checking if APKs are ready..." |
| 100 | + ls -la integration-tests/build/outputs/apk/ || echo "APK directory not found" |
| 101 | + |
| 102 | + echo "Debug: Verifying API keys are set..." |
| 103 | + echo "ITERABLE_API_KEY length: ${#ITERABLE_API_KEY}" |
| 104 | + echo "ITERABLE_SERVER_API_KEY length: ${#ITERABLE_SERVER_API_KEY}" |
| 105 | + echo "ITERABLE_TEST_USER_EMAIL: $ITERABLE_TEST_USER_EMAIL" |
| 106 | + |
| 107 | + # Start logcat in background for crash debugging |
| 108 | + adb logcat > /tmp/test-logcat.log & |
| 109 | + LOGCAT_PID=$! |
| 110 | + |
| 111 | + # Run the specific test with better error handling |
| 112 | + ./gradlew :integration-tests:connectedDebugAndroidTest \ |
| 113 | + -Pandroid.testInstrumentationRunnerArguments.class=com.iterable.integration.tests.InAppMessageIntegrationTest#testInAppMessageMVP \ |
| 114 | + --stacktrace --no-daemon || { |
| 115 | + echo "Test failed! Collecting crash logs..." |
| 116 | + kill $LOGCAT_PID 2>/dev/null || true |
| 117 | + echo "=== CRASH LOGS ===" |
| 118 | + tail -100 /tmp/test-logcat.log |
| 119 | + echo "=== END CRASH LOGS ===" |
| 120 | + exit 1 |
| 121 | + } |
| 122 | + |
| 123 | + # Stop logcat |
| 124 | + kill $LOGCAT_PID 2>/dev/null || true |
| 125 | + env: |
| 126 | + ITERABLE_API_KEY: ${{ secrets.BCIT_ITERABLE_API_KEY }} |
| 127 | + ITERABLE_SERVER_API_KEY: ${{ secrets.BCIT_ITERABLE_SERVER_API_KEY }} |
| 128 | + ITERABLE_TEST_USER_EMAIL: ${{ secrets.BCIT_ITERABLE_TEST_USER_EMAIL }} |
| 129 | + |
| 130 | + # - name: Generate Test Report |
| 131 | + # if: always() |
| 132 | + # run: | |
| 133 | + # echo "Generating E2E test report..." |
| 134 | + # ./gradlew :integration-tests:jacocoIntegrationTestReport |
| 135 | + |
| 136 | + # - name: Collect Test Logs |
| 137 | + # if: always() |
| 138 | + # run: | |
| 139 | + # echo "Collecting E2E test logs..." |
| 140 | + # adb logcat -d > integration-tests/build/e2e-test-logs.txt |
| 141 | + |
| 142 | + # # Also collect specific test logs |
| 143 | + # adb logcat -d | grep -E "(InAppMessageIntegrationTest|BaseIntegrationTest|IterableApi)" > integration-tests/build/inapp-specific-logs.txt |
| 144 | + |
| 145 | + # - name: Take Screenshots for Debugging |
| 146 | + # if: always() |
| 147 | + # run: | |
| 148 | + # echo "Taking screenshots for debugging..." |
| 149 | + # mkdir -p integration-tests/screenshots |
| 150 | + # adb shell screencap -p /sdcard/screenshot.png |
| 151 | + # adb pull /sdcard/screenshot.png integration-tests/screenshots/final-state-api-${{ matrix.api-level }}.png |
| 152 | + |
| 153 | + # - name: Upload Test Results |
| 154 | + # if: always() |
| 155 | + # uses: actions/upload-artifact@v4 |
| 156 | + # with: |
| 157 | + # name: inapp-e2e-test-results-api-${{ matrix.api-level }} |
| 158 | + # path: | |
| 159 | + # integration-tests/build/reports/ |
| 160 | + # integration-tests/build/outputs/ |
| 161 | + # integration-tests/build/e2e-test-logs.txt |
| 162 | + # integration-tests/build/inapp-specific-logs.txt |
| 163 | + |
| 164 | + # - name: Upload Coverage Report |
| 165 | + # if: always() |
| 166 | + # uses: actions/upload-artifact@v4 |
| 167 | + # with: |
| 168 | + # name: inapp-e2e-coverage-api-${{ matrix.api-level }} |
| 169 | + # path: integration-tests/build/reports/jacoco/ |
| 170 | + |
| 171 | + # - name: Upload Screenshots |
| 172 | + # if: always() |
| 173 | + # uses: actions/upload-artifact@v4 |
| 174 | + # with: |
| 175 | + # name: inapp-e2e-screenshots-api-${{ matrix.api-level }} |
| 176 | + # path: integration-tests/screenshots/ |
| 177 | + |
| 178 | + # - name: Cleanup |
| 179 | + # if: always() |
| 180 | + # run: | |
| 181 | + # echo "Test cleanup completed" |
| 182 | + |
| 183 | + # test-summary: |
| 184 | + # name: Test Summary |
| 185 | + # runs-on: ubuntu-latest |
| 186 | + # needs: inapp-e2e-tests |
| 187 | + # if: always() |
| 188 | + |
| 189 | + # steps: |
| 190 | + # - name: Checkout code |
| 191 | + # uses: actions/checkout@v4 |
| 192 | + |
| 193 | + # - name: Download Test Results |
| 194 | + # uses: actions/download-artifact@v4 |
| 195 | + # with: |
| 196 | + # name: inapp-e2e-test-results-api-34 |
| 197 | + # path: test-results/ |
| 198 | + |
| 199 | + # - name: Generate Test Summary |
| 200 | + # run: | |
| 201 | + # echo "## In-App Message E2E Test Results" >> $GITHUB_STEP_SUMMARY |
| 202 | + # echo "" >> $GITHUB_STEP_SUMMARY |
| 203 | + # echo "### Test Execution Summary" >> $GITHUB_STEP_SUMMARY |
| 204 | + # echo "- **Branch**: InApp-Display-E2E" >> $GITHUB_STEP_SUMMARY |
| 205 | + # echo "- **API Level Tested**: 34" >> $GITHUB_STEP_SUMMARY |
| 206 | + # echo "- **Test Method**: testInAppMessageMVP" >> $GITHUB_STEP_SUMMARY |
| 207 | + # echo "- **Test Type**: E2E Integration Test" >> $GITHUB_STEP_SUMMARY |
| 208 | + # echo "" >> $GITHUB_STEP_SUMMARY |
| 209 | + # echo "### E2E Test Scenarios" >> $GITHUB_STEP_SUMMARY |
| 210 | + # echo "- ✅ User Sign-in Verification" >> $GITHUB_STEP_SUMMARY |
| 211 | + # echo "- ✅ In-App Message Trigger" >> $GITHUB_STEP_SUMMARY |
| 212 | + # echo "- ✅ Message Display Verification" >> $GITHUB_STEP_SUMMARY |
| 213 | + # echo "- ✅ Button Click Interaction" >> $GITHUB_STEP_SUMMARY |
| 214 | + # echo "- ✅ Message Dismissal" >> $GITHUB_STEP_SUMMARY |
| 215 | + # echo "" >> $GITHUB_STEP_SUMMARY |
| 216 | + # echo "### Artifacts Available" >> $GITHUB_STEP_SUMMARY |
| 217 | + # echo "- Test execution reports" >> $GITHUB_STEP_SUMMARY |
| 218 | + # echo "- Code coverage reports" >> $GITHUB_STEP_SUMMARY |
| 219 | + # echo "- Debug screenshots" >> $GITHUB_STEP_SUMMARY |
| 220 | + # echo "- Detailed test logs" >> $GITHUB_STEP_SUMMARY |
0 commit comments