Browse Source

trying to run on OSX

Daniel Zlotin 7 years ago
parent
commit
6c9bf6fe51

+ 6
- 6
.travis.yml View File

@@ -1,17 +1,15 @@
1
-language: java
2
-
3
-jdk:
4
-  - oraclejdk8
1
+os: osx
2
+osx_image: xcode8.1
5 3
 
6 4
 env:
7 5
   global:
8 6
     - NODE_VERSION=stable
9 7
     - PATH=$PATH:$HOME/.yarn/bin
10
-    - ANDROID_HOME=$HOME/android-sdk-linux
8
+    - ANDROID_HOME=$HOME/android-sdk-macosx
11 9
     - PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
12 10
 
13 11
 git:
14
-  depth: 3
12
+  depth: 10
15 13
 
16 14
 branches:
17 15
   only:
@@ -31,6 +29,8 @@ before_cache:
31 29
 
32 30
 before_install:
33 31
   - set -e
32
+  - brew update
33
+  - brew cask install java
34 34
   - nvm install $NODE_VERSION
35 35
   - curl -o- -L https://yarnpkg.com/install.sh | bash
36 36
 

+ 5
- 2
playground/e2e/init.js View File

@@ -1,11 +1,14 @@
1 1
 /*eslint-disable*/
2 2
 require('babel-polyfill');
3 3
 const detox = require('detox');
4
-const config = require('../package.json').detox;
4
+const detoxConfig = require('../package.json').detox;
5
+
6
+const release = process.env.detoxMode === 'release';
5 7
 
6 8
 before(function(done) {
7 9
   this.timeout(30000);
8
-  detox.config(config);
10
+  detoxConfig['ios-simulator'].app = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
11
+  detox.config(detoxConfig);
9 12
   detox.start(done);
10 13
 });
11 14
 

+ 1
- 2
playground/package.json View File

@@ -24,8 +24,7 @@
24 24
       "sessionId": "playground"
25 25
     },
26 26
     "ios-simulator": {
27
-      "app": "ios/DerivedData/playground/Build/Products/Debug_Detox-iphonesimulator/playground.app",
28
-      "device": "iPhone 7, iOS 10.2"
27
+      "device": "iPhone 7"
29 28
     }
30 29
   },
31 30
   "babel": {

+ 29
- 20
playground/scripts/e2e.ios.js View File

@@ -1,43 +1,52 @@
1
-const cp = require('child_process');
1
+const _ = require('lodash');
2
+const exec = require('./exec');
3
+const fs = require('fs');
2 4
 
3
-function exec(cmd) {
4
-  cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
5
-}
6
-
7
-function execSilent(cmd) {
8
-  cp.execSync(cmd, {stdio: ['inherit', 'ignore', 'inherit']});
9
-}
5
+const release = _.includes(process.argv, 'release');
10 6
 
11
-function kill(process) {
12
-  execSilent(`pkill -f "${process}" || true`);
7
+function hackReactXcodeScript() {
8
+  const fileToHack = `./node_modules/react-native/packager/react-native-xcode.sh`;
9
+  const lines = _.split(String(fs.readFileSync(fileToHack)), '\n');
10
+  lines[11] = release ? '' : `exit 0;`;
11
+  fs.writeFileSync(fileToHack, _.join(lines, '\n'));
13 12
 }
14 13
 
15 14
 function buildProjForDetox() {
16
-  exec(`RCT_NO_LAUNCH_PACKAGER=true \
15
+  const scheme = release ? `playground_release_Detox` : `playground_Detox`;
16
+  const args = release ? '' : `GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`;
17
+
18
+  exec.exec(`RCT_NO_LAUNCH_PACKAGER=true \
17 19
           cd ios && xcodebuild \
18
-            -scheme playground_Detox build \
20
+            -scheme ${scheme} build \
19 21
             -project playground.xcodeproj \
20 22
             -sdk iphonesimulator \
21 23
             -derivedDataPath ./DerivedData/playground \
22
-            GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`);
24
+            ${args}`);
23 25
 }
24 26
 
25 27
 function e2e() {
26 28
   try {
27 29
     kill(`detox-server`);
28
-    cp.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
29
-    exec(`BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
30
+    exec.execAsync(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
31
+    exec.exec(`${release ? 'detoxMode=release' : ''} BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
30 32
   } finally {
31 33
     kill(`detox-server`);
32
-    //kill(`Simulator`);
33
-    //kill(`CoreSimulator`);
34
-    exec(`cat ./detox-server.log`);
35
-    exec(`rm -f ./detox-server.log`);
36
-    exec(`sleep 5`);
34
+    if (release) {
35
+      kill(`Simulator`);
36
+      kill(`CoreSimulator`);
37
+    }
38
+    exec.exec(`cat ./detox-server.log`);
39
+    exec.exec(`rm -f ./detox-server.log`);
40
+    exec.exec(`sleep 5`);
37 41
   }
38 42
 }
39 43
 
44
+function kill(process) {
45
+  exec.execSilent(`pkill -f "${process}"`);
46
+}
47
+
40 48
 function run() {
49
+  hackReactXcodeScript();
41 50
   buildProjForDetox();
42 51
   e2e();
43 52
 }

+ 24
- 0
playground/scripts/exec.js View File

@@ -0,0 +1,24 @@
1
+const cp = require('child_process');
2
+
3
+function exec(cmd) {
4
+  cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
5
+}
6
+
7
+function execSilent(cmd) {
8
+  cp.execSync(`${cmd} || true`, {stdio: ['ignore', 'ignore', 'ignore']});
9
+}
10
+
11
+function execRead(cmd) {
12
+  return String(cp.execSync(cmd, {stdio: ['pipe', 'pipe', 'pipe']})).trim();
13
+}
14
+
15
+function execAsync(cmd) {
16
+  cp.exec(cmd);
17
+}
18
+
19
+module.exports = {
20
+  exec,
21
+  execSilent,
22
+  execRead,
23
+  execAsync
24
+};

+ 1
- 1
scripts/installAndroidSDK.sh View File

@@ -5,7 +5,7 @@ mkdir -p ~/.android
5 5
 
6 6
 # download android SDK
7 7
 echo "Downloading Android SDK"
8
-curl --location http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz | tar -x -z -C $HOME
8
+curl --location https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip | tar -x -z -C $HOME
9 9
 
10 10
 # copy licenses
11 11
 echo "Copying Android licenses"