Skip to content

Commit 02e56ba

Browse files
author
Krzysztof
authored
chore: Script files cleanup (#497)
1 parent 63bef8f commit 02e56ba

File tree

5 files changed

+62
-57
lines changed

5 files changed

+62
-57
lines changed

.circleci/config.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ jobs:
179179
working_directory: example/ios
180180
command: pod install
181181
- save-cache: *cache_save_pods
182+
- run:
183+
name: Boot simulator
184+
background: true
185+
command: ./scripts/ios_e2e.sh 'run_simulator'
182186
- run:
183187
name: Build iOS app
184188
command: yarn build:e2e:ios
@@ -206,9 +210,7 @@ jobs:
206210
command: yarn bundle:android --dev false
207211
- run:
208212
name: Build APK
209-
working_directory: example/android
210-
command: ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2
211-
213+
command: yarn build:e2e:android
212214
- persist_to_workspace:
213215
root: ~/async_storage
214216
paths:
@@ -275,7 +277,7 @@ jobs:
275277
-logcat '*:W' | grep -i "ReactNative"
276278
- run:
277279
name: Wait for emulator to boot
278-
command: yarn build:e2e:android
280+
command: ./scripts/android_e2e.sh 'wait_for_emulator'
279281
- run:
280282
name: Wake device
281283
command: |

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@
4545
"start:web": "expo start:web",
4646
"start:macos": "react-native start --use-react-native-macos",
4747
"start:windows": "react-native start --use-react-native-windows",
48-
"build:e2e:android": "detox build -c android.emu.release",
49-
"build:e2e:ios": "detox build -c ios.sim.release",
50-
"build:e2e:macos": "scripts/run_macos_e2e.sh 'build'",
51-
"bundle:android": "react-native bundle --entry-file index.js --platform android --bundle-output example/index.android.jsbundle",
52-
"bundle:ios": "react-native bundle --entry-file index.js --platform ios --bundle-output example/index.ios.jsbundle",
48+
"build:e2e:android": "scripts/android_e2e.sh 'build'",
49+
"build:e2e:ios": "scripts/ios_e2e.sh 'build'",
50+
"build:e2e:macos": "scripts/macos_e2e.sh 'build'",
51+
"bundle:android": "scripts/android_e2e.sh 'bundle'",
52+
"bundle:ios": "scripts/ios_e2e.sh 'bundle'",
5353
"test": "yarn test:lint && yarn test:flow",
5454
"test:flow": "flow check",
5555
"test:lint": "eslint src/**/*.js example/**/*.js jest/*.js",
5656
"test:e2e:android": "detox test -c android.emu.release --maxConcurrency 1",
5757
"test:e2e:ios": "detox test -c ios.sim.release --maxConcurrency 1",
58-
"test:e2e:macos": "scripts/run_macos_e2e.sh 'test'"
58+
"test:e2e:macos": "scripts/macos_e2e.sh 'test'"
5959
},
6060
"peerDependencies": {
6161
"react": "^16.8",
@@ -105,7 +105,6 @@
105105
"configurations": {
106106
"ios.sim.release": {
107107
"binaryPath": "example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app",
108-
"build": ".circleci/scripts/run_ios_e2e.sh \"iPhone 11\"",
109108
"type": "ios.simulator",
110109
"device": {
111110
"type": "iPhone 11"
@@ -114,7 +113,6 @@
114113
"android.emu.release": {
115114
"binaryPath": "example/android/app/build/outputs/apk/release/app-release.apk",
116115
"testBinaryPath": "example/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk",
117-
"build": ".circleci/scripts/run_android_e2e.sh",
118116
"type": "android.emulator",
119117
"device": {
120118
"avdName": "Emu_E2E"

.circleci/scripts/run_android_e2e.sh renamed to scripts/android_e2e.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#!/bin/bash
22

3-
# On CI, waits for emu to be booted
4-
# Locally, builds apk
5-
6-
ROOT_DIR=$PWD
7-
83
INTERVAL=5 # 5 secs between each check
94
MAX_RETRIES=60 # wait max 5 minutes for emu to boot
105

116
build_apk() {
127
echo
138
echo "[Detox e2e] Building APK"
14-
yarn bundle:android --dev false
15-
cd example/android
16-
./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release
17-
cd ${ROOT_DIR}
9+
(cd example/android; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release --max-workers 2)
10+
}
11+
12+
bundle_js() {
13+
extraArgs="$@"
14+
echo
15+
echo "[Detox e2e] Bundling JS"
16+
react-native bundle --entry-file index.js --platform android --bundle-output example/index.android.jsbundle $extraArgs
1817
}
1918

2019
wait_for_emulator_to_boot() {
@@ -41,8 +40,19 @@ wait_for_emulator_to_boot() {
4140
echo "[Detox e2e] Emulator booted."
4241
}
4342

44-
if [[ -n $CIRCLECI ]]; then
45-
wait_for_emulator_to_boot # Run it on CI
46-
else
47-
build_apk # Run locally
48-
fi
43+
44+
case $1 in
45+
wait_for_emulator)
46+
wait_for_emulator_to_boot
47+
;;
48+
build)
49+
build_apk
50+
;;
51+
bundle)
52+
shift; bundle_js $@
53+
;;
54+
*)
55+
echo -n "Unknown argument: $1"
56+
;;
57+
esac
58+

.circleci/scripts/run_ios_e2e.sh renamed to scripts/ios_e2e.sh

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RESOURCE_DIR="$PWD/example/ios/build/Build/Products/Release-iphonesimulator/Reac
44
ENTRY_FILE="example/index.js"
55
BUNDLE_FILE="$RESOURCE_DIR/main.jsbundle"
66
EXTRA_PACKAGER_ARGS="--entry-file=$ENTRY_FILE"
7+
SIMULATOR_NAME="iPhone 11"
78

89
build_project() {
910
echo "[Detox e2e] Building iOS project"
@@ -18,19 +19,6 @@ build_project() {
1819
}
1920

2021
run_simulator() {
21-
if [[ -n $1 ]]; then
22-
deviceName=$1
23-
else
24-
echo "[Detox e2e] Device name not passed!" >&2;
25-
exit;
26-
fi
27-
28-
29-
if [[ $2 = "headless" ]]; then
30-
runHeadless=1
31-
else
32-
runHeadless=0
33-
fi
3422

3523
# Find simulator
3624
devDir=`xcode-select -p`
@@ -39,40 +27,47 @@ run_simulator() {
3927
# parse output
4028
availableDevices=$(
4129
eval "xcrun simctl list devices" |\
42-
eval "sed '/"$deviceName"/!d'" |\
30+
eval "sed '/"$SIMULATOR_NAME"/!d'" |\
4331
eval "sed '/unavailable/d'" |\
4432
eval "sed 's/(Shutdown)//; s/(Shutting Down)//; s/(Booted)//; s/ (/*/; s/)//'"
4533
)
4634

4735
IFS='*' read -a deviceInfo <<< "$availableDevices"
4836

4937
if [[ $deviceInfo == "" ]]; then
50-
echo "[Detox e2e] Could not find device: $deviceName" >&2
38+
echo "[Detox e2e] Could not find device: $SIMULATOR_NAME" >&2
5139
exit;
5240
fi
5341

54-
5542
deviceUUID=${deviceInfo[1]}
5643

57-
echo "[Detox e2e] Booting up $deviceName (id: $deviceUUID)"
44+
echo "[Detox e2e] Booting up $SIMULATOR_NAME (id: $deviceUUID)"
5845

5946
# Booting emulator in headless mode
6047
eval "open $devDir --args -CurrentDeviceUDID $deviceUUID"
61-
62-
# Decide if should run headless or not
63-
if [ "$runHeadless" -eq 0 ]; then
64-
eval "xcrun instruments -w $deviceUUID" >/dev/null 2>&1
65-
else
66-
echo "[Detox e2e] Running simulator in headless mode."
67-
fi
48+
eval "xcrun instruments -w $deviceUUID" >/dev/null 2>&1
49+
exit 0
6850
}
6951

70-
build_project
71-
72-
sleep 2
73-
74-
run_simulator "$1" "$2"
52+
bundle_js() {
53+
extraArgs="$@"
54+
echo
55+
echo "[Detox e2e] Bundling JS"
56+
react-native bundle --entry-file index.js --platform ios --bundle-output example/index.ios.jsbundle $extraArgs
57+
}
7558

76-
sleep 10
7759

78-
exit 0
60+
case $1 in
61+
build)
62+
build_project
63+
;;
64+
run_simulator)
65+
run_simulator
66+
;;
67+
bundle)
68+
shift; bundle_js $@
69+
;;
70+
*)
71+
echo -n "Unknown argument: $1"
72+
;;
73+
esac
File renamed without changes.

0 commit comments

Comments
 (0)