diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 6ea146ff52..1c59cb31e5 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -28,6 +28,16 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@v3 + - name: Run Paparazzi Verification + run: ./gradlew verifyPaparazziDebug + + - name: Upload Failure Diffs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: paparazzi-failures + path: "**/build/paparazzi/failures/" + - name: Build debug APK env: SENTRY_DSN: ${{ secrets.SENTRY_DSN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 93f8418f4b..b3fe4e4d08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,3 +11,18 @@ + Please, **do not modify readme and other information files** (except for typos)(and if you are better at explaining it then thats also accepted) + **Avoid adding new dependencies** unless required. APK size is important. + **please explain your changes** atleast try to cause it just helps us work a lot faster than spending time figuring out what you did🥲. + +### Snapshot Tests + +* Baseline: `app/src/test/snapshots/images` +* Reports: `app/build/reports/paparazzi/debug/index.html` + +To verify: +```shell +gradlew verifyPaparazziDebug +``` + +To update: +```shell +gradlew recordPaparazziDebug +``` diff --git a/app/build.gradle b/app/build.gradle index a5a83ad4f2..6f47c0a077 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,7 @@ plugins { // id 'dev.reformator.stacktracedecoroutinator' id 'io.sentry.android.gradle' version '6.1.0' alias(libs.plugins.compose.compiler) + alias(libs.plugins.paparazzi) } android { @@ -241,6 +242,7 @@ dependencies { debugImplementation libs.workinspector debugImplementation libs.compose.ui.tooling debugImplementation libs.compose.ui.test.manifest + testImplementation libs.compose.ui.tooling testImplementation libs.junit testImplementation libs.json diff --git a/app/src/test/kotlin/io/github/landwarderer/futon/ui/PaparazziRules.kt b/app/src/test/kotlin/io/github/landwarderer/futon/ui/PaparazziRules.kt new file mode 100644 index 0000000000..87ffd4d13a --- /dev/null +++ b/app/src/test/kotlin/io/github/landwarderer/futon/ui/PaparazziRules.kt @@ -0,0 +1,13 @@ +package io.github.landwarderer.futon.ui + +import app.cash.paparazzi.DeviceConfig +import app.cash.paparazzi.Paparazzi +import org.junit.Rule + +abstract class PaparazziRules { + @get:Rule + val paparazzi = Paparazzi( + deviceConfig = DeviceConfig.PIXEL_5, + theme = "Theme.Futon", + ) +} diff --git a/app/src/test/kotlin/io/github/landwarderer/futon/ui/view/SourcesSnapshotTest.kt b/app/src/test/kotlin/io/github/landwarderer/futon/ui/view/SourcesSnapshotTest.kt new file mode 100644 index 0000000000..a6bd5b3f96 --- /dev/null +++ b/app/src/test/kotlin/io/github/landwarderer/futon/ui/view/SourcesSnapshotTest.kt @@ -0,0 +1,14 @@ +package io.github.landwarderer.futon.ui.view + +import android.widget.LinearLayout +import io.github.landwarderer.futon.R +import io.github.landwarderer.futon.ui.PaparazziRules +import org.junit.Test + +class SourcesSnapshotTest: PaparazziRules() { + @Test + fun dialogDownload() { + val view = paparazzi.inflate(R.layout.dialog_download) + paparazzi.snapshot(view) + } +} diff --git a/app/src/test/snapshots/images/io.github.landwarderer.futon.ui.view_SourcesSnapshotTest_dialogDownload.png b/app/src/test/snapshots/images/io.github.landwarderer.futon.ui.view_SourcesSnapshotTest_dialogDownload.png new file mode 100644 index 0000000000..b28a567b9d Binary files /dev/null and b/app/src/test/snapshots/images/io.github.landwarderer.futon.ui.view_SourcesSnapshotTest_dialogDownload.png differ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bd913844fa..4167351c92 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -54,6 +54,7 @@ webkit = "1.14.0" workRuntime = "2.10.5" workinspector = "1.2" window = "1.3.0" +paparazzi = "2.0.0-alpha05" composeBom = "2026.03.00" activityCompose = "1.13.0" lifecycleViewmodelCompose = "2.10.0" @@ -146,6 +147,7 @@ compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" } [plugins] +paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } android-application = { id = "com.android.application", version.ref = "gradle" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }