From 005f25009681d0b720213c2074c057f846008568 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Thu, 19 May 2022 14:45:23 +0530 Subject: [PATCH 1/2] rebase and all changes done for optimization performance and fix test failure --- ...overage.yml => coverage_api21_request.yml} | 8 ++-- .github/workflows/coverage_api30_request.yml | 44 +++++++++++++++++++ .../java/org/kiwix/kiwixmobile/BaseRobot.kt | 18 ++++++-- .../org/kiwix/kiwixmobile/intro/IntroRobot.kt | 5 +-- .../main/TopLevelDestinationRobot.kt | 7 +-- 5 files changed, 66 insertions(+), 16 deletions(-) rename .github/workflows/{coverage.yml => coverage_api21_request.yml} (80%) create mode 100644 .github/workflows/coverage_api30_request.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage_api21_request.yml similarity index 80% rename from .github/workflows/coverage.yml rename to .github/workflows/coverage_api21_request.yml index 15d2921a7..7244c6b5b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage_api21_request.yml @@ -14,17 +14,17 @@ jobs: coverageReport: strategy: - max-parallel: 2 matrix: - api-level: [21, 30, 21,30] + api-level: [21] fail-fast: false - runs-on: macOS-latest + runs-on: macos-10.15 steps: - name: checkout uses: actions/checkout@v3 with: fetch-depth: 1 - + env: + GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" - name: create instrumentation coverage uses: ReactiveCircus/android-emulator-runner@v2.23.0 with: diff --git a/.github/workflows/coverage_api30_request.yml b/.github/workflows/coverage_api30_request.yml new file mode 100644 index 000000000..da0e2b931 --- /dev/null +++ b/.github/workflows/coverage_api30_request.yml @@ -0,0 +1,44 @@ +name: Coverage Reporting + +on: + push: + branches: + - master + - develop + + pull_request: + branches: + - '**' + +jobs: + + coverageReport: + strategy: + matrix: + api-level: [30] + fail-fast: false + runs-on: macos-10.15 + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + env: + GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" + - name: create instrumentation coverage + uses: ReactiveCircus/android-emulator-runner@v2.23.0 + with: + api-level: ${{ matrix.api-level }} + arch: x86_64 + ndk: 21.4.7075529 + script: bash contrib/instrumentation.sh + + - name: Upload screenshot result + uses: actions/upload-artifact@v1 + if: failure() + with: + name: ${{ matrix.api-level }} + path: screencap.png + + - name: create unit coverage + run: ./gradlew jacocoTestDebugUnitTestReport jacocoTestCustomExampleDebugUnitTestReport diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt index 81c8a5f25..9e387921f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt @@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile import android.R.id import android.app.Instrumentation import android.content.Context +import androidx.test.espresso.NoMatchingViewException import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.Direction import androidx.test.uiautomator.UiDevice @@ -81,9 +82,20 @@ abstract class BaseRobot( private fun waitFor( findable: Findable, - timeout: Long = VERY_LONG_WAIT - ): UiObject2? = - uiDevice.wait(Until.findObject(findable.selector(this)), timeout) + timeout: Long = VERY_LONG_WAIT, + retryCount: Int = 5 + ): UiObject2? { + var uiObject2: UiObject2? = null + for (i in 0 until retryCount) { + try { + uiObject2 = uiDevice.wait(Until.findObject(findable.selector(this)), timeout) + break + } catch (noMatchingViewException: NoMatchingViewException) { + noMatchingViewException.printStackTrace() + } + } + return uiObject2 + } private fun UiObject2.customSwipe( direction: Direction, diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt index 09a387338..1af04c0c2 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt @@ -34,13 +34,10 @@ class IntroRobot : BaseRobot() { private val getStarted = ViewId(R.id.get_started) private val viewPager = ViewId(R.id.view_pager) - init { + fun swipeLeft() { isVisible(getStarted) isVisible(TextId(R.string.welcome_to_the_family)) isVisible(TextId(R.string.humankind_knowledge)) - } - - fun swipeLeft() { attempt(10) { isVisible(viewPager).swipeLeft() isVisible(TextId(R.string.save_books_offline)) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt index 6a00fb3bd..e75074883 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationRobot.kt @@ -17,8 +17,8 @@ */ package org.kiwix.kiwixmobile.main -import com.adevinta.android.barista.interaction.BaristaSleepInteractions import applyWithViewHierarchyPrinting +import com.adevinta.android.barista.interaction.BaristaSleepInteractions import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable.StringId.TextId import org.kiwix.kiwixmobile.Findable.ViewId @@ -47,11 +47,8 @@ fun topLevel(func: TopLevelDestinationRobot.() -> Unit) = class TopLevelDestinationRobot : BaseRobot() { - init { - isVisible(ViewId(R.id.navigation_container)) - } - fun clickReaderOnBottomNav(func: ReaderRobot.() -> Unit) { + isVisible(ViewId(R.id.navigation_container)) BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong()) clickOn(ViewId(R.id.readerFragment)) reader(func) From ab7f922930a175614dcf828d6bc99ba4e990f3ef Mon Sep 17 00:00:00 2001 From: MohitMali Date: Thu, 19 May 2022 16:39:46 +0530 Subject: [PATCH 2/2] moving to single coverage file and remove code coverage to 30 --- ...overage_api21_request.yml => coverage.yml} | 12 +++-- .github/workflows/coverage_api30_request.yml | 44 ------------------- 2 files changed, 8 insertions(+), 48 deletions(-) rename .github/workflows/{coverage_api21_request.yml => coverage.yml} (90%) delete mode 100644 .github/workflows/coverage_api30_request.yml diff --git a/.github/workflows/coverage_api21_request.yml b/.github/workflows/coverage.yml similarity index 90% rename from .github/workflows/coverage_api21_request.yml rename to .github/workflows/coverage.yml index 7244c6b5b..94155e7c3 100644 --- a/.github/workflows/coverage_api21_request.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,7 @@ jobs: coverageReport: strategy: matrix: - api-level: [21] + api-level: [21,30] fail-fast: false runs-on: macos-10.15 steps: @@ -23,16 +23,18 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 1 - env: - GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" + - name: create instrumentation coverage uses: ReactiveCircus/android-emulator-runner@v2.23.0 + env: + GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" with: api-level: ${{ matrix.api-level }} arch: x86_64 ndk: 21.4.7075529 script: bash contrib/instrumentation.sh + - name: Upload screenshot result uses: actions/upload-artifact@v1 if: failure() @@ -41,15 +43,17 @@ jobs: path: screencap.png - name: create unit coverage + if: ${{ matrix.api-level==21 }} run: ./gradlew jacocoTestDebugUnitTestReport jacocoTestCustomExampleDebugUnitTestReport - name: Upload coverage to Codecov + if: ${{ matrix.api-level==21 }} run: | bash <(curl -s https://codecov.io/bash) - name: Upload Coverage to GH-Actions uses: actions/upload-artifact@v2.2.0 - if: ${{ always() }} + if: ${{ matrix.api-level==21 }} with: name: Tests Coverage Report path: | diff --git a/.github/workflows/coverage_api30_request.yml b/.github/workflows/coverage_api30_request.yml deleted file mode 100644 index da0e2b931..000000000 --- a/.github/workflows/coverage_api30_request.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Coverage Reporting - -on: - push: - branches: - - master - - develop - - pull_request: - branches: - - '**' - -jobs: - - coverageReport: - strategy: - matrix: - api-level: [30] - fail-fast: false - runs-on: macos-10.15 - steps: - - name: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - env: - GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000" - - name: create instrumentation coverage - uses: ReactiveCircus/android-emulator-runner@v2.23.0 - with: - api-level: ${{ matrix.api-level }} - arch: x86_64 - ndk: 21.4.7075529 - script: bash contrib/instrumentation.sh - - - name: Upload screenshot result - uses: actions/upload-artifact@v1 - if: failure() - with: - name: ${{ matrix.api-level }} - path: screencap.png - - - name: create unit coverage - run: ./gradlew jacocoTestDebugUnitTestReport jacocoTestCustomExampleDebugUnitTestReport