diff --git a/.github/workflows/sanity_test.yml b/.github/workflows/sanity_test.yml index 93e4686fe74..319c4bb431f 100644 --- a/.github/workflows/sanity_test.yml +++ b/.github/workflows/sanity_test.yml @@ -1,9 +1,9 @@ name: Sanity Test on: - schedule: - # At 20:00 every day UTC - - cron: '0 20 * * *' + push: + branches: [ michaelk/gha_experiment ] + # Enrich gradle.properties for CI/CD env: @@ -21,8 +21,6 @@ jobs: api-level: [ 28 ] steps: - uses: actions/checkout@v2 - with: - ref: develop - name: Set up Python 3.8 uses: actions/setup-python@v2 with: @@ -40,7 +38,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-buildcache restore-keys: | ${{ runner.os }}-gradle- - name: Start synapse server @@ -54,6 +52,8 @@ jobs: with: distribution: 'adopt' java-version: '11' + - name: Build Test suite on API ${{ matrix.api-level }} + run: ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false packageGplayDebugAndroidTest - name: Run sanity tests on API ${{ matrix.api-level }} uses: reactivecircus/android-emulator-runner@v2 with: @@ -61,6 +61,7 @@ jobs: arch: x86 profile: Nexus 5X force-avd-creation: false + sdcard-path-or-size: 512M emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none emulator-build: 7425822 # workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160 script: | @@ -69,11 +70,25 @@ jobs: touch emulator.log chmod 777 emulator.log adb logcat >> emulator.log & - ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest || adb pull storage/emulated/0/Pictures/failure_screenshots + ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest || (adb pull /storage/emulated/0/Pictures/failure_screenshots && exit 1) - name: Upload Test Report Log uses: actions/upload-artifact@v2 + if: always() with: name: sanity-error-results path: | emulator.log failure_screenshots/ + + notify: + runs-on: ubuntu-latest + needs: integration-tests + if: always() + steps: + - uses: michaelkaye/matrix-hookshot-action@v0.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + matrix_access_token: ${{ secrets.ELEMENT_ANDROID_NOTIFICATION_ACCESS_TOKEN }} + matrix_room_id: ${{ secrets.ELEMENT_ANDROID_INTERNAL_ROOM_ID }} + text_template: "Sanity test run: {{#each job_statuses }}{{#with this }}{{#if completed }} {{name}} {{conclusion}} at {{completed_at}} {{html_url}}{{/if}}{{/with}}{{/each}}" + html_template: "CI Sanity test run results: {{#each job_statuses }}{{#with this }}{{#if completed }} {{name}} {{conclusion}} at {{completed_at}} [details]{{/if}}{{/with}}{{/each}}" diff --git a/vector/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt b/vector/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt index 2e329ebb6bc..2939dcf4e03 100644 --- a/vector/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt +++ b/vector/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt @@ -40,7 +40,7 @@ private val deviceLanguage = Locale.getDefault().language class ScreenshotFailureRule : TestWatcher() { override fun failed(e: Throwable?, description: Description) { - val screenShotName = "$deviceLanguage-${description.methodName}-${SimpleDateFormat("EEE-MMMM-dd-HH:mm:ss").format(Date())}" + val screenShotName = "$deviceLanguage-${description.methodName}-${SimpleDateFormat("EEE-MMMM-dd-HHmmss").format(Date())}" val bitmap = getInstrumentation().uiAutomation.takeScreenshot() storeFailureScreenshot(bitmap, screenShotName) } diff --git a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index bab397678e5..417d28d6252 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -16,10 +16,12 @@ package im.vector.app.ui +import android.Manifest import androidx.test.espresso.IdlingPolicies import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest +import androidx.test.rule.GrantPermissionRule import im.vector.app.R import im.vector.app.espresso.tools.ScreenshotFailureRule import im.vector.app.features.MainActivity @@ -43,6 +45,7 @@ class UiAllScreensSanityTest { @get:Rule val testRule = RuleChain .outerRule(ActivityScenarioRule(MainActivity::class.java)) + .around(GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .around(ScreenshotFailureRule()) private val elementRobot = ElementRobot()