* [test] fix travis

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9bc95082
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9bc95082
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9bc95082

Branch: refs/heads/0.16-dev
Commit: 9bc95082e280bdfdb55c9c18c7457c810961ee2f
Parents: d3d842b
Author: gurisxie <279483...@qq.com>
Authored: Wed Sep 20 21:02:07 2017 +0800
Committer: gurisxie <279483...@qq.com>
Committed: Wed Sep 20 21:02:07 2017 +0800

----------------------------------------------------------------------
 .travis.yml           |  29 +++---------
 dangerfile-android.js | 108 +++++++++++++++++++++++++++++++++++++++++++++
 dangerfile-ios.js     |   4 +-
 3 files changed, 116 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9bc95082/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 6441986..dd0873a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,10 +30,10 @@ matrix:
       - os: linux
         env: TEST_SUITE=release
     include:
-      - os: osx
+      - os: linux
         env: TEST_SUITE=release
-        osx_image: xcode8.1
-        language: objective-c
+        osx_image: oraclejdk8
+        language: android
       - os: osx
         env: TEST_SUITE=ios
         osx_image: xcode8.1
@@ -63,25 +63,10 @@ before_script:
       nvm install 7.0
       npm install
     fi
-  - |
-    if [[ $TEST_SUITE = "release" ]]; then
-      brew update
-      #manual install android sdk
-      brew cask install android-sdk
-      brew install gradle
-      export ANDROID_HOME=/usr/local/share/android-sdk
-      export 
PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
-      echo yes | sdkmanager platform-tools
-      echo yes | sdkmanager tools #tools
-      echo yes | sdkmanager "build-tools;25.0.3" #build-tool
-      echo yes | sdkmanager "platforms;android-25" #compile target
-      echo yes | sdkmanager "extras;android;m2repository" #support
-    fi
 script:
   - |
     if [[ $TEST_SUITE = "android" ]]; then
-      cd android
-      ./gradlew clean assembleDebug :weex_sdk:testDebugUnitTest --info 
-PdisableCov=true -Dorg.gradle.daemon=true -Dorg.gradle.parallel=true 
-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError" 
-Dfile.encoding=UTF-8 &&
+      npm run danger -- --dangerfile=./dangerfile-android.js
       cd $TRAVIS_BUILD_DIR
     fi
   - |
@@ -95,14 +80,12 @@ script:
     fi
   - |
     if [[ $TEST_SUITE = "danger" ]]; then
-      npm run danger
+      npm run danger -- --dangerfile=./dangerfile.js
     fi
   - |
     if [[ $TEST_SUITE = "release" ]]; then
       bash scripts/generate_apache_release.sh &&
-      cd apache_release_temp &&
-      bash scripts/build_from_source.sh &&
-      cd $TRAVIS_BUILD_DIR
+      cd apache_release_temp
     fi
 notifications:
   webhooks:

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9bc95082/dangerfile-android.js
----------------------------------------------------------------------
diff --git a/dangerfile-android.js b/dangerfile-android.js
new file mode 100644
index 0000000..2e81f0a
--- /dev/null
+++ b/dangerfile-android.js
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// Removed import
+import fs from "fs";
+import path from 'path';
+import GitHubApi from 'github';
+import parseDiff from 'parse-diff';
+import shell from "shelljs";
+
+const type_unknown = 0;
+const type_ios_sdk = 1;
+const type_android_sdk = 2;
+const type_ios_test = 3;
+const type_android_test = 4;
+const type_jsfm = 5;
+const type_jsfm_test = 6;
+const type_doc = 7;
+const type_ui_test = 8;
+
+const getFileType = file => {
+  if (file.match(/WeexSDK\/Sources\/.+\.(m|h|mm)/)) {
+    return type_ios_sdk;
+  } else if (file.match(/WeexSDKTests\//)) {
+    return type_ios_test;
+  } else if (file.match(/android\/sdk\/src\/test\/.+\.java/)) {
+    return type_android_test;
+  } else if (file.match(/android\/sdk\/src\/main\/java\/.+\.java/)) {
+    return type_android_sdk;
+  } else if (
+    file.match(/html5\/(shared|frameworks|render|runtime|services)\/.+\.js/)
+  ) {
+    return type_jsfm;
+  } else if (file.match(/html5\/test\/.+\.js/)) {
+    return type_jsfm_test;
+  } else if (file.match(/doc\/\.+\.md/)) {
+    return type_doc;
+  } else if(file.match(/test\/scripts\/.+\.js/) || 
file.match(/test\/pages\/.+\.vue/)){
+    return type_ui_test
+  }else{
+    return type_unknown
+  }
+}
+
+function checkAndroidFile(file){
+  var type = getFileType(file);
+  return type == type_android_test || type == type_android_sdk || type == 
type_jsfm;
+}
+
+var hasAndroidFile = false;
+
+if (!hasAndroidFile && danger.git.created_files) {
+  danger.git.created_files.some(file => {
+    var f = checkAndroidFile(file);
+    if(f){
+      hasAndroidFile =f;
+    }
+    return f;
+  });
+}
+if (!hasAndroidFile && danger.git.modified_files) {
+  danger.git.modified_files.some(file => {
+    var f = checkAndroidFile(file);
+    if(f){
+      hasAndroidFile =f;
+    }
+    return f;
+  });
+}
+if (!hasAndroidFile && danger.git.deleted_files) {
+  danger.git.deleted_files.some(file => {
+    var f = checkAndroidFile(file);
+    if(f){
+      hasAndroidFile =f;
+    }
+    return f;
+  });
+}
+
+if(hasAndroidFile){
+  var runTestCmd='source ~/.bash_profile; '
+    +'cd android; '
+    +'./gradlew clean assembleDebug :weex_sdk:testDebugUnitTest --info 
-PdisableCov=true '
+    +'-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true 
-Dorg.gradle.jvmargs="-Xmx512m '
+    +'-XX:+HeapDumpOnOutOfMemoryError" -Dfile.encoding=UTF-8 '
+  var runSuccess = shell.exec(runTestCmd,{ async: false, timeout: 8 * 60 * 
1000 }).code == 0;
+  if(!runSuccess){
+    fail("android platform run unit test failed!");
+  }
+}else{
+  message('has no android file changed,skip test!');
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9bc95082/dangerfile-ios.js
----------------------------------------------------------------------
diff --git a/dangerfile-ios.js b/dangerfile-ios.js
index 1855e8e..dbaa7bb 100644
--- a/dangerfile-ios.js
+++ b/dangerfile-ios.js
@@ -95,7 +95,7 @@ if (!hasIosFile && danger.git.deleted_files) {
 if(hasIosFile){
   var brewUpdateCmd='source ~/.bash_profile; '
     + 'brew update'
-  var runSuccess = shell.exec(brewUpdateCmd,{ async: false, timeout: 8 * 60 * 
1000 }).code !== 0;
+  var runSuccess = shell.exec(brewUpdateCmd,{ async: false, timeout: 8 * 60 * 
1000 }).code == 0;
   if(!runSuccess){
     warn("ios platform brew update failed!");
   }
@@ -103,7 +103,7 @@ if(hasIosFile){
     +'xcodebuild -project ios/sdk/WeexSDK.xcodeproj test '
     +'-scheme WeexSDKTests CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO '
     +'-destination "platform=iOS Simulator,name=iPhone 6"'
-  runSuccess = shell.exec(runTestCmd,{ async: false, timeout: 8 * 60 * 1000 
}).code !== 0;
+  runSuccess = shell.exec(runTestCmd,{ async: false, timeout: 8 * 60 * 1000 
}).code == 0;
   if(!runSuccess){
     fail("ios platform run unit test failed!");
   }

Reply via email to