From d82aa9eddb1ed401e0ed7c9e8bc342f9bb7069f9 Mon Sep 17 00:00:00 2001 From: Daniel Frett Date: Thu, 7 Mar 2024 14:37:52 -0700 Subject: [PATCH] enable Paparazzi for the app module --- .gitattributes | 2 ++ .github/workflows/build.yml | 3 ++- .github/workflows/git-lfs-validation.yml | 15 ++++++++++++ README.md | 4 ++++ app/build.gradle.kts | 1 + .../main/kotlin/AndroidTestConfiguration.kt | 3 +++ .../src/main/kotlin/PaparazziConfiguration.kt | 24 +++++++++++++++++++ gradle/libs.versions.toml | 1 + 8 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/git-lfs-validation.yml create mode 100644 build-logic/src/main/kotlin/PaparazziConfiguration.kt diff --git a/.gitattributes b/.gitattributes index 6fee576c89..61d9cc4993 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,5 @@ *.properties text *.xml text *.yml text + +**/snapshots/**/*.png filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a93e4a559e..eae6fe6c55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,6 +86,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + lfs: 'true' - name: Cache Maven uses: actions/cache@v4 with: @@ -101,7 +102,7 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Run Unit Tests - run: ./gradlew test koverXmlReportDebug koverXmlReportProductionDebug --max-workers 1 --scan + run: ./gradlew test verifyPaparazzi koverXmlReportDebug koverXmlReportProductionDebug --max-workers 1 --scan - name: Codecov uses: codecov/codecov-action@v4 with: diff --git a/.github/workflows/git-lfs-validation.yml b/.github/workflows/git-lfs-validation.yml new file mode 100644 index 0000000000..dc2c8b498b --- /dev/null +++ b/.github/workflows/git-lfs-validation.yml @@ -0,0 +1,15 @@ +name: "Validate Git LFS" + +on: + push: + branches: [develop, master, feature/*] + pull_request: + branches: [develop, master, feature/*] + +jobs: + validate-lfs-pointers: + name: "Validate Git LFS pointers" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: git lfs fsck --pointers diff --git a/README.md b/README.md index 363948ad8b..c632411a32 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ GodTools Android [![codecov](https://codecov.io/gh/CruGlobal/godtools-android/branch/develop/graph/badge.svg)](https://codecov.io/gh/CruGlobal/godtools-android) +# Git LFS + +We use [Git LFS](https://git-lfs.com/) for storing Paparazzi snapshots. You will need to setup [Git LFS](https://git-lfs.com/) on your local machine in order to store new paparazzi snapshots or validate existing paparazzi snapshots. + # OneSky To enable OneSky translation downloads/uploads configure the following [gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties): diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ccb0ca21b0..e69a5dcacc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -7,6 +7,7 @@ plugins { alias(libs.plugins.grgit) alias(libs.plugins.hilt) alias(libs.plugins.ksp) + alias(libs.plugins.paparazzi) } android { diff --git a/build-logic/src/main/kotlin/AndroidTestConfiguration.kt b/build-logic/src/main/kotlin/AndroidTestConfiguration.kt index 12c6206a49..13c0680758 100644 --- a/build-logic/src/main/kotlin/AndroidTestConfiguration.kt +++ b/build-logic/src/main/kotlin/AndroidTestConfiguration.kt @@ -59,4 +59,7 @@ internal fun TestedExtension.configureTestOptions(project: Project) { } } } + + // Paparazzi + project.fixGuavaDependencyForPaparazzi() } diff --git a/build-logic/src/main/kotlin/PaparazziConfiguration.kt b/build-logic/src/main/kotlin/PaparazziConfiguration.kt new file mode 100644 index 0000000000..a5dcd1f420 --- /dev/null +++ b/build-logic/src/main/kotlin/PaparazziConfiguration.kt @@ -0,0 +1,24 @@ +import org.gradle.api.Project +import org.gradle.api.attributes.java.TargetJvmEnvironment + +internal fun Project.fixGuavaDependencyForPaparazzi() { + plugins.withId("app.cash.paparazzi") { + // Defer until afterEvaluate so that testImplementation is created by Android plugin. + afterEvaluate { + dependencies.constraints { + add("testImplementation", "com.google.guava:guava") { + attributes { + attribute( + TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, + objects.named(TargetJvmEnvironment::class.java, TargetJvmEnvironment.STANDARD_JVM) + ) + } + because( + "LayoutLib and sdk-common depend on Guava's -jre published variant. " + + "See https://github.com/cashapp/paparazzi/issues/906." + ) + } + } + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0ded019cd1..0f0dd9da32 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -240,3 +240,4 @@ grgit = { id = "org.ajoberstar.grgit", version = "5.2.2" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradle" } +paparazzi = { id = "app.cash.paparazzi", version = "1.3.3" }