Browse Source

try run android emulator on travis

Daniel Zlotin 7 years ago
parent
commit
7d800f2a09

+ 1
- 7
.travis.yml View File

@@ -19,8 +19,6 @@ cache:
19 19
     - $HOME/.m2
20 20
 
21 21
 install:
22
-  - sysctl hw.ncpu
23
-  - sysctl hw.memsize
24 22
         # node:
25 23
   - source ./scripts/env/installNode.sh
26 24
         # yarn:
@@ -28,12 +26,8 @@ install:
28 26
   - yarn config set cache-folder $YARN_CACHE
29 27
         # android sdk:
30 28
   - source ./scripts/env/installAndroidSDK.sh
31
-        # android emulator:
32
-  #- echo yes | android update sdk --no-ui --all --filter "sys-img-armeabi-v7a-google_apis-25"
33
-  #- echo no | android create avd --name AVD -t android-25 --abi google_apis/armeabi-v7a
34
-  #- android list avd
35 29
         # fbsimctl:
36
-  - source ./scripts/env/installFbSimCtl.sh
30
+  # - source ./scripts/env/installFbSimCtl.sh
37 31
 
38 32
 script:
39 33
   - set -e

+ 2
- 0
scripts/env/android-sdk-licenses/android-googletv-license View File

@@ -0,0 +1,2 @@
1
+
2
+601085b94cd77f0b54ff86406957099ebe79c4d6

+ 1
- 0
scripts/env/android-sdk-licenses/android-sdk-license View File

@@ -1 +1,2 @@
1
+
1 2
 8933bad161af4178b1185d1a37fbf41ea5269c55

+ 2
- 0
scripts/env/android-sdk-licenses/android-sdk-preview-license View File

@@ -0,0 +1,2 @@
1
+
2
+84831b9409646a918e30573bab4c9c91346d8abd

+ 2
- 0
scripts/env/android-sdk-licenses/google-gdk-license View File

@@ -0,0 +1,2 @@
1
+
2
+33b6a2b64607f11b759f320ef9dff4ae5c47d97a

+ 2
- 0
scripts/env/android-sdk-licenses/intel-android-extra-license View File

@@ -0,0 +1,2 @@
1
+
2
+d975f751698a77b662f1254ddbeed3901e976f5a

+ 2
- 0
scripts/env/android-sdk-licenses/mips-android-sysimage-license View File

@@ -0,0 +1,2 @@
1
+
2
+e9acab5b5fbb560a72cfaecce8946896ff6aab9d

+ 17
- 6
scripts/env/installAndroidSDK.sh View File

@@ -2,17 +2,28 @@
2 2
 
3 3
 scriptdir="$(dirname "${BASH_SOURCE[0]}")"
4 4
 
5
-export ANDROID_HOME=$HOME/android-sdk-macosx
6
-export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
5
+export ANDROID_HOME=$HOME/android-sdk
6
+export PATH=$PATH:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
7
+
8
+mkdir $ANDROID_HOME
7 9
 
8 10
 # fix for https://code.google.com/p/android/issues/detail?id=223424
9 11
 mkdir -p ~/.android
12
+touch ~/.android/repositories.cfg
10 13
 
11
-# download android SDK
12 14
 echo "Downloading Android SDK"
13
-curl --location https://dl.google.com/android/android-sdk_r24.4.1-macosx.zip | tar -x -z -C $HOME
15
+curl --location https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip | tar -x -z -C $ANDROID_HOME
14 16
 
15
-# copy licenses
16
-echo "Copying Android licenses"
17
+echo "Copying Android Licenses"
17 18
 mkdir -p "${ANDROID_HOME}"/licenses
18 19
 cp "$scriptdir/android-sdk-licenses/"* "${ANDROID_HOME}"/licenses
20
+
21
+package="system-images;android-24;default;x86"
22
+echo "Downloading emulator"
23
+sdkmanager "emulator"
24
+echo "Downloading $package"
25
+sdkmanager "${package}"
26
+echo "Creating avd"
27
+echo no | avdmanager create avd --force --name "pixel" --abi "default/x86" --package "${package}" --device "pixel"
28
+sleep 2
29
+avdmanager list avd

+ 23
- 3
scripts/test.e2e.android.js View File

@@ -1,17 +1,37 @@
1
+/*eslint-disable no-console*/
1 2
 const _ = require('lodash');
2 3
 const exec = require('shell-utils').exec;
3 4
 
4 5
 const release = _.includes(process.argv, 'release');
5 6
 
7
+run();
8
+
6 9
 function run() {
7 10
   if (process.env.CI) {
8
-    console.log(`android e2e disabled on CI for now`); //eslint-disable-line
9
-    return;
11
+    try {
12
+      // console.log(`android e2e disabled on CI for now`);
13
+      launchEmulator();
14
+      runTests();
15
+    } finally {
16
+      killEmulators();
17
+    }
18
+  } else {
19
+    runTests();
10 20
   }
21
+}
11 22
 
23
+function runTests() {
12 24
   exec.execSync(`yarn run uninstall-android`);
13 25
   exec.execSync(`yarn run install-android ${release ? '-- release' : ''}`);
14 26
   exec.execSync(`cd AndroidE2E && ./gradlew connectedDebugAndroidTest`);
15 27
 }
16 28
 
17
-run();
29
+function launchEmulator() {
30
+  console.log(`Launching Android Emulator`);
31
+  exec.exec(`cd $ANDROID_HOME/tools && ./emulator -skin 1080x1920 -gpu host -no-audio @pixel`);
32
+  exec.execSync(`./scripts/waitForAndroidEmulator.sh`);
33
+}
34
+
35
+function killEmulators() {
36
+  exec.execSync(`adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done`);
37
+}

+ 4
- 4
scripts/travis.sh View File

@@ -21,9 +21,9 @@ run_f () {
21 21
 
22 22
 run_f "yarn install"
23 23
 run_f "yarn run clean"
24
-run_f "yarn run test-js"
24
+# run_f "yarn run test-js"
25 25
 run_f "yarn run test-unit-android -- release"
26
-run_f "yarn run test-unit-ios -- release"
26
+# run_f "yarn run test-unit-ios -- release"
27 27
 run_f "yarn run test-e2e-android -- release"
28
-run_f "yarn run test-e2e-ios -- release"
29
-run_f "yarn run release"
28
+# run_f "yarn run test-e2e-ios -- release"
29
+# run_f "yarn run release"

+ 21
- 0
scripts/waitForAndroidEmulator.sh View File

@@ -0,0 +1,21 @@
1
+#!/bin/bash -e
2
+
3
+bootanim=""
4
+failcounter=0
5
+timeout_in_sec=360
6
+
7
+until [[ "$bootanim" =~ "stopped" ]]; do
8
+  bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
9
+  if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
10
+    || "$bootanim" =~ "running" ]]; then
11
+    let "failcounter += 1"
12
+    echo "Waiting for emulator to start"
13
+    if [[ $failcounter -gt timeout_in_sec ]]; then
14
+      echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
15
+      exit 1
16
+    fi
17
+  fi
18
+  sleep 1
19
+done
20
+
21
+echo "Emulator is ready"