Skip to content

restart adb server #191

restart adb server

restart adb server #191

name: Detox E2E Android Tests PR
on:
push:
branches:
- test_android_e2e
pull_request:
branches:
- main
- test_android_e2e
types:
- labeled
concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number }}-${{ github.event.label.name }}"
cancel-in-progress: true
jobs:
build-android-apk:
if: github.event.label.name == 'E2E Android tests for PR' && false
runs-on: ubuntu-latest-8-cores
env:
ORG_GRADLE_PROJECT_jvmargs: -Xmx8g
steps:
- name: Prune Docker to free up space
run: docker system prune -af
- name: Remove npm Temporary Files
run: |
rm -rf ~/.npm/_cacache
- name: ci/checkout-repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: ci/prepare-android-build
uses: ./.github/actions/prepare-android-build
env:
STORE_FILE: "${{ secrets.MM_MOBILE_STORE_FILE }}"
STORE_ALIAS: "${{ secrets.MM_MOBILE_STORE_ALIAS }}"
STORE_PASSWORD: "${{ secrets.MM_MOBILE_STORE_PASSWORD }}"
MATTERMOST_BUILD_GH_TOKEN: "${{ secrets.MATTERMOST_BUILD_GH_TOKEN }}"
- name: Install Dependencies
run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y default-jdk
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: ~/.gradle/caches/modules-2/
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Detox build
run: |
cd detox
npm install
npm install -g detox-cli
npm run e2e:android-build
- name: ci/upload-android-pr-build
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: android-build-apk-${{ github.run_id }}
path: "android/app/build/outputs/apk/**/app-*.apk"
run-android-tests:
# if: github.event.label.name == 'E2E Android tests for PR'
# needs: build-android-apk
runs-on: macos-13
env:
SDK_VERSION: 31
AVD_NAME: "detox_pixel_4_xl_api_31"
ARCH: "x86_64"
steps:
- name: ci/checkout-repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
# - name: Download APK artifact
# uses: actions/download-artifact@v4
# with:
# name: android-build-apk-13046110009
# path: android/app/build/outputs/apk/
- name: Create destination path
run: mkdir -p android/app/build/outputs/apk
- name: Download artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -L -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/mattermost/mattermost-mobile/actions/artifacts/2508660502/zip \
--output android/app/build/outputs/apk/artifact.zip
- name: Unzip artifact
run: unzip android/app/build/outputs/apk/artifact.zip -d android/app/build/outputs/apk
- name: List unzipped files
run: ls -la android/app/build/outputs/apk
- name: Cleanup
run: |
find android/app/build -type f
rm android/app/build/outputs/apk/artifact.zip
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: ~/.gradle/caches/modules-2/
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Set up Java 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Restart ADB
run: |
adb kill-server
adb start-server
adb devices
- name: Install Android SDK and AOSP Emulator
run: |
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install emulator
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-${SDK_VERSION};google_apis;x86_64"
echo "y" | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n ${AVD_NAME} -d pixel --package "system-images;android-${SDK_VERSION};google_apis;x86_64"
- name: Start AOSP Emulator
run: |
nohup $ANDROID_HOME/emulator/emulator -avd ${AVD_NAME} \
-no-audio -no-window -no-snapshot -gpu off -accel off -cores 2 > emulator.log 2>&1 &
echo "Waiting for emulator to start..."
timeout=600 # Increased timeout to 10 minutes
while [[ $(adb devices | grep emulator | wc -l) -eq 0 ]]; do
sleep 5
timeout=$((timeout - 5))
if [[ $timeout -le 0 ]]; then
echo "Emulator failed to start within time limit."
cat emulator.log
exit 1
fi
done
echo "Emulator is up and running."
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
- name: Run Detox tests
run: |
cd detox
npm install
npm install -g detox-cli
npm run e2e:android-test -- about.e2e.ts