Skip to content

Commit 43c0ffc

Browse files
committed
Add updatePaparazziFailures Gradle task to automatically updates snapshot failures
1 parent 586a579 commit 43c0ffc

47 files changed

Lines changed: 68 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/kotlinc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
import org.gradle.api.DefaultTask
14+
15+
private val failuresDir = project.layout.buildDirectory.dir("paparazzi/failures").get().asFile
16+
17+
tasks.register<DefaultTask>("updatePaparazziFailures") {
18+
group = "verification"
19+
// Clean failures directory first to avoid copying old failures
20+
dependsOn(tasks["cleanPaparazziFailures"])
21+
// Using finalizedBy in cunjunction with mustRunAfter allows to run verifyPaparazzi and copyPaparazziFailures
22+
// in that order even if verifyPaparazzi fails
23+
tasks["cleanPaparazziFailures"].finalizedBy("verifyPaparazzi", "copyPaparazziFailures")
24+
tasks["copyPaparazziFailures"].mustRunAfter(tasks["verifyPaparazzi"])
25+
}
26+
27+
tasks.register<DefaultTask>("cleanPaparazziFailures") {
28+
doLast {
29+
if (failuresDir.exists()) {
30+
failuresDir.deleteRecursively()
31+
logger.lifecycle("Cleaned failures in ${project.name}.")
32+
}
33+
}
34+
}
35+
36+
tasks.register<DefaultTask>("copyPaparazziFailures") {
37+
doLast {
38+
val snapshotsDir = File("${project.projectDir}/src/test/snapshots/images")
39+
40+
// Get all PNG files except delta comparison images
41+
val failureFiles = failuresDir.walkTopDown()
42+
.filter { it.isFile && it.extension == "png" && !it.name.startsWith("delta-") }
43+
.toList()
44+
45+
// Ensure snapshots directory exists
46+
snapshotsDir.mkdirs()
47+
48+
// Copy failure files to snapshots directory
49+
failureFiles.forEach { failureFile ->
50+
val snapshotFile = snapshotsDir.resolve(failureFile.name)
51+
failureFile.copyTo(snapshotFile, overwrite = true)
52+
}
53+
54+
if (failureFiles.isEmpty()) {
55+
logger.lifecycle("No snapshots updated in ${project.name}.")
56+
} else {
57+
val snapshotPlural = if (failureFiles.count() > 1) "s" else ""
58+
logger.lifecycle("Updated ${failureFiles.count()} snapshot$snapshotPlural in ${project.name}.")
59+
}
60+
}
61+
}

core/src/main/java/com/orange/ouds/core/component/samples/OudsAlertMessageSamples.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import androidx.compose.material.icons.Icons
1616
import androidx.compose.material.icons.filled.FavoriteBorder
1717
import androidx.compose.runtime.Composable
1818
import androidx.compose.ui.tooling.preview.PreviewLightDark
19-
import com.orange.ouds.core.component.OudsAlertMessage
2019
import com.orange.ouds.core.component.OudsAlertIcon
20+
import com.orange.ouds.core.component.OudsAlertMessage
2121
import com.orange.ouds.core.component.OudsAlertMessageActionLink
2222
import com.orange.ouds.core.component.OudsAlertMessageActionLinkPosition
2323
import com.orange.ouds.core.component.OudsAlertMessageStatus

theme-orange-compact/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
plugins {
1414
id("dokka")
1515
id("library")
16+
id("paparazzi")
1617
alias(libs.plugins.compose.compiler)
1718
alias(libs.plugins.paparazzi)
1819
id(libs.plugins.kotlin.parcelize.get().pluginId) // https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638
9.88 KB
13.1 KB
14 KB
14.4 KB
18.3 KB
16.4 KB

0 commit comments

Comments
 (0)