Browse Source

trying to run on OSX

Daniel Zlotin 8 years ago
parent
commit
6c9bf6fe51

+ 6
- 6
.travis.yml View File

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

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

1
 /*eslint-disable*/
1
 /*eslint-disable*/
2
 require('babel-polyfill');
2
 require('babel-polyfill');
3
 const detox = require('detox');
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
 before(function(done) {
8
 before(function(done) {
7
   this.timeout(30000);
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
   detox.start(done);
12
   detox.start(done);
10
 });
13
 });
11
 
14
 

+ 1
- 2
playground/package.json View File

24
       "sessionId": "playground"
24
       "sessionId": "playground"
25
     },
25
     },
26
     "ios-simulator": {
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
   "babel": {
30
   "babel": {

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

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
 function buildProjForDetox() {
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
           cd ios && xcodebuild \
19
           cd ios && xcodebuild \
18
-            -scheme playground_Detox build \
20
+            -scheme ${scheme} build \
19
             -project playground.xcodeproj \
21
             -project playground.xcodeproj \
20
             -sdk iphonesimulator \
22
             -sdk iphonesimulator \
21
             -derivedDataPath ./DerivedData/playground \
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
 function e2e() {
27
 function e2e() {
26
   try {
28
   try {
27
     kill(`detox-server`);
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
   } finally {
32
   } finally {
31
     kill(`detox-server`);
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
 function run() {
48
 function run() {
49
+  hackReactXcodeScript();
41
   buildProjForDetox();
50
   buildProjForDetox();
42
   e2e();
51
   e2e();
43
 }
52
 }

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

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
 
5
 
6
 # download android SDK
6
 # download android SDK
7
 echo "Downloading Android SDK"
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
 # copy licenses
10
 # copy licenses
11
 echo "Copying Android licenses"
11
 echo "Copying Android licenses"