Update lib versions in Android apps #17
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
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |
| # All rights reserved. | |
| # | |
| # This source code is licensed under the BSD-style license found in the | |
| # LICENSE file in the root directory of this source tree. | |
| name: Android Emulator Tests | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'dl3/android/**' | |
| - 'mv3/android/**' | |
| - '.github/workflows/android-emulator.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| instrumentation-test: | |
| runs-on: 8-core-ubuntu | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| demo: | |
| - path: 'dl3/android/DeepLabV3Demo' | |
| name: 'DeepLabV3Demo' | |
| - path: 'mv3/android/MV3Demo' | |
| name: 'MV3Demo' | |
| env: | |
| API_LEVEL: 34 | |
| ARCH: x86_64 | |
| DEMO_PATH: ${{ matrix.demo.path }} | |
| name: Instrumentation Test ${{ matrix.demo.name }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Determine demo name | |
| id: demo-info | |
| run: | | |
| DEMO_NAME=$(basename "${{ env.DEMO_PATH }}") | |
| echo "demo_name=$DEMO_NAME" >> $GITHUB_OUTPUT | |
| echo "Testing: $DEMO_NAME" | |
| echo "=== Test Configuration ===" | |
| echo "Demo: $DEMO_NAME" | |
| echo "Model will be downloaded by the test if not present" | |
| - name: Enable KVM group perms | |
| 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: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }}-ram8G-disk8G-${{ steps.demo-info.outputs.demo_name }}-v1 | |
| - name: Create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.API_LEVEL }} | |
| arch: ${{ env.ARCH }} | |
| ram-size: 8192M | |
| disk-size: 8192M | |
| force-avd-creation: true | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 8192 | |
| disable-animations: false | |
| working-directory: ${{ env.DEMO_PATH }} | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Run instrumentation tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.API_LEVEL }} | |
| arch: ${{ env.ARCH }} | |
| ram-size: 8192M | |
| disk-size: 8192M | |
| force-avd-creation: true | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 8192 | |
| disable-animations: true | |
| working-directory: ${{ env.DEMO_PATH }} | |
| script: | | |
| set -ex | |
| DEMO_NAME=$(basename "$PWD") | |
| LOGCAT_FILE="/tmp/logcat-${DEMO_NAME}.txt" | |
| echo "=== Emulator Memory Info ===" | |
| adb shell cat /proc/meminfo | head -5 | |
| echo "=== Emulator Disk Space ===" | |
| adb shell df -h /data | |
| adb logcat -c | |
| adb logcat > "$LOGCAT_FILE" & | |
| LOGCAT_PID=$! | |
| echo "=== Starting Gradle ===" | |
| ./gradlew connectedCheck | |
| TEST_EXIT_CODE=$? | |
| if [ -n "$LOGCAT_PID" ]; then kill $LOGCAT_PID 2>/dev/null || true; fi | |
| echo "=== Test completion status ===" | |
| if [ $TEST_EXIT_CODE -eq 0 ]; then echo "✅ Tests passed successfully"; else echo "❌ Tests failed with exit code $TEST_EXIT_CODE"; fi | |
| echo "=== Checking for test results in logcat ===" | |
| grep -E "SanityCheck|UIWorkflowTest" "$LOGCAT_FILE" || echo "No test logs found" | |
| exit $TEST_EXIT_CODE | |
| - name: Upload logcat | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: logcat-${{ steps.demo-info.outputs.demo_name }} | |
| path: /tmp/logcat-*.txt | |
| retention-days: 7 |