Fixing BCIT and in app tests in CI #417
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: In-App Message E2E Tests | |
| on: | |
| push: | |
| branches: [ InApp-Display-E2E ] | |
| pull_request: | |
| branches: [ InApp-Display-E2E, master, develop ] | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| inapp-e2e-tests: | |
| name: In-App Message E2E Tests | |
| # SDK-170: macOS Intel runners (2 cores / 3GB AVD on HVF) starved system_server during | |
| # cold boot and produced cascading ANRs (systemui / nexuslauncher / gms / phone …), | |
| # leaving a system dialog on top of MainActivity so UiAutomator could not find the | |
| # in-app button. Ubuntu runners with KVM acceleration and 4 vCPU / 16GB stop the storm. | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [34] # MVP testing on most relevant API level only | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Enable KVM device permissions | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \ | |
| | sudo tee /etc/udev/rules.d/99-kvm.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Set up Android SDK | |
| uses: android-actions/setup-android@v2 | |
| - name: Create local.properties | |
| run: | | |
| echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties | |
| echo "ndk.dir=$ANDROID_SDK_ROOT/ndk" >> local.properties | |
| - name: Accept Android SDK Licenses | |
| run: | | |
| echo "Accepting Android SDK licenses..." | |
| yes | sdkmanager --licenses || true | |
| echo "SDK licenses accepted" | |
| - name: Setup Google Services Configuration | |
| run: | | |
| echo "Setting up Google Services configuration for CI..." | |
| # Ensure the google-services.json file exists for the build | |
| if [ ! -f "integration-tests/google-services.json" ]; then | |
| echo "Creating google-services.json from template..." | |
| cp integration-tests/google-services.json.template integration-tests/google-services.json | |
| fi | |
| echo "Google Services configuration ready" | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Pre-download Gradle and Build (Parallel with Emulator) | |
| run: | | |
| echo "Pre-downloading Gradle and building while emulator boots..." | |
| # Download Gradle wrapper in background | |
| ./gradlew --version & | |
| # Start building APKs in background | |
| ./gradlew :integration-tests:assembleDebug :integration-tests:assembleDebugAndroidTest --no-daemon & | |
| echo "Build started in background..." | |
| - name: Run UI Tests with Emulator (KVM / x86_64) | |
| uses: ReactiveCircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_6 | |
| cores: 4 | |
| ram-size: 4096M | |
| heap-size: 576M | |
| force-avd-creation: true | |
| disable-animations: true | |
| emulator-boot-timeout: 900 | |
| emulator-options: -no-window -no-snapshot -gpu swiftshader_indirect -no-boot-anim -camera-back none -partition-size 6000 | |
| pre-emulator-launch-script: | | |
| # Clean + start adb after platform-tools exist (avoids tcp:5037 noise) | |
| adb kill-server >/dev/null 2>&1 || true | |
| adb start-server | |
| # The android-emulator-runner action runs each line of an inline `script:` | |
| # in a fresh `/bin/sh -c`, so cross-line variables and bash functions don't | |
| # survive. Externalise the whole thing to a single bash file that runs in | |
| # one process — see .github/scripts/run-e2e.sh for the actual logic. | |
| script: bash "$GITHUB_WORKSPACE/.github/scripts/run-e2e.sh" | |
| env: | |
| ITERABLE_API_KEY: ${{ secrets.BCIT_ITERABLE_API_KEY }} | |
| ITERABLE_SERVER_API_KEY: ${{ secrets.BCIT_ITERABLE_SERVER_API_KEY }} | |
| ITERABLE_TEST_USER_EMAIL: ${{ secrets.BCIT_ITERABLE_TEST_USER_EMAIL }} | |
| # SDK-170: do NOT upload integration-tests/build/outputs/ — that path contains the | |
| # built APKs which embed BuildConfig.ITERABLE_API_KEY and BuildConfig.ITERABLE_SERVER_API_KEY | |
| # as compile-time string constants. On a public repo, anyone who can download the | |
| # artifact could `strings`/`apktool` the APK and recover both keys. | |
| - name: Upload E2E diagnostics | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: e2e-diagnostics-api-${{ matrix.api-level }} | |
| path: | | |
| integration-tests/build/diagnostics/ | |
| integration-tests/build/reports/ | |
| if-no-files-found: warn | |
| retention-days: 7 | |
| # test-summary: | |
| # name: Test Summary | |
| # runs-on: ubuntu-latest | |
| # needs: inapp-e2e-tests | |
| # if: always() | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Download Test Results | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: inapp-e2e-test-results-api-34 | |
| # path: test-results/ | |
| # - name: Generate Test Summary | |
| # run: | | |
| # echo "## In-App Message E2E Test Results" >> $GITHUB_STEP_SUMMARY | |
| # echo "" >> $GITHUB_STEP_SUMMARY | |
| # echo "### Test Execution Summary" >> $GITHUB_STEP_SUMMARY | |
| # echo "- **Branch**: InApp-Display-E2E" >> $GITHUB_STEP_SUMMARY | |
| # echo "- **API Level Tested**: 34" >> $GITHUB_STEP_SUMMARY | |
| # echo "- **Test Method**: testInAppMessageMVP" >> $GITHUB_STEP_SUMMARY | |
| # echo "- **Test Type**: E2E Integration Test" >> $GITHUB_STEP_SUMMARY | |
| # echo "" >> $GITHUB_STEP_SUMMARY | |
| # echo "### E2E Test Scenarios" >> $GITHUB_STEP_SUMMARY | |
| # echo "- ✅ User Sign-in Verification" >> $GITHUB_STEP_SUMMARY | |
| # echo "- ✅ In-App Message Trigger" >> $GITHUB_STEP_SUMMARY | |
| # echo "- ✅ Message Display Verification" >> $GITHUB_STEP_SUMMARY | |
| # echo "- ✅ Button Click Interaction" >> $GITHUB_STEP_SUMMARY | |
| # echo "- ✅ Message Dismissal" >> $GITHUB_STEP_SUMMARY | |
| # echo "" >> $GITHUB_STEP_SUMMARY | |
| # echo "### Artifacts Available" >> $GITHUB_STEP_SUMMARY | |
| # echo "- Test execution reports" >> $GITHUB_STEP_SUMMARY | |
| # echo "- Code coverage reports" >> $GITHUB_STEP_SUMMARY | |
| # echo "- Debug screenshots" >> $GITHUB_STEP_SUMMARY | |
| # echo "- Detailed test logs" >> $GITHUB_STEP_SUMMARY |