feat: resolve mobile security and reliability tasks #364
Workflow file for this run
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: E2E Tests — Maestro on EAS Preview APK | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| concurrency: | |
| group: e2e-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-preview-apk: | |
| name: Build Preview APK via EAS | |
| runs-on: ubuntu-latest | |
| outputs: | |
| apk-url: ${{ steps.wait-build.outputs.apk-url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Setup EAS | |
| uses: expo/expo-github-action@v8 | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: Build Preview APK | |
| id: eas-build | |
| run: | | |
| BUILD_URL=$(eas build \ | |
| --platform android \ | |
| --profile preview \ | |
| --non-interactive \ | |
| --json \ | |
| --no-wait | jq -r '.[0].buildDetailsPageUrl') | |
| echo "build-page-url=$BUILD_URL" >> $GITHUB_OUTPUT | |
| - name: Wait for EAS Build to complete | |
| id: wait-build | |
| run: | | |
| echo "Waiting for EAS build to complete..." | |
| for i in $(seq 1 60); do | |
| STATUS=$(eas build:list --platform android --limit 1 --json | jq -r '.[0].status') | |
| echo "Build status: $STATUS (attempt $i/60)" | |
| if [ "$STATUS" = "FINISHED" ]; then | |
| URL=$(eas build:list --platform android --limit 1 --json | jq -r '.[0].artifacts.buildUrl') | |
| echo "apk-url=$URL" >> $GITHUB_OUTPUT | |
| echo "✅ Build finished. APK URL: $URL" | |
| break | |
| elif [ "$STATUS" = "ERRORED" ] || [ "$STATUS" = "CANCELLED" ]; then | |
| echo "❌ Build failed with status: $STATUS" | |
| exit 1 | |
| fi | |
| sleep 30 | |
| done | |
| - name: Download APK | |
| run: | | |
| curl -L "${{ steps.wait-build.outputs.apk-url }}" -o petchain-preview.apk | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: petchain-preview-apk | |
| path: petchain-preview.apk | |
| retention-days: 7 | |
| e2e-android: | |
| name: Run Maestro E2E Tests | |
| runs-on: ubuntu-latest | |
| needs: build-preview-apk | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download Preview APK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: petchain-preview-apk | |
| - name: Enable KVM (hardware acceleration) | |
| 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: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Start Android Emulator | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: 33 | |
| target: google_apis | |
| arch: x86_64 | |
| profile: pixel_6 | |
| disable-animations: true | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim | |
| script: echo "Emulator started" | |
| - name: Install Maestro CLI | |
| run: | | |
| curl -Ls "https://get.maestro.mobile.dev" | bash | |
| echo "$HOME/.maestro/bin" >> $GITHUB_PATH | |
| - name: Install APK on emulator | |
| run: adb install petchain-preview.apk | |
| - name: Run Maestro smoke test | |
| run: maestro test .maestro/flows/smoke-test.yaml --format junit --output maestro-results.xml | |
| continue-on-error: true | |
| id: maestro-run | |
| - name: Upload Maestro test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: maestro-test-results | |
| path: maestro-results.xml | |
| retention-days: 14 | |
| - name: Notify Slack — E2E Result | |
| if: always() | |
| uses: slackapi/slack-github-action@v1.27.0 | |
| with: | |
| payload: | | |
| { | |
| "text": "${{ steps.maestro-run.outcome == 'success' && '✅' || '❌' }} *PetChain E2E Tests — ${{ steps.maestro-run.outcome == 'success' && 'PASSED' || 'FAILED' }}*", | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "${{ steps.maestro-run.outcome == 'success' && '✅' || '❌' }} *Maestro E2E Tests — ${{ steps.maestro-run.outcome == 'success' && 'PASSED' || 'FAILED' }}*\n*Branch:* `${{ github.ref_name }}`\n*Commit:* <${{ github.event.head_commit.url }}|`${{ github.sha }}`>\n*Triggered by:* ${{ github.actor }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>" | |
| } | |
| } | |
| ] | |
| } | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
| - name: Fail if Maestro tests failed | |
| if: steps.maestro-run.outcome == 'failure' | |
| run: exit 1 |