From 9b8295eb56cb632cdaaa07bc3185de57dff4d225 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Fri, 8 May 2020 10:27:32 +0200 Subject: [PATCH 1/5] Build pull request on CI --- .github/workflows/android-emulator.yml | 28 +++++++++++++++++++ .../workflows/gradle-wrapper-validation.yml | 10 +++++++ anychart/build.gradle | 3 +- sample/build.gradle | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/android-emulator.yml create mode 100644 .github/workflows/gradle-wrapper-validation.yml diff --git a/.github/workflows/android-emulator.yml b/.github/workflows/android-emulator.yml new file mode 100644 index 00000000..32e02d83 --- /dev/null +++ b/.github/workflows/android-emulator.yml @@ -0,0 +1,28 @@ +name: Android Emulator test + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build + - name: Android Emulator test + uses: ReactiveCircus/android-emulator-runner@v2.8.0 + with: + api-level: 28 + disable-animations: true + script: ./gradlew cAT + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: Espresso-test-report + path: sample/build/reports/androidTests/connected/ diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 00000000..f552c8dc --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,10 @@ +name: "Validate Gradle Wrapper" +on: [push] + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 diff --git a/anychart/build.gradle b/anychart/build.gradle index a571c2e8..76547b57 100644 --- a/anychart/build.gradle +++ b/anychart/build.gradle @@ -10,7 +10,7 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - + multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } @@ -28,6 +28,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:multidex:1.0.3' testImplementation 'junit:junit:4.12' } diff --git a/sample/build.gradle b/sample/build.gradle index 366d9158..da5d188f 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -33,6 +33,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(":anychart") + implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:recyclerview-v7:28.0.0' From 55e48fc0c1a69d557a627d9d660d7f5068e6f82c Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 10 May 2020 07:17:23 +0200 Subject: [PATCH 2/5] remove pointless tests --- .../anychart/ExampleInstrumentedTest.java | 26 ------------------- .../anychart/anychart/ExampleUnitTest.java | 17 ------------ .../com/anychart/sample/ExampleUnitTest.java | 17 ------------ 3 files changed, 60 deletions(-) delete mode 100644 anychart/src/androidTest/java/com/anychart/anychart/ExampleInstrumentedTest.java delete mode 100644 anychart/src/test/java/com/anychart/anychart/ExampleUnitTest.java delete mode 100644 sample/src/test/java/com/anychart/sample/ExampleUnitTest.java diff --git a/anychart/src/androidTest/java/com/anychart/anychart/ExampleInstrumentedTest.java b/anychart/src/androidTest/java/com/anychart/anychart/ExampleInstrumentedTest.java deleted file mode 100644 index b02093ff..00000000 --- a/anychart/src/androidTest/java/com/anychart/anychart/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.anychart.anychart; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumentation test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.anychart.anychart.test", appContext.getPackageName()); - } -} diff --git a/anychart/src/test/java/com/anychart/anychart/ExampleUnitTest.java b/anychart/src/test/java/com/anychart/anychart/ExampleUnitTest.java deleted file mode 100644 index 18ab070e..00000000 --- a/anychart/src/test/java/com/anychart/anychart/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.anychart.anychart; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/sample/src/test/java/com/anychart/sample/ExampleUnitTest.java b/sample/src/test/java/com/anychart/sample/ExampleUnitTest.java deleted file mode 100644 index 9c974d6c..00000000 --- a/sample/src/test/java/com/anychart/sample/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.anychart.sample; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file From 70b137f45dd2d2911a2152b95e87e22ed0c04523 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 10 May 2020 08:12:42 +0200 Subject: [PATCH 3/5] unify onAfter() --- .../com/anychart/sample/MainActivityTest.java | 89 ++----------------- 1 file changed, 7 insertions(+), 82 deletions(-) diff --git a/sample/src/androidTest/java/com/anychart/sample/MainActivityTest.java b/sample/src/androidTest/java/com/anychart/sample/MainActivityTest.java index 4edde849..922eff2f 100644 --- a/sample/src/androidTest/java/com/anychart/sample/MainActivityTest.java +++ b/sample/src/androidTest/java/com/anychart/sample/MainActivityTest.java @@ -7,6 +7,7 @@ import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; +import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -29,6 +30,12 @@ public class MainActivityTest { public ActivityTestRule activityRule = new ActivityTestRule<>( MainActivity.class, false, true); + + @After + public void onEndTest() { + pressBack(); + } + @Test public void pieChartTest() { onView(withId(R.id.recycler_view)) @@ -41,8 +48,6 @@ public void pieChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1s")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1t")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -61,8 +66,6 @@ public void columnChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_16")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_17")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -75,8 +78,6 @@ public void lineChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_20")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1m")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -88,8 +89,6 @@ public void areaChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_23")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_24")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -120,8 +119,6 @@ public void barChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_3q")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_3r")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -137,8 +134,6 @@ public void vennDiagramTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_a")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_x")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -173,8 +168,6 @@ public void heatMapChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_rect_1i")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_rect_1j")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -187,8 +180,6 @@ public void tagCloudTest() { onWebView().withElement(findElement(Locator.ID, "ac_simple-text_s")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_simple-text_2a")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -212,8 +203,6 @@ public void waterfallChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1s")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1t")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -237,8 +226,6 @@ public void treeMapChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_rect_12")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_rect_13")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -253,8 +240,6 @@ public void circularGaugeTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_e")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_f")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -264,8 +249,6 @@ public void thermometerTest() { onWebView().withElement(findElement(Locator.ID, "container")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -275,8 +258,6 @@ public void linearColorScaleTest() { onWebView().withElement(findElement(Locator.ID, "container")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -287,8 +268,6 @@ public void windSpeedTest() { onWebView().withElement(findElement(Locator.ID, "container")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1l")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -299,8 +278,6 @@ public void windDirectionTest() { onWebView().withElement(findElement(Locator.ID, "container")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_y")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -312,8 +289,6 @@ public void scatterChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_13")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_6a")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -326,8 +301,6 @@ public void resourceChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_7")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_9")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -340,8 +313,6 @@ public void radarChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2k")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_22")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -354,8 +325,6 @@ public void polarChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2a")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_2d")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -376,8 +345,6 @@ public void rangeChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_31")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_30")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -404,8 +371,6 @@ public void verticalChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1l")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1m")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -420,8 +385,6 @@ public void funnelChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_k")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_l")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -447,8 +410,6 @@ public void pertChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1h")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1a")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -460,8 +421,6 @@ public void combinedChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1u")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1x")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -478,8 +437,6 @@ public void bubbleChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_circle_2r")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_circle_3u")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -491,8 +448,6 @@ public void paretoChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2k")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_2l")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -506,8 +461,6 @@ public void pyramidChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_r")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_i")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -526,8 +479,6 @@ public void boxChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1p")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1t")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -540,8 +491,6 @@ public void mosaicChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1o")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1p")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -557,8 +506,6 @@ public void mekkoChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_1b")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_1a")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -580,8 +527,6 @@ public void bar3DChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_3n")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_4b")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -602,8 +547,6 @@ public void column3DChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2w")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_6r")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -615,8 +558,6 @@ public void area3DChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2j")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_23")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -628,8 +569,6 @@ public void hiloChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_2b")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_3b")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -639,8 +578,6 @@ public void ohlcChartTest() { onWebView().withElement(findElement(Locator.ID, "container")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -659,8 +596,6 @@ public void quadrantChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_d")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_f")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -677,8 +612,6 @@ public void sunburstChartTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_5")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_5")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -700,8 +633,6 @@ public void bubbleMapTest() { onWebView().withElement(findElement(Locator.ID, "ac_circle_11")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_circle_x")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -717,8 +648,6 @@ public void choroplethMapTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_10")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_s")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -735,8 +664,6 @@ public void pointMapTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_25")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_26")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } @Test @@ -751,8 +678,6 @@ public void connectorMapTest() { onWebView().withElement(findElement(Locator.ID, "ac_path_7l")).perform(webClick()); onWebView().withElement(findElement(Locator.ID, "ac_path_7m")).perform(webClick()); onView(withId(R.id.web_view)).check(matches(isEnabled())); - - pressBack(); } } From 7c62b72dd8a6eaf52cb6f6b3c3445b5246c4f57a Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 10 May 2020 07:41:52 +0200 Subject: [PATCH 4/5] specify profile --- .github/workflows/android-emulator.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/android-emulator.yml b/.github/workflows/android-emulator.yml index 32e02d83..84d76b46 100644 --- a/.github/workflows/android-emulator.yml +++ b/.github/workflows/android-emulator.yml @@ -20,6 +20,8 @@ jobs: with: api-level: 28 disable-animations: true + arch: x86_64 + profile: Nexus 6 script: ./gradlew cAT - uses: actions/upload-artifact@v1 if: failure() From 4f0382cf825915d5eff38ff0b5b6908f715d6eb6 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 10 May 2020 07:35:42 +0200 Subject: [PATCH 5/5] Run CI in parallel Harmonize parallel jobs --- .github/workflows/android-emulator.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android-emulator.yml b/.github/workflows/android-emulator.yml index 84d76b46..7b67c50d 100644 --- a/.github/workflows/android-emulator.yml +++ b/.github/workflows/android-emulator.yml @@ -1,12 +1,12 @@ -name: Android Emulator test +name: Android CI on: pull_request: types: [opened, synchronize, reopened] jobs: - build: - runs-on: macOS-latest + Build: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: set up JDK 1.8 @@ -15,6 +15,14 @@ jobs: java-version: 1.8 - name: Build with Gradle run: ./gradlew build + Espresso: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 - name: Android Emulator test uses: ReactiveCircus/android-emulator-runner@v2.8.0 with: