FWK testing - Android #15
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: Android Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Generate Gradle Wrapper | |
| run: gradle wrapper | |
| working-directory: Android | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| working-directory: Android | |
| - name: Run Android Unit Tests | |
| id: unit_tests | |
| continue-on-error: true | |
| run: ./gradlew :wallet:test | |
| working-directory: Android | |
| - name: Upload Unit Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: unit-test-reports | |
| path: Android/wallet/build/reports/tests/ | |
| - name: Run Android Instrumented Tests | |
| id: instrumented_tests | |
| continue-on-error: true | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 24 | |
| target: google_apis | |
| arch: x86_64 | |
| ram-size: 4096M | |
| heap-size: 2048M | |
| working-directory: Android | |
| emulator-options: -no-snapshot-save -no-window -gpu off -noaudio -no-boot-anim -camera-back none -memory 4096 -partition-size 4096 | |
| script: | | |
| echo "Waiting for emulator to fully boot..." | |
| boot_completed="" | |
| retry=0 | |
| while [[ -z "$boot_completed" && $retry -lt 60 ]]; do | |
| boot_completed=$(adb shell getprop sys.boot_completed 2>/dev/null) | |
| if [[ "$boot_completed" == "1" ]]; then | |
| echo "Emulator booted successfully!" | |
| break | |
| fi | |
| echo "Still waiting for boot... (attempt $((retry+1)))" | |
| sleep 5 | |
| retry=$((retry+1)) | |
| done | |
| if [[ "$boot_completed" != "1" ]]; then | |
| echo "Emulator failed to boot in time!" | |
| exit 1 | |
| fi | |
| adb shell input keyevent 82 | |
| echo "Device is ready, running tests..." | |
| ./gradlew :wallet:connectedAndroidTest --info --stacktrace | |
| - name: Upload Instrumented Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: instrumented-test-reports | |
| path: Android/wallet/build/reports/androidTests/ | |
| - name: Check Test Results | |
| if: always() | |
| run: | | |
| if [[ "${{ steps.unit_tests.outcome }}" == "failure" || "${{ steps.instrumented_tests.outcome }}" == "failure" ]]; then | |
| echo "Tests failed. Please check the test reports in the artifacts." | |
| exit 1 | |
| fi | |