From fccac66768114e602b9f3155188bcfd5cbbca1f6 Mon Sep 17 00:00:00 2001 From: Sandipan Dey Date: Wed, 3 Jan 2024 12:17:13 +0530 Subject: [PATCH] circleci e2e --- .circleci/config.yml | 173 ++++++++++--------------------------------- 1 file changed, 41 insertions(+), 132 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b716020d93..226994542f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,18 @@ 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: + - android/restore-gradle-cache + - run: | + yarn e2e:build android.emu.debug + - android/save-gradle-cache parameters: version: @@ -28,141 +38,41 @@ parameters: default: "" jobs: - test_android_in_pr: - docker: - - image: cimg/android:2022.12 - resource_class: xlarge - environment: - TERM: dumb - JAVA_OPTS: -Xms512m -Xmx2g - GRADLE_OPTS: -Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError" - working_directory: ~/galoy-mobile - shell: /bin/bash --login -o pipefail + e2e_build_android: + 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" }} + - 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' + - 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 +264,4 @@ workflows: not: equal: [main, << pipeline.git.branch >>] jobs: - - test_android_in_pr - - test_ios_in_pr + - e2e_android