From 23522790560de983ea3cbb3c5e5823f46b7cbbab Mon Sep 17 00:00:00 2001 From: Sandipan Dey Date: Thu, 15 Feb 2024 17:58:51 +0530 Subject: [PATCH] ci: single e2e test export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home" --- .detoxrc.js | 2 +- .github/workflows/adb-test.yml | 37 ++----- .github/workflows/e2e.yml | 191 ++++++++++++--------------------- package.json | 2 +- 4 files changed, 80 insertions(+), 152 deletions(-) diff --git a/.detoxrc.js b/.detoxrc.js index 7d57fb4c25..be55bbffa4 100644 --- a/.detoxrc.js +++ b/.detoxrc.js @@ -36,7 +36,7 @@ module.exports = { emulator: { type: "android.emulator", device: { - avdName: "Pixel_API_29_AOSP", + avdName: "Pixel_API_34_AOSP", }, }, }, diff --git a/.github/workflows/adb-test.yml b/.github/workflows/adb-test.yml index b70ed69596..0a1b2985c5 100644 --- a/.github/workflows/adb-test.yml +++ b/.github/workflows/adb-test.yml @@ -1,37 +1,14 @@ -name: ADB Test -on: push +on: [push] jobs: adb-test: - name: Run Detox tests on Android - runs-on: ["self-hosted", "Linux", "X64"] - + runs-on: self-hosted steps: - - uses: actions/setup-node@v2 - with: - node-version: 20 - - run: npm i -g yarn - - - 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 + - name: Run Detox Tests on Android Emulator 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 install - yarn e2e:test android.emu.debug -d -R 3 --headless + api-level: 34 + arch: arm64-v8a + avd-name: Pixel_API_34_AOSP + script: ./gradlew connectedCheck diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1853c8a3fc..9268b535d8 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -5,23 +5,29 @@ on: # pull_request: # branches: [main] -jobs: - build-e2e-android: - name: Build APK +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true - # Github hosted runner doesn't have enough space - runs-on: ["self-hosted", "Linux", "X64"] +jobs: + e2e-ios: + name: E2E Test on iOS + runs-on: self-hosted steps: - uses: actions/checkout@v2 + + # Node, Ruby - uses: actions/setup-node@v2 with: node-version: 20 - - uses: actions/setup-java@v2 + - run: npm i -g yarn + - uses: ruby/setup-ruby@v1 with: - java-version: 17 - distribution: temurin - - uses: gradle/actions/setup-gradle@v3 + bundler-cache: true + + # Caching + - uses: DeterminateSystems/magic-nix-cache-action@v2 - uses: actions/cache@v2 with: path: | @@ -31,54 +37,22 @@ jobs: restore-keys: | ${{ runner.os }}-deps- - - run: npm i -g yarn - - uses: android-actions/setup-android@v3 - + # Install Node Modules and Pods - run: yarn install - - run: yarn e2e:build android.emu.debug + env: + LANG: en_US.UTF-8 + LC_ALL: en_US.UTF-8 - - uses: actions/upload-artifact@v4 - with: - name: built-e2e-apk - path: android/app/build/outputs - - test-e2e-android: - name: Run Detox tests on Android - runs-on: ["self-hosted", "Linux", "X64"] - needs: build-e2e-android - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v4 - with: - name: built-e2e-apk - path: android/app/build/outputs - - uses: actions/setup-node@v2 - with: - node-version: 20 - - uses: actions/setup-java@v2 - with: - java-version: 17 - distribution: temurin - - uses: gradle/actions/setup-gradle@v3 - - - uses: android-actions/setup-android@v3 - - name: Create and Start Android Emulator + # Metro + - name: Start Metro 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 & + yarn start & + echo "METRO_PID=$!" >> $GITHUB_ENV - echo "Will take 3-4 minutes to boot up completely" + # Build + - run: yarn e2e:build ios.sim.debug - - uses: DeterminateSystems/magic-nix-cache-action@v2 + # Start Tilt - name: Tilt CI run: | for i in {1..5}; do @@ -87,39 +61,25 @@ jobs: done exit 1 - - 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: Run Detox Tests - run: yarn e2e:test android.emu.debug --headless -d -R 3 --take-screenshots all --record-videos all --record-logs all --headless + # Tests on iOS Simulator + - name: Run Detox Tests on iOS Simulator + run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings - uses: actions/upload-artifact@v4 + if: always() with: - name: android-recordings - path: artifacts + name: ios-recordings + path: ios-artifacts - - name: Destroy Android Emulator + # Cleanup + - name: Terminate Metro if: always() continue-on-error: true - run: adb devices | grep emulator | cut -f1 | while read -r line; do adb -s $line emu kill; done + run: kill $METRO_PID - - name: Terminate Metro + - run: killall Simulator if: always() continue-on-error: true - run: kill $METRO_PID - name: Destroy backend if: always() @@ -128,49 +88,27 @@ jobs: nix develop -c sh -c 'cd dev && tilt down' || true docker rm -f $(docker ps -aq) - build-e2e-ios: - name: Build IPA - runs-on: macos-latest + e2e-android: + name: E2E Test on Android + runs-on: self-hosted steps: - uses: actions/checkout@v2 + + # Node, Ruby, Java, Android Sdk - uses: actions/setup-node@v2 with: node-version: 20 - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - 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: Build app - run: yarn e2e:build ios.sim.debug - - - uses: actions/upload-artifact@v4 + - run: npm i -g yarn + - uses: actions/setup-java@v2 with: - name: built-e2e-ipa - path: ios/build/Build/Products/Debug-iphonesimulator/Blink.app - - test-e2e-ios: - name: Run Detox tests on iOS - runs-on: ["self-hosted", "MacOS", "ARM64"] - needs: build-e2e-ios + java-version: 17 + distribution: temurin + - uses: android-actions/setup-android@v3 - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v4 - with: - name: built-e2e-ipa - path: ios/build/Build/Products/Debug-iphonesimulator/Blink.app - - uses: actions/setup-node@v2 - with: - node-version: 20 + # Caching + - uses: gradle/actions/setup-gradle@v3 + - uses: DeterminateSystems/magic-nix-cache-action@v2 - uses: actions/cache@v2 with: path: | @@ -180,14 +118,19 @@ jobs: restore-keys: | ${{ runner.os }}-deps- - - run: npm install -g yarn - - run: yarn install + # Install Node Modules + - run: NOPOSTINSTALLPODS=true yarn install + + # Metro - name: Start Metro run: | yarn start & echo "METRO_PID=$!" >> $GITHUB_ENV - - uses: DeterminateSystems/magic-nix-cache-action@v2 + # Build + - run: yarn e2e:build android.emu.debug + + # Start Tilt - name: Tilt CI run: | for i in {1..5}; do @@ -196,20 +139,28 @@ jobs: done exit 1 - - run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --headless + # Android Emulator + - name: Run Detox Tests on Android Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + arch: arm64-v8a + profile: Pixel 6a + avd-name: Pixel_API_34_AOSP + script: yarn e2e:test android.emu.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location android-recordings - uses: actions/upload-artifact@v4 + if: always() with: - name: ios-recordings - path: artifacts + name: android-recordings + path: android-recordings - - run: killall Simulator - if: always() - continue-on-error: true + # Cleanup - name: Terminate Metro if: always() continue-on-error: true run: kill $METRO_PID + - name: Destroy backend if: always() continue-on-error: true diff --git a/package.json b/package.json index 7704fe016d..095b838c35 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dev:gengql": "yarn node utils/create-gql.ts", "adb": "adb reverse tcp:9090 tcp:9090 && adb reverse tcp:3000 tcp:3000 && adb reverse tcp:4000 tcp:4000 && adb reverse tcp:9001 tcp:9001 && adb reverse tcp:8081 tcp:8081 && adb reverse tcp:4002 tcp:4002 && adb reverse tcp:4455 tcp:4455", "patch": "patch-package", - "postinstall": "jetify && yarn patch-package && if which pod >/dev/null; then (cd ios; bundle install; bundle exec pod install); fi", + "postinstall": "jetify && yarn patch-package && if [ -z \"$NOPOSTINSTALLPODS\" ]; then if which pod >/dev/null; then (cd ios; bundle install; bundle exec pod install); fi; fi", "hack:types-react-native": "rimraf node_modules/@types/react-native/node_modules/@types", "prepare": "npm-run-all patch hack:*", "client:dev": "yalc add @galoymoney/client",