From 966ddb482d72b75265f8a59d15119611358fe51e 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 | 40 ++----- .github/workflows/e2e.yml | 206 ++++++++------------------------- package.json | 2 +- 4 files changed, 63 insertions(+), 187 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..2c1f6ae56f 100644 --- a/.github/workflows/adb-test.yml +++ b/.github/workflows/adb-test.yml @@ -1,37 +1,17 @@ -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 + profile: pixel_6a + avd-name: Pixel_API_34_AOSP + target: google_apis_playstore + emulator-options: -gpu swiftshader_indirect + script: adb devices -l diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1853c8a3fc..992dcac33b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -5,23 +5,35 @@ 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: + name: E2E Tests + runs-on: self-hosted steps: - uses: actions/checkout@v2 + + # Node, Ruby, Java, Android Sdk - uses: actions/setup-node@v2 with: node-version: 20 + - run: npm i -g yarn + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true - uses: actions/setup-java@v2 with: java-version: 17 distribution: temurin + - uses: android-actions/setup-android@v3 + + # Caching - uses: gradle/actions/setup-gradle@v3 + - uses: DeterminateSystems/magic-nix-cache-action@v2 - uses: actions/cache@v2 with: path: | @@ -31,54 +43,23 @@ 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 - - - uses: actions/upload-artifact@v4 - with: - name: built-e2e-apk - path: android/app/build/outputs + env: + LANG: en_US.UTF-8 + LC_ALL: en_US.UTF-8 - 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 + - run: yarn e2e:build android.emu.debug - - uses: DeterminateSystems/magic-nix-cache-action@v2 + # Start Tilt - name: Tilt CI run: | for i in {1..5}; do @@ -87,129 +68,44 @@ jobs: done exit 1 - - uses: actions/cache@v2 + # Tests on Android Emulator + - name: Run Detox Tests on Android Emulator + uses: reactivecircus/android-emulator-runner@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 + api-level: 34 + arch: arm64-v8a + profile: pixel_6a + avd-name: Pixel_API_34_AOSP + target: google_apis_playstore + emulator-options: -gpu swiftshader_indirect + 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: android-recordings - path: artifacts + path: android-recordings + + # 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 - - name: Destroy Android Emulator + - uses: actions/upload-artifact@v4 if: always() - continue-on-error: true - run: adb devices | grep emulator | cut -f1 | while read -r line; do adb -s $line emu kill; done + with: + name: ios-recordings + path: ios-artifacts + # Cleanup - name: Terminate Metro if: always() continue-on-error: true run: kill $METRO_PID - - name: Destroy backend - if: always() - continue-on-error: true - run: | - 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 - - steps: - - uses: actions/checkout@v2 - - 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 - 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 - - 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 - - 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 install -g yarn - - run: yarn install - - name: Start Metro - run: | - yarn start & - echo "METRO_PID=$!" >> $GITHUB_ENV - - - uses: DeterminateSystems/magic-nix-cache-action@v2 - - name: Tilt CI - run: | - for i in {1..5}; do - echo "Tilt CI attempt $i" - nix develop -c sh -c 'cd dev && tilt ci' && exit 0 || sleep 15 - done - exit 1 - - - run: yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --headless - - - uses: actions/upload-artifact@v4 - with: - name: ios-recordings - path: artifacts - - run: killall Simulator if: always() continue-on-error: true - - 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",