From 928b4b83cf1ceb0aaedf1b1129a051868ec619d1 Mon Sep 17 00:00:00 2001 From: Sandipan Dey Date: Thu, 15 Feb 2024 11:58:05 +0530 Subject: [PATCH] try emulator creation manually export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home" --- .github/workflows/adb-check.yml | 43 ----------------- .github/workflows/adb-test.yml | 31 ++++++++++++ .github/workflows/e2e.yml | 84 ++++++++++++++------------------- 3 files changed, 66 insertions(+), 92 deletions(-) delete mode 100644 .github/workflows/adb-check.yml create mode 100644 .github/workflows/adb-test.yml diff --git a/.github/workflows/adb-check.yml b/.github/workflows/adb-check.yml deleted file mode 100644 index 603487f479..0000000000 --- a/.github/workflows/adb-check.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: ADB Check (Temporary) - -on: push - -jobs: - test-e2e-android: - name: Run tests on Android - runs-on: ["self-hosted", "Linux", "X64"] - - steps: - # - uses: actions/checkout@v4 - - uses: android-actions/setup-android@v3 - - - 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 - - # - uses: actions/setup-node@v2 - # with: - # node-version: 20 - # - run: npm i -g yarn - - # - run: | - # mkdir -p ./android/app/build/outputs - # cp -r ~/apk ./android/app/build/outputs - - # - uses: actions/cache@v2 - # with: - # path: | - # node_modules - # ios/Pods - # key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }} - # restore-keys: | - # ${{ runner.os }}-deps- - - # - run: yarn install - - name: Run Android Emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - script: sleep 999999 diff --git a/.github/workflows/adb-test.yml b/.github/workflows/adb-test.yml new file mode 100644 index 0000000000..cef77522fe --- /dev/null +++ b/.github/workflows/adb-test.yml @@ -0,0 +1,31 @@ +name: ADB Test +on: push + +jobs: + adb-test: + name: Run Detox tests on Android + runs-on: ["self-hosted", "Linux", "X64"] + + steps: + - uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: temurin + - uses: android-actions/setup-android@v3 + + - 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: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + arch: x86_64 + profile: Nexus 6 + avd-name: Pixel_API_29_AOSP + script: | + cd ~/galoy-mobile + yarn e2e:test android.emu.debug -d -R 3 --headless diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b2eb609fba..1853c8a3fc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -8,6 +8,8 @@ on: jobs: build-e2e-android: name: Build APK + + # Github hosted runner doesn't have enough space runs-on: ["self-hosted", "Linux", "X64"] steps: @@ -59,14 +61,22 @@ jobs: java-version: 17 distribution: temurin - uses: gradle/actions/setup-gradle@v3 - - uses: actions/cache@v2 - with: - path: | - node_modules - ios/Pods - key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-deps- + + - uses: android-actions/setup-android@v3 + - name: Create and Start Android Emulator + run: | + echo "Enabling KVM..." + 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 + + echo "Creating AVD..." + avdmanager create avd -n Pixel_API_29_AOSP -k "system-images;android-34;default;x86_64" --device "Nexus 6" --force + + echo "Starting Emulator..." + emulator -avd Pixel_API_29_AOSP -no-audio -no-window -accel off & + + echo "Will take 3-4 minutes to boot up completely" - uses: DeterminateSystems/magic-nix-cache-action@v2 - name: Tilt CI @@ -77,64 +87,40 @@ jobs: done exit 1 - - run: npm i -g yarn - - uses: android-actions/setup-android@v3 + - uses: actions/cache@v2 + with: + path: | + node_modules + ios/Pods + key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-deps- + - run: npm i -g yarn - run: yarn install - name: Start Metro run: | yarn start & echo "METRO_PID=$!" >> $GITHUB_ENV - - 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: Run Detox Tests + run: yarn e2e:test android.emu.debug --headless -d -R 3 --take-screenshots all --record-videos all --record-logs all --headless - - name: Run Detox Tests (test attempt 1) - continue-on-error: true - id: test1 - uses: reactivecircus/android-emulator-runner@v2 + - uses: actions/upload-artifact@v4 with: - api-level: 29 - avd-name: Pixel_API_29_AOSP - force-avd-creation: true - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 --take-screenshots all --record-videos all --record-logs all --headless + name: android-recordings + path: artifacts - - name: Run Detox Tests (test attempt 2) + - name: Destroy Android Emulator + if: always() continue-on-error: true - id: test2 - if: steps.test1.outcome != 'success' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - avd-name: Pixel_API_29_AOSP - force-avd-creation: false - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 --take-screenshots all --record-videos all --record-logs all --headless - - - name: Run Detox Tests (test attempt 3) - if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - avd-name: Pixel_API_29_AOSP - force-avd-creation: false - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 + run: adb devices | grep emulator | cut -f1 | while read -r line; do adb -s $line emu kill; done - name: Terminate Metro if: always() continue-on-error: true run: kill $METRO_PID - - uses: actions/upload-artifact@v4 - with: - name: android-recordings - path: artifacts - - name: Destroy backend if: always() continue-on-error: true