diff --git a/.circleci/config.yml b/.circleci/config.yml index b716020d93..8a2ab58c6e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,26 @@ version: 2.1 orbs: - gh: circleci/github-cli@2.0 + gh: circleci/github-cli@2.3.0 node: circleci/node@5.1.1 + android: circleci/android@2.4.0 + rn: react-native-community/react-native@7.1.1 + +commands: + e2e_build_android_cmd: + steps: + - run: | + java -version + yarn e2e:build android.emu.debug + install_java: + steps: + - run: + name: Install Java + command: | + sudo apt-get update && sudo apt-get install -y openjdk-8-jdk + sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/bin/java + sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac + java -version parameters: version: @@ -28,9 +46,9 @@ parameters: default: "" jobs: - test_android_in_pr: + e2e_build_android: docker: - - image: cimg/android:2022.12 + - image: cimg/android:2022.12 resource_class: xlarge environment: TERM: dumb @@ -38,131 +56,42 @@ jobs: GRADLE_OPTS: -Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError" working_directory: ~/galoy-mobile shell: /bin/bash --login -o pipefail + # executor: + # name: rn/linux_android + # resource_class: xlarge steps: - # if workflow was triggered by API then don't run the test jobs - - run: | - if [ << pipeline.trigger_source >> = "api" ]; then - circleci-agent step halt - fi - - checkout: - path: ~/galoy-mobile - + - checkout - node/install: install-yarn: true node-version: '18.18.2' - - - run: sudo apt-get install gcc g++ make - - run: gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - - - restore_cache: - key: 1-gem-{{ checksum "android/Gemfile.lock" }} - - run: cd android && bundle config set deployment 'true' - - run: cd android && bundle check || bundle install - - save_cache: - key: 1-gem-{{ checksum "android/Gemfile.lock" }} - paths: - - android/vendor - - - restore_cache: - key: yarn-{{ checksum "yarn.lock" }} - - run: yarn install - - save_cache: - key: yarn-{{ checksum "yarn.lock" }} + - install_java + - rn/yarn_install + - e2e_build_android_cmd + - persist_to_workspace: + root: ~/galoy-mobile paths: - - node_modules - - run: echo $RELEASE_KEYSTORE | base64 -d > android/app/release.keystore - - run: yarn android:prepareAssets - - run: - name: Test Browserstack - command: | - set -o pipefail - cd android && bundle exec fastlane browserstack | tee browserstack_output.log - error_code=$? - SESSION_ID=$(cat browserstack_output.log | grep sessionId | head -n1 | sed -n "s/^.*'\(.*\)'.*$/\1/ p") - echo "Session ID" - echo $SESSION_ID - echo "Browserstack URL" - echo "https://app-automate.browserstack.com/dashboard/v2/builds/$BROWSERSTACK_ANDROID_BUILD/sessions/$SESSION_ID" - VIDEO_URL=$(curl -s -u "$BROWSERSTACK_USER:$BROWSERSTACK_ACCESS_KEY" -X GET "https://api-cloud.browserstack.com/app-automate/sessions/$SESSION_ID.json" | jq -r '.automation_session.video_url') - echo "Video URL" - echo $VIDEO_URL - exit $error_code - - test_ios_in_pr: - macos: - xcode: 14.2.0 - resource_class: macos.x86.medium.gen2 - working_directory: ~/galoy-mobile - environment: - FL_OUTPUT_DIR: output - shell: /bin/bash --login -o pipefail + - android/app/build + e2e_run_android: + executor: + name: android/android-machine + resource-class: xlarge + tag: 2023.12.1 steps: - # if workflow was triggered by API then don't run the test jobs - - run: | - if [ << pipeline.trigger_source >> = "api" ]; then - circleci-agent step halt - fi - - checkout: - path: ~/galoy-mobile - - - run: - name: Check Ruby version - command: | - rbenv versions - echo "Ruby version in .ruby-version:" - cat .ruby-version - echo "Ruby version in Gemfile:" - grep -E "^ruby" Gemfile - - - run: - name: Install Bundler 2.2.30 - command: | - gem install bundler:2.2.30 - echo "export BUNDLE_PATH=$(bundle show --path)" >> $BASH_ENV - source $BASH_ENV - - - add_ssh_keys: - fingerprints: - - "19:7e:f3:6c:be:a7:17:01:7d:09:ca:39:c3:98:86:90" - - restore_cache: - key: 1-gem-{{ checksum "ios/Gemfile.lock" }} - - run: cd ios && bundle config set deployment 'true' - - run: cd ios && bundle config set --local path 'vendor/bundle' - - run: cd ios && bundle check || bundle install - - run: gem install cocoapods - - save_cache: - key: 1-gem-{{ checksum "ios/Gemfile.lock" }} - paths: - - ios/vendor - - restore_cache: - key: 1-yarn-{{ checksum "yarn.lock" }}-pod1-{{ checksum "ios/Podfile.lock" }} - - run: yarn install - - save_cache: - key: 1-yarn-{{ checksum "yarn.lock" }}-pod1-{{ checksum "ios/Podfile.lock" }} - paths: - - node_modules - - ios/Pods - - run: - name: Import Apple Certificates - command: | - tmpfile=$(mktemp /tmp/wwdr-cert.cer) - curl -f -o $tmpfile https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer && security import $tmpfile ~/Library/Keychains/login.keychain-db - - run: - name: Browserstack Testing - command: | - set -o pipefail - cd ios && bundle exec fastlane browserstack | tee browserstack_output.log - error_code=$? - SESSION_ID=$(cat browserstack_output.log | grep sessionId | head -n1 | sed -n "s/^.*'\(.*\)'.*$/\1/ p") - echo "Session ID" - echo $SESSION_ID - echo "Browserstack URL" - echo "https://app-automate.browserstack.com/dashboard/v2/builds/$BROWSERSTACK_IOS_BUILD/sessions/$SESSION_ID" - VIDEO_URL=$(curl -s -u "$BROWSERSTACK_USER:$BROWSERSTACK_ACCESS_KEY" -X GET "https://api-cloud.browserstack.com/app-automate/sessions/$SESSION_ID.json" | jq -r '.automation_session.video_url') - echo "Video URL" - echo $VIDEO_URL - exit $error_code - no_output_timeout: 15m + - attach_workspace: + at: . + - node/install: + install-yarn: true + node-version: '18.18.2' + - rn/yarn_install + - android/create-avd: + avd-name: Pixel_API_29_AOSP + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: Pixel_API_29_AOSP + no-window: true + post-emulator-launch-assemble-command: "" + - run: yarn e2e:test android.emu.debug --headless -d -R 3 --record-videos build_android: docker: @@ -354,5 +283,7 @@ workflows: not: equal: [main, << pipeline.git.branch >>] jobs: - - test_android_in_pr - - test_ios_in_pr + - e2e_build_android + - e2e_run_android: + requires: + - e2e_build_android diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e82429e01b..fb99fdf27a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,108 +1,108 @@ -name: E2E - -on: [pull_request] - -jobs: - android: - name: E2E (Android) - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v2 - with: - node-version: 20 - - - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - 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: NOPOSTINSTALLPODS=1 yarn install - - - name: Build app - run: yarn e2e:build android.emu.debug - - - name: Start Metro - run: | - yarn start & - echo "METRO_PID=$!" >> $GITHUB_ENV - - - name: Run Detox Tests (test attempt 1) - continue-on-error: true - id: test1 - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - avd-name: Pixel_API_29_AOSP - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 - - - name: Run Detox Tests (test attempt 2) - 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 - emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 - - - 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 - emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 - arch: x86_64 - script: yarn e2e:test android.emu.debug --headless -d -R 3 +# name: E2E + +# on: [pull_request] + +# jobs: +# android: +# name: E2E (Android) +# runs-on: macos-latest + +# steps: +# - uses: actions/checkout@v2 + +# - uses: actions/setup-node@v2 +# with: +# node-version: 20 + +# - uses: actions/setup-java@v2 +# with: +# java-version: '11' +# distribution: 'adopt' + +# - 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: NOPOSTINSTALLPODS=1 yarn install + +# - name: Build app +# run: yarn e2e:build android.emu.debug + +# - name: Start Metro +# run: | +# yarn start & +# echo "METRO_PID=$!" >> $GITHUB_ENV + +# - name: Run Detox Tests (test attempt 1) +# continue-on-error: true +# id: test1 +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 29 +# avd-name: Pixel_API_29_AOSP +# force-avd-creation: false +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 +# arch: x86_64 +# script: yarn e2e:test android.emu.debug --headless -d -R 3 + +# - name: Run Detox Tests (test attempt 2) +# 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 +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 +# arch: x86_64 +# script: yarn e2e:test android.emu.debug --headless -d -R 3 + +# - 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 +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047 +# arch: x86_64 +# script: yarn e2e:test android.emu.debug --headless -d -R 3 - - name: Terminate Metro - if: always() - continue-on-error: true - run: kill $METRO_PID +# - name: Terminate Metro +# if: always() +# continue-on-error: true +# run: kill $METRO_PID - # ios: - # name: E2E (iOS) - # runs-on: macOS-latest +# # ios: +# # name: E2E (iOS) +# # runs-on: macOS-latest - # steps: - # - uses: actions/checkout@v2 +# # steps: +# # - uses: actions/checkout@v2 - # - uses: actions/setup-node@v2 - # with: - # node-version: 20 +# # - uses: actions/setup-node@v2 +# # with: +# # node-version: 20 - # - uses: ruby/setup-ruby@v1 - # with: - # bundler-cache: true +# # - uses: ruby/setup-ruby@v1 +# # with: +# # bundler-cache: true - # - run: yarn install +# # - run: yarn install - # - name: Detox deps for ios - # run: | - # brew tap wix/brew - # brew install applesimutils +# # - name: Detox deps for ios +# # run: | +# # brew tap wix/brew +# # brew install applesimutils - # - name: Build app - # run: yarn e2e:build ios.sim.debug +# # - name: Build app +# # run: yarn e2e:build ios.sim.debug - # - name: Run Detox Tests - # run: bash ${{ github.workspace }}/ci/tasks/e2e-ios.sh +# # - name: Run Detox Tests +# # run: bash ${{ github.workspace }}/ci/tasks/e2e-ios.sh