Skip to content

Commit

Permalink
CI: Fix test failures (#147)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Kudo authored Mar 21, 2021
1 parent 618a23f commit 3c654af
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 162 deletions.
37 changes: 9 additions & 28 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build jsc-android and test

on: [push]
on: [push, pull_request]

jobs:
build:
Expand All @@ -27,7 +27,6 @@ jobs:
- name: Install Android packages
run: |
sdkmanager \
"lldb;3.0" \
"cmake;3.10.2.4988404"
shell: bash
- name: Build
Expand All @@ -44,7 +43,7 @@ jobs:
mv dist.unstripped archive/
shell: bash

- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v2
with:
name: archive
path: archive
Expand All @@ -57,33 +56,15 @@ jobs:
steps:
- uses: actions/checkout@v1

- uses: actions/download-artifact@master
- uses: actions/download-artifact@v2
with:
name: archive
path: archive

- name: Launch AVD
run: |
source scripts/android-setup.sh
export PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}"
export AVD_PACKAGES="system-images;android-${ANDROID_SDK_TARGET_API_LEVEL};google_apis;${AVD_ABI}"
sdkmanager "${AVD_PACKAGES}"
createAVD
launchAVD &
shell: bash

- name: Wait AVD
run: |
export PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}"
source scripts/android-setup.sh
set +e +o pipefail
waitForAVD
shell: bash

- name: Run test
run: |
mv archive/dist .
cd test
yarn
cd android && ./gradlew assembleDebug assembleAndroidTest connectedAndroidTest
shell: bash
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 16
arch: x86
disable-animations: false
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew assembleRelease assembleAndroidTest connectedAndroidTest
30 changes: 0 additions & 30 deletions scripts/.tests.env

This file was deleted.

95 changes: 0 additions & 95 deletions scripts/android-setup.sh

This file was deleted.

11 changes: 7 additions & 4 deletions test/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

testBuildType 'release'

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down Expand Up @@ -192,10 +195,10 @@ dependencies {
implementation jscFlavor
}

androidTestImplementation 'androidx.test:core:1.1.0';
androidTestImplementation 'androidx.test.ext:junit:1.1.0';
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0';
androidTestImplementation 'androidx.test:core:1.3.0';
androidTestImplementation 'androidx.test.ext:junit:1.1.2';
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0';
}

// Run this once to be able to run the application with BUCK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import android.view.View;

import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.ViewAction;
import androidx.test.espresso.UiController;
import androidx.test.espresso.PerformException;
import androidx.test.espresso.util.TreeIterables;
import androidx.test.espresso.util.HumanReadables;
import androidx.test.filters.LargeTest;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import java.util.concurrent.TimeoutException;
Expand All @@ -29,10 +29,8 @@
@LargeTest
public class SimpleTest {

@Before
public void launchActivity() {
ActivityScenario.launch(MainActivity.class);
}
@Rule public ActivityScenarioRule<MainActivity> activityScenarioRule
= new ActivityScenarioRule<>(MainActivity.class);

@Test
public void testIfAppLoads() {
Expand Down

0 comments on commit 3c654af

Please sign in to comment.