From 53cb650cf87ac3c301eb5b39453439f72f899304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 11:56:24 +0200 Subject: [PATCH 1/7] Add new compareScreenshot function that receives a SemanticsNodeInteraction --- .../androidsnaptesting/screenshots/ScreenshotsRule.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt index f7ddc39..d62a8a9 100644 --- a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt +++ b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt @@ -11,6 +11,7 @@ import android.widget.HorizontalScrollView import android.widget.ScrollView import androidx.annotation.RequiresApi import androidx.compose.ui.graphics.asAndroidBitmap +import androidx.compose.ui.test.SemanticsNodeInteraction import androidx.compose.ui.test.captureToImage import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.onRoot @@ -65,6 +66,16 @@ public class ScreenshotsRule( compareScreenshot(bitmap, name) } + @RequiresApi(Build.VERSION_CODES.O) + public fun compareScreenshot( + node: SemanticsNodeInteraction, + name: String? = null + ) { + disableFlakyComponentsAndWaitForIdle() + val bitmap = node.captureToImage().asAndroidBitmap() + compareScreenshot(bitmap, name) + } + public fun compareScreenshot( activity: Activity, name: String? = null, From f7707140bfa7302ebd3d0bc610d83863ba254364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 11:56:58 +0200 Subject: [PATCH 2/7] Add disableFlakyComponentsAndWaitForIdle to all the comparators --- .../androidsnaptesting/screenshots/ScreenshotsRule.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt index d62a8a9..50f25c3 100644 --- a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt +++ b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt @@ -61,6 +61,7 @@ public class ScreenshotsRule( rule: ComposeTestRule, name: String? = null, ) { + disableFlakyComponentsAndWaitForIdle() rule.waitForIdle() val bitmap = rule.onRoot().captureToImage().asAndroidBitmap() compareScreenshot(bitmap, name) @@ -93,6 +94,7 @@ public class ScreenshotsRule( bitmap: Bitmap, name: String? = null, ) { + disableFlakyComponentsAndWaitForIdle() val resourceName = "${className}_${name ?: testName}.png" val fileName = "$resourceName.${System.nanoTime()}" saveScreenshot(fileName, bitmap) From 01a9a9abe3b3267bb8e037352b49719481084123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 12:04:42 +0200 Subject: [PATCH 3/7] Add snapshot workflow --- .github/workflows/release.yml | 4 ++-- .github/workflows/snapshot.yml | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/snapshot.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 826ffed..a75da12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ jobs: library: runs-on: [ self-hosted-org, linux ] container: - image: docker://docker.tuenti.io/android/novum_android:12 + image: docker://docker.tuenti.io/android/novum_android:13 steps: - name: Checkout repo uses: actions/checkout@v4 @@ -25,7 +25,7 @@ jobs: plugin: runs-on: [ self-hosted-org, linux ] container: - image: docker://docker.tuenti.io/android/novum_android:12 + image: docker://docker.tuenti.io/android/novum_android:13 steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..9829034 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,44 @@ +name: "Create snapshot" +on: + workflow_dispatch: + inputs: + snapshot-version: + description: "Snapshot version" + required: true +jobs: + library: + runs-on: [ self-hosted-org, linux ] + container: + image: docker://docker.tuenti.io/android/novum_android:13 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Publish library snapshot + env: + MOBILE_MAVENCENTRAL_USER: ${{ secrets.MOBILE_MAVENCENTRAL_USER }} + MOBILE_MAVENCENTRAL_PASSWORD: ${{ secrets.MOBILE_MAVENCENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }} + NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }} + NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }} + run: | + ./gradlew publishReleasePublicationToSnapshotsRepository -DLIBRARY_VERSION=${{ github.event.inputs.snapshot-version }}-SNAPSHOT + plugin: + runs-on: [ self-hosted-org, linux ] + container: + image: docker://docker.tuenti.io/android/novum_android:13 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Publish plugin snapshot + env: + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + NEXUS_USER: ${{ secrets.NEXUS_RELEASE_USER }} + NEXUS_PASS: ${{ secrets.NEXUS_RELEASE_PASSWORD }} + run: | + cd include-build + ../gradlew publishGradlePluginPublicationToMavenRepository -DLIBRARY_VERSION=${{ github.event.inputs.snapshot-version }}-SNAPSHOT From bbdc8eddb35d5de89223914be46dd0597c11f93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 12:06:47 +0200 Subject: [PATCH 4/7] Run tests on internal runners --- .github/workflows/preintegration.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preintegration.yml b/.github/workflows/preintegration.yml index 86c7d65..be0231f 100644 --- a/.github/workflows/preintegration.yml +++ b/.github/workflows/preintegration.yml @@ -2,9 +2,14 @@ name: "Preintegration Checks" on: pull_request: workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: tests: - runs-on: ubuntu-latest + runs-on: [ self-hosted-org, linux ] steps: - name: Checkout repo uses: actions/checkout@v4 @@ -13,4 +18,4 @@ jobs: run: './gradlew clean check assemble' - name: "Check Gradle Plugin Project" - run: './gradlew -p include-build clean check jar' \ No newline at end of file + run: './gradlew -p include-build clean check jar' From 7a44748e89bba8b9b865e767eba9349334b7b164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 12:09:20 +0200 Subject: [PATCH 5/7] Run on docker --- .github/workflows/preintegration.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/preintegration.yml b/.github/workflows/preintegration.yml index be0231f..fb53894 100644 --- a/.github/workflows/preintegration.yml +++ b/.github/workflows/preintegration.yml @@ -10,6 +10,15 @@ concurrency: jobs: tests: runs-on: [ self-hosted-org, linux ] + container: + image: docker://docker.tuenti.io/android/novum_android:13 + env: + TMPDIR: /mnt/ramdisk/tmp + ANDROID_AVD_HOME: /mnt/ramdisk/avd + GRADLE_USER_HOME: /mnt/ramdisk/gradle/${{ github.event.repository.name }} + options: --device=/dev/kvm + volumes: + - /dev/shm:/mnt/ramdisk steps: - name: Checkout repo uses: actions/checkout@v4 From 601dbe5c46643d39a8c59f6ba231fb78946b76ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Latorre?= Date: Fri, 24 Oct 2025 12:12:08 +0200 Subject: [PATCH 6/7] Remove options --- .github/workflows/preintegration.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/preintegration.yml b/.github/workflows/preintegration.yml index fb53894..d46e0b8 100644 --- a/.github/workflows/preintegration.yml +++ b/.github/workflows/preintegration.yml @@ -12,13 +12,6 @@ jobs: runs-on: [ self-hosted-org, linux ] container: image: docker://docker.tuenti.io/android/novum_android:13 - env: - TMPDIR: /mnt/ramdisk/tmp - ANDROID_AVD_HOME: /mnt/ramdisk/avd - GRADLE_USER_HOME: /mnt/ramdisk/gradle/${{ github.event.repository.name }} - options: --device=/dev/kvm - volumes: - - /dev/shm:/mnt/ramdisk steps: - name: Checkout repo uses: actions/checkout@v4 From 5394475e1256611bfa78f24a8702ef572a7d935e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Latorre=20Asensio?= Date: Fri, 24 Oct 2025 12:24:20 +0200 Subject: [PATCH 7/7] Fix comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt index 50f25c3..6a1168d 100644 --- a/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt +++ b/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt @@ -94,7 +94,6 @@ public class ScreenshotsRule( bitmap: Bitmap, name: String? = null, ) { - disableFlakyComponentsAndWaitForIdle() val resourceName = "${className}_${name ?: testName}.png" val fileName = "$resourceName.${System.nanoTime()}" saveScreenshot(fileName, bitmap)