refactor(mobile): enforce result model invariants #1705
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 device tests | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review, converted_to_draft, labeled, unlabeled] | |
| push: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: read | |
| jobs: | |
| android-eligibility: | |
| uses: ./.github/workflows/android-eligibility.yml | |
| with: | |
| event-name: ${{ github.event_name }} | |
| ref: ${{ github.ref }} | |
| pr-number: ${{ github.event.pull_request.number || '' }} | |
| pr-head-repo: ${{ github.event.pull_request.head.repo.full_name || '' }} | |
| pr-labels: ${{ toJson(github.event.pull_request.labels.*.name) }} | |
| pr-draft: ${{ github.event.pull_request.draft || false }} | |
| android-device-test-phase: | |
| name: android-device-tests (${{ matrix.phase }}) | |
| needs: android-eligibility | |
| if: ${{ needs.android-eligibility.outputs.should-run == 'true' }} | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| phase: [wallet-mobile, compose-demo, enterprise-mobile] | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
| steps: | |
| - name: Checkout all repos with ref fallback | |
| uses: walt-id/waltid-identity/.github/actions/checkout-repos@73cf58a0edcc4c978304fdfd1a91372d34f65da2 | |
| with: | |
| token: ${{ secrets.GH_ACCESS_TOKEN || github.token }} | |
| ref: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref_name }} | |
| - name: Configure gradle | |
| uses: walt-id/waltid-identity/.github/actions/gradle-setup-action@c95b601fc5095d5668eb8c906af992d8e00ed513 | |
| - name: Enable Android build in identity repo | |
| uses: walt-id/waltid-identity/.github/actions/set-properties@00d4e55e9865cf17c6703d926dce4a4f6e1d404a | |
| with: | |
| file: 'waltid-identity/gradle.properties' | |
| properties: 'enableAndroidBuild=true' | |
| - name: Enable Android build in unified-build root | |
| uses: walt-id/waltid-identity/.github/actions/set-properties@00d4e55e9865cf17c6703d926dce4a4f6e1d404a | |
| with: | |
| file: 'gradle.properties' | |
| properties: 'enableAndroidBuild=true' | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Configure Android device test phase | |
| id: android-device-phase | |
| run: ./waltid-identity/.github/scripts/mobile-ci/configure-android-device-phase.sh "${{ matrix.phase }}" | |
| - name: Preinstall Android emulator SDK packages | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| retry_sdkmanager_install() { | |
| local attempt | |
| for attempt in 1 2 3; do | |
| echo "sdkmanager install attempt ${attempt}: $*" | |
| if "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "$@" --channel=0; then | |
| return 0 | |
| fi | |
| if [ "$attempt" -eq 3 ]; then | |
| return 1 | |
| fi | |
| sleep $((attempt * 20)) | |
| done | |
| } | |
| yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null || true | |
| retry_sdkmanager_install 'build-tools;37.0.0' platform-tools 'platforms;android-34' | |
| retry_sdkmanager_install emulator | |
| retry_sdkmanager_install 'system-images;android-34;default;x86_64' | |
| - name: Build Enterprise Android mobile test artifacts | |
| if: matrix.phase == 'enterprise-mobile' | |
| run: ./waltid-identity/.github/scripts/mobile-ci/prepare-enterprise-android-mobile-tests.sh | |
| - name: Run Android device tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 34 | |
| arch: x86_64 | |
| emulator-options: ${{ steps.android-device-phase.outputs.emulator_options }} | |
| disable-animations: true | |
| script: ${{ steps.android-device-phase.outputs.script }} | |
| - name: Publish Android device test report | |
| if: always() && steps.android-device-phase.outputs.report_paths != '' | |
| uses: mikepenz/action-junit-report@v6 | |
| with: | |
| update_check: true | |
| job_name: android-device-tests (${{ matrix.phase }}) | |
| check_name: Android Device Test Report (${{ matrix.phase }}) | |
| report_paths: ${{ steps.android-device-phase.outputs.report_paths }} | |
| detailed_summary: true | |
| include_passed: false | |
| include_skipped: false | |
| require_tests: false | |
| - name: Upload Android device test reports | |
| if: always() && steps.android-device-phase.outputs.artifact_paths != '' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-device-test-reports-${{ matrix.phase }} | |
| path: ${{ steps.android-device-phase.outputs.artifact_paths }} | |
| retention-days: 30 | |
| android-device-tests: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - android-eligibility | |
| - android-device-test-phase | |
| if: always() | |
| steps: | |
| - name: Check Android device test phases | |
| run: | | |
| if [ "${{ needs.android-eligibility.outputs.should-run }}" != "true" ]; then | |
| echo "Android eligibility skipped this run: ${{ needs.android-eligibility.outputs.reason }}" | |
| exit 0 | |
| fi | |
| if [ "${{ needs.android-device-test-phase.result }}" != "success" ]; then | |
| echo "::error::One or more Android device test phases failed." | |
| exit 1 | |
| fi |