|
12 | 12 | build: |
13 | 13 | # Android builds run on ubuntu-latest so the emulator can use hardware (KVM) |
14 | 14 | # acceleration. The previous macos-15-intel runner regularly wedged/segfaulted |
15 | | - # the hand-rolled emulator boot (see #7031). |
| 15 | + # the emulator boot under `-gpu host` (see #7031). |
| 16 | + # |
| 17 | + # NOTE: this repo restricts GitHub Actions to an allow-list (GitHub-authored, |
| 18 | + # aws-actions/*, aws-amplify/* and changesets/action), so the emulator is |
| 19 | + # launched with the Android SDK CLI directly rather than a third-party action. |
16 | 20 | runs-on: ubuntu-latest |
17 | 21 | # Bound the whole job so a wedged emulator boot can't run until GitHub's 6h hard limit. |
18 | 22 | timeout-minutes: 45 |
|
37 | 41 |
|
38 | 42 | env: |
39 | 43 | MEGA_APP_NAME: rn${{ matrix.framework-version.formatted }}${{ matrix.build-tool }}${{ matrix.build-tool-version }}${{ matrix.platform }}ui${{ inputs.dist-tag }} |
| 44 | + EMULATOR_PORT: 5554 |
40 | 45 | GRADLE_OPTS: '-Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000' |
41 | 46 | steps: |
42 | 47 | - name: Checkout Amplify UI |
@@ -79,21 +84,39 @@ jobs: |
79 | 84 | sudo udevadm control --reload-rules |
80 | 85 | sudo udevadm trigger --name-match=kvm |
81 | 86 |
|
82 | | - # reactivecircus/android-emulator-runner manages the SDK, AVD and emulator |
83 | | - # lifecycle and keeps the emulator alive for the duration of `script`, so the |
84 | | - # MegaApp build and log check run against a booted device. This replaces the |
85 | | - # hand-rolled emulator launch/snapshot logic that repeatedly failed on macOS. |
86 | | - - name: Build MegaApp ${{ env.MEGA_APP_NAME }} on Android emulator (NodeJS ${{ matrix.node-version }}) |
| 87 | + - name: Install Android emulator |
87 | 88 | if: ${{ matrix.platform == 'android' }} |
88 | | - uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2.37.0 |
89 | | - with: |
90 | | - api-level: 27 |
91 | | - arch: x86_64 |
92 | | - target: default |
93 | | - profile: pixel_5 |
94 | | - emulator-boot-timeout: 420 |
95 | | - disable-animations: true |
96 | | - script: | |
97 | | - cd build-system-tests |
98 | | - npm run setup:${{ matrix.framework }}:${{ matrix.build-tool }} -- --name ${{ env.MEGA_APP_NAME }} --platform ${{ matrix.platform }} --tag ${{ inputs.dist-tag }} --framework-version ${{ matrix.framework-version.value }} --build-tool-version ${{ matrix.build-tool-version }} |
99 | | - npm run checkReactNativeLogs -- --log-file-name ${{ matrix.logfile }} --mega-app-name ${{ env.MEGA_APP_NAME }} --platform ${{ matrix.platform }} |
| 89 | + run: | |
| 90 | + echo "ANDROID_HOME=$ANDROID_HOME" |
| 91 | + yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null |
| 92 | + $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "platform-tools" "emulator" "build-tools;33.0.2" "system-images;android-27;default;x86_64" |
| 93 | + echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd --force --name Pixel_5_API_27 --device "pixel_5" --package "system-images;android-27;default;x86_64" |
| 94 | +
|
| 95 | + - name: Start Android emulator |
| 96 | + if: ${{ matrix.platform == 'android' }} |
| 97 | + run: | |
| 98 | + # Headless launch with software GPU (swiftshader) + KVM; this is the |
| 99 | + # reliable CI combination on Linux runners. |
| 100 | + $ANDROID_HOME/emulator/emulator -avd Pixel_5_API_27 -port ${{ env.EMULATOR_PORT }} -no-window -no-boot-anim -no-audio -no-snapshot -gpu swiftshader_indirect -accel on -camera-back none & |
| 101 | + if ! timeout 420 $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'; then |
| 102 | + echo "::error::Android emulator did not reach sys.boot_completed within 420s; failing fast instead of hanging until the 6h limit" |
| 103 | + $ANDROID_HOME/platform-tools/adb devices |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + $ANDROID_HOME/platform-tools/adb devices |
| 107 | + # disable spell checker |
| 108 | + $ANDROID_HOME/platform-tools/adb shell settings put secure spell_checker_enabled 0 |
| 109 | + # disable animations |
| 110 | + $ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0.0 |
| 111 | + $ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0.0 |
| 112 | + $ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0.0 |
| 113 | +
|
| 114 | + - name: Create MegaApp ${{ env.MEGA_APP_NAME }} and run build on NodeJS ${{ matrix.node-version }} |
| 115 | + run: npm run setup:${{matrix.framework}}:${{matrix.build-tool}} -- --name ${{ env.MEGA_APP_NAME }} --platform ${{matrix.platform}} --tag ${{inputs.dist-tag}} --framework-version ${{matrix.framework-version.value}} --build-tool-version ${{matrix.build-tool-version}} |
| 116 | + shell: bash |
| 117 | + working-directory: build-system-tests |
| 118 | + |
| 119 | + - name: Detect Mega App Error in Log |
| 120 | + run: npm run checkReactNativeLogs -- --log-file-name ${{ matrix.logfile }} --mega-app-name ${{ env.MEGA_APP_NAME }} --platform ${{ matrix.platform }} |
| 121 | + shell: bash |
| 122 | + working-directory: build-system-tests |
0 commit comments