Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove 3rd party rn orb #16

Merged
merged 19 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 171 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,162 @@
version: 2.1

orbs:
rn: react-native-community/react-native@5.6.2
executors:
linux_js:
docker:
- image: circleci/node:14.15.0
resource_class: medium
environment:
PATH: '/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

macos_custom:
parameters:
xcode_version:
type: string
default: '12.4.0'
macos:
xcode: <<parameters.xcode_version>>

commands:
attach_project:
steps:
- attach_workspace:
at: ~/project

ios_simulator_start:
steps:
- run:
name: Start iOS simulator (background)
background: true
command: xcrun simctl boot "11" || true

pod_install:
parameters:
pod_install_directory:
type: string
default: 'example/ios'

steps:
- restore_cache:
keys:
- cache-pods-{{ checksum "<<parameters.pod_install_directory>>/Podfile.lock" }}-v1
- cache-pods-
- run:
name: Install CocoaPods
command: |
cd <<parameters.pod_install_directory>> && pod install && cd -
- save_cache:
paths:
- <<parameters.pod_install_directory>>/Pods
key: cache-pods-{{ checksum "<<parameters.pod_install_directory>>/Podfile.lock" }}-v1

setup_macos_executor:
parameters:
node_version:
type: string
default: '14.15.0'
steps:
- attach_workspace:
at: .
- run:
name: Configure Environment Variables
command: |
echo 'export PATH="$PATH:/usr/local/opt/node@<<parameters.node_version>>/bin:~/.yarn/bin:~/project/node_modules/.bin:~/project/example/node_modules/.bin"' >> $BASH_ENV
echo 'export ANDROID_HOME="/usr/local/share/android-commandlinetools"' >> $BASH_ENV
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-commandlinetools"' >> $BASH_ENV
echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> $BASH_ENV
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> $BASH_ENV
source $BASH_ENV
- restore_cache:
key: |
brew-cache-{{ arch }}-v1
- run:
name: Install node@<<parameters.node_version>>
command: |
set +e
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
source ~/.bashrc
command -v nvm
nvm install <<parameters.node_version>>
nvm alias default <<parameters.node_version>>
- run:
name: Configure Detox Environment
command: |
brew update >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install android-commandlinetools >/dev/null
touch .watchmanconfig
node -v
android_emulator_start:
parameters:
device_name:
type: string
default: 'TestingAVD'
platform_version:
type: string
default: 'android-28'
build_tools_version:
type: string
default: '30.0.2'
logcat_grep:
type: string
default: 'com.example.stripeterminalreactnative'

steps:
- run:
name: Install Android Emulator
shell: /bin/bash -e
command: |
yes | sdkmanager "platform-tools" "tools" >/dev/null
yes | sdkmanager "platforms;<<parameters.platform_version>>" "system-images;<<parameters.platform_version>>;default;x86_64" >/dev/null
yes | sdkmanager "emulator" --channel=3 >/dev/null
yes | sdkmanager "build-tools;<<parameters.build_tools_version>>" >/dev/null
yes | sdkmanager --licenses >/dev/null
yes | sdkmanager --list
- run:
name: ADB Start Stop
command: |
adb start-server
adb devices
adb kill-server
ls -la ~/.android
- run:
name: Create Android Emulator
command:
avdmanager create avd --force --name <<parameters.device_name>> --package
"system-images;<<parameters.platform_version>>;default;x86_64" --tag
default --device pixel

- run:
name: Start Android Emulator (background)
command: |
$ANDROID_HOME/emulator/emulator @<<parameters.device_name>> -version
$ANDROID_HOME/emulator/emulator @<<parameters.device_name>> -cores 2 -gpu auto -accel on -memory 2048 -no-audio -no-snapshot -no-boot-anim -no-window -logcat *:W | grep -i 'ReactNative\|<<parameters.logcat_grep>>'
background: true

- run:
name: Wait for AVD to be ready
no_output_timeout: '5m'
command: |
export BOOT=""
echo "Waiting for AVD to finish booting"
export PATH=$(dirname $(dirname $(command -v android)))/platform-tools:$PATH
until [[ "$BOOT" =~ "1" ]]; do
sleep 5
export BOOT=$(adb -e shell getprop sys.boot_completed 2>&1)
done
sleep 15
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
echo "Android Virtual Device is now ready."
jobs:
install-dependencies:
executor: rn/linux_js
executor: linux_js
steps:
- checkout
- attach_project
Expand Down Expand Up @@ -39,48 +184,52 @@ jobs:
paths: [.]

lint:
executor: rn/linux_js
executor: linux_js
steps:
- attach_project
- run:
name: Lint files
command: |
yarn lint

typescript:
executor: rn/linux_js
executor: linux_js
steps:
- attach_project
- run:
name: Typecheck files
command: |
yarn typescript

test:
executor: rn/linux_js
executor: linux_js
steps:
- attach_project
- run:
name: Integration tests
command: |
yarn test

e2e-ios:
executor:
name: rn/macos
xcode_version: '12.4.0'
executor: macos_custom

steps:
- attach_workspace:
at: .
- rn/setup_macos_executor:
node_version: '14.15.0'
- rn/ios_simulator_start:
device: 'iPhone 11'

- setup_macos_executor

- ios_simulator_start

- run:
command: yarn install --frozen-lockfile
name: yarn install
- rn/pod_install:
pod_install_directory: 'example/ios'

- run:
command: |
rm example/node_modules/react-native/scripts/find-node.sh
touch example/node_modules/react-native/scripts/find-node.sh
name: remove find node

- pod_install

- run:
command: yarn e2e:build:ios:release
name: build for detox
Expand All @@ -92,19 +241,16 @@ jobs:

e2e-android:
executor:
name: rn/macos
xcode_version: '12.4.0'
name: macos_custom
steps:
- attach_workspace:
at: .
- rn/setup_macos_executor:
node_version: '14.15.0'
- setup_macos_executor

- run:
command: yarn install --frozen-lockfile
name: yarn install
- rn/android_emulator_start:
logcat_grep: 'com.example.stripeterminalreactnative'
platform_version: android-28
- android_emulator_start
- run:
command: yarn e2e:build:android:release
name: build for detox
Expand All @@ -125,9 +271,6 @@ workflows:
- typescript:
requires:
- install-dependencies
- test:
requires:
- install-dependencies
- e2e-android:
requires:
- install-dependencies
Expand Down
15 changes: 9 additions & 6 deletions e2e/app.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ const {

describe('Payments', () => {
beforeAll(async () => {
await device.launchApp({ permissions: { location: 'always' } });
// await device.disableSynchronization();
});

beforeEach(async () => {
await device.reloadReactNative();
await device.launchApp({
permissions: { location: 'always' },
newInstance: true,
});
});

afterAll(async () => {
Expand Down Expand Up @@ -115,7 +118,7 @@ describe('Payments', () => {
await goBack('logs-back');
await goBack('payment-back');

await disconnectReader();
// await disconnectReader();
});

it('Store card via readReusableCard', async () => {
Expand All @@ -138,7 +141,7 @@ describe('Payments', () => {
await goBack('logs-back');
await goBack('payment-back');

await disconnectReader();
// await disconnectReader();
});

it('Store card via SetupIntent', async () => {
Expand All @@ -164,7 +167,7 @@ describe('Payments', () => {
await goBack('logs-back');
await goBack('payment-back');

await disconnectReader();
// await disconnectReader();
});

it('In-Person Refund failed due to unsupported country', async () => {
Expand Down Expand Up @@ -202,6 +205,6 @@ describe('Payments', () => {
await goBack('logs-back');
await goBack('payment-back');

await disconnectReader();
// await disconnectReader();
});
});
2 changes: 1 addition & 1 deletion e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 480000,
"testTimeout": 200000,
"testRegex": "\\.e2e\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
Expand Down
4 changes: 2 additions & 2 deletions e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const setSimulatedUpdatePlan = async (
by.text(defaultPlan).withAncestor(by.id('picker-container'))
).tap();
await element(by.text(plan)).tap();
waitFor(element(by.id('close-picker')))
await waitFor(element(by.id('close-picker')))
.toBeVisible()
.withTimeout(10000);
element(by.id('close-picker')).tap();
await element(by.id('close-picker')).tap();
}
};

Expand Down
6 changes: 5 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
androidTestImplementation('com.wix:detox:+')

androidTestImplementation('com.wix:detox:+'){
exclude group: 'com.google.android.material'
exclude group: 'androidx.appcompat'
}

implementation "com.stripe:stripeterminal:2.3.1"
androidTestUtil 'com.linkedin.testbutler:test-butler-app:2.2.1'
Expand Down
Loading