From 9a436211b586e686a52440a60a6b921ce72c56b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Mon, 27 May 2024 14:28:48 +0000 Subject: [PATCH] CI experiment Change-Id: I7e7657ab34832d5988ebbe6af0d5464e9b4364ff --- .github/workflows/Build.yaml | 8 +++++--- .../google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index a0be24aa3..f337522f0 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -310,7 +310,7 @@ jobs: - name: Build projects and run instrumented screenshot tests id: dropshotsverify - continue-on-error: true + continue-on-error: false uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} @@ -323,11 +323,12 @@ jobs: emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none # Run tests, if they fail, record screenshots and exit with a failure script: > + set +o pipefail && ./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests --daemon || echo "Recording new screenshots" ; ./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests -Pdropshots.record --daemon --stacktrace ; echo "Done recording new screenshots, exiting with failure" - ; exit 5 + ; echo ::set-output name=newgoldens::true - name: Prevent pushing new screenshots if this is a fork id: checkfork_screenshots_instrumented @@ -338,12 +339,13 @@ jobs: - name: Checkout new changes (in case another job already uploaded screenshots) uses: actions/checkout@v4 + if: steps.dropshotsverify.outputs.newgoldens == 'true' with: clean: false - name: Push new device screenshots if available uses: stefanzweifel/git-auto-commit-action@4b8a201e31cadd9829df349894b28c54e6c19fe6 - if: steps.dropshotsverify.outcome == 'failure' + if: steps.dropshotsverify.outputs.newgoldens == 'true' with: file_pattern: 'app/src/androidTest/screenshots/*.png' disable_globbing: true diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt index b17a16bac..d6a4c87be 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt +++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/EdgeToEdgeTest.kt @@ -17,6 +17,7 @@ package com.google.samples.apps.nowinandroid.ui import android.graphics.Bitmap +import android.util.Log import androidx.test.core.app.takeScreenshot import androidx.test.espresso.device.DeviceInteraction.Companion.setClosedMode import androidx.test.espresso.device.DeviceInteraction.Companion.setFlatMode @@ -251,6 +252,7 @@ class EdgeToEdgeTest { } catch (e: AssertionError) { if (count == 0) throw e count -= 1 + Log.i("EdgeToEdgeTest", "Test failed, retrying (count=$count)") waitForWindowUpdate() } }