Skip to content

Commit 3c654af

Browse files
authored
CI: Fix test failures (#147)
* CI: Fix lldb not found broken * CI: Add GitHub Actions trigger from PR * test: Fix test failure on CI. 1. Use reactivecircus/android-emulator-runner actions to create emulator. Make it clear and fix ILL_ILLOPC exception 2. Use release build to do the instrucment test. 3. Fix PRE_ON_CREATE hanging from ActivityScenario.launch
1 parent 618a23f commit 3c654af

File tree

5 files changed

+19
-162
lines changed

5 files changed

+19
-162
lines changed

.github/workflows/build_and_test.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build jsc-android and test
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
@@ -27,7 +27,6 @@ jobs:
2727
- name: Install Android packages
2828
run: |
2929
sdkmanager \
30-
"lldb;3.0" \
3130
"cmake;3.10.2.4988404"
3231
shell: bash
3332
- name: Build
@@ -44,7 +43,7 @@ jobs:
4443
mv dist.unstripped archive/
4544
shell: bash
4645

47-
- uses: actions/upload-artifact@master
46+
- uses: actions/upload-artifact@v2
4847
with:
4948
name: archive
5049
path: archive
@@ -57,33 +56,15 @@ jobs:
5756
steps:
5857
- uses: actions/checkout@v1
5958

60-
- uses: actions/download-artifact@master
59+
- uses: actions/download-artifact@v2
6160
with:
6261
name: archive
6362
path: archive
6463

65-
- name: Launch AVD
66-
run: |
67-
source scripts/android-setup.sh
68-
export PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}"
69-
export AVD_PACKAGES="system-images;android-${ANDROID_SDK_TARGET_API_LEVEL};google_apis;${AVD_ABI}"
70-
sdkmanager "${AVD_PACKAGES}"
71-
createAVD
72-
launchAVD &
73-
shell: bash
74-
75-
- name: Wait AVD
76-
run: |
77-
export PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}"
78-
source scripts/android-setup.sh
79-
set +e +o pipefail
80-
waitForAVD
81-
shell: bash
82-
8364
- name: Run test
84-
run: |
85-
mv archive/dist .
86-
cd test
87-
yarn
88-
cd android && ./gradlew assembleDebug assembleAndroidTest connectedAndroidTest
89-
shell: bash
65+
uses: reactivecircus/android-emulator-runner@v2
66+
with:
67+
api-level: 16
68+
arch: x86
69+
disable-animations: false
70+
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew assembleRelease assembleAndroidTest connectedAndroidTest

scripts/.tests.env

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/android-setup.sh

Lines changed: 0 additions & 95 deletions
This file was deleted.

test/android/app/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ android {
164164
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
165165
}
166166
}
167+
168+
testBuildType 'release'
169+
167170
// applicationVariants are e.g. debug, release
168171
applicationVariants.all { variant ->
169172
variant.outputs.each { output ->
@@ -192,10 +195,10 @@ dependencies {
192195
implementation jscFlavor
193196
}
194197

195-
androidTestImplementation 'androidx.test:core:1.1.0';
196-
androidTestImplementation 'androidx.test.ext:junit:1.1.0';
197-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
198-
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0';
198+
androidTestImplementation 'androidx.test:core:1.3.0';
199+
androidTestImplementation 'androidx.test.ext:junit:1.1.2';
200+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
201+
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0';
199202
}
200203

201204
// Run this once to be able to run the application with BUCK

test/android/app/src/androidTest/java/com/test/SimpleTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import android.view.View;
99

10-
import androidx.test.core.app.ActivityScenario;
1110
import androidx.test.espresso.ViewAction;
1211
import androidx.test.espresso.UiController;
1312
import androidx.test.espresso.PerformException;
1413
import androidx.test.espresso.util.TreeIterables;
1514
import androidx.test.espresso.util.HumanReadables;
1615
import androidx.test.filters.LargeTest;
16+
import androidx.test.ext.junit.rules.ActivityScenarioRule;
1717
import androidx.test.ext.junit.runners.AndroidJUnit4;
1818

1919
import java.util.concurrent.TimeoutException;
@@ -29,10 +29,8 @@
2929
@LargeTest
3030
public class SimpleTest {
3131

32-
@Before
33-
public void launchActivity() {
34-
ActivityScenario.launch(MainActivity.class);
35-
}
32+
@Rule public ActivityScenarioRule<MainActivity> activityScenarioRule
33+
= new ActivityScenarioRule<>(MainActivity.class);
3634

3735
@Test
3836
public void testIfAppLoads() {

0 commit comments

Comments
 (0)