Skip to content

Commit

Permalink
circleci e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Jan 3, 2024
1 parent 117da31 commit f15a49f
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 222 deletions.
167 changes: 44 additions & 123 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
version: 2.1

orbs:
gh: circleci/[email protected]
gh: circleci/github-cli@2.3.0
node: circleci/[email protected]
android: circleci/[email protected]
rn: react-native-community/[email protected]

commands:
e2e_build_android_cmd:
steps:
- android/restore-gradle-cache
- run: |
yarn e2e:build android.emu.debug
- android/save-gradle-cache

parameters:
version:
Expand All @@ -28,7 +38,7 @@ parameters:
default: ""

jobs:
test_android_in_pr:
e2e_build_android:
docker:
- image: cimg/android:2022.12
resource_class: xlarge
Expand All @@ -39,130 +49,39 @@ jobs:
working_directory: ~/galoy-mobile
shell: /bin/bash --login -o pipefail
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: sudo apt-get install gcc g++ make
- run: gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
- 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'
- 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:
Expand Down Expand Up @@ -354,5 +273,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
Loading

0 comments on commit f15a49f

Please sign in to comment.