Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cleanRecordPaparazzi... task to help tidy up orphaned snapshots #1316

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.gradle.api.internal.artifacts.transform.UnzipTransform
import org.gradle.api.logging.LogLevel.LIFECYCLE
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.reporting.ReportingExtension
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.options.Option
import org.gradle.api.tasks.testing.Test
Expand Down Expand Up @@ -77,6 +78,7 @@ public class PaparazziPlugin : Plugin<Project> {
private fun <T> setupPaparazzi(project: Project, variants: DomainObjectSet<T>) where T : BaseVariant, T : TestedVariant {
project.addTestDependency()
val nativePlatformFileCollection = project.setupNativePlatformDependency()
val snapshotOutputDir = project.layout.projectDirectory.dir("src/test/snapshots")
jrodbx marked this conversation as resolved.
Show resolved Hide resolved

// Create anchor tasks for all variants.
val verifyVariants = project.tasks.register("verifyPaparazzi") {
Expand All @@ -87,6 +89,17 @@ public class PaparazziPlugin : Plugin<Project> {
it.group = VERIFICATION_GROUP
it.description = "Record golden images for all variants"
}
val cleanRecordVariants = project.tasks.register("cleanRecordPaparazzi") {
it.group = VERIFICATION_GROUP
it.description = "Clean and record golden images for all variants"
}

// Create a task to delete all snapshots.
jrodbx marked this conversation as resolved.
Show resolved Hide resolved
val deleteSnapshots = project.tasks.register("deletePaparazziSnapshots", Delete::class.java) {
it.group = VERIFICATION_GROUP
it.description = "Delete all golden images"
it.delete(project.fileTree(snapshotOutputDir))
jrodbx marked this conversation as resolved.
Show resolved Hide resolved
}

variants.all { variant ->
val variantSlug = variant.name.capitalize(Locale.US)
Expand All @@ -96,7 +109,6 @@ public class PaparazziPlugin : Plugin<Project> {
val buildDirectory = project.layout.buildDirectory
val gradleUserHomeDir = project.gradle.gradleUserHomeDir
val reportOutputDir = project.extensions.getByType(ReportingExtension::class.java).baseDirectory.dir("paparazzi/${variant.name}")
val snapshotOutputDir = project.layout.projectDirectory.dir("src/test/snapshots")

val localResourceDirs = project
.files(variant.sourceSets.flatMap { it.resDirectories })
Expand Down Expand Up @@ -179,8 +191,15 @@ public class PaparazziPlugin : Plugin<Project> {
val recordTaskProvider = project.tasks.register("recordPaparazzi$variantSlug", PaparazziTask::class.java) {
it.group = VERIFICATION_GROUP
it.description = "Record golden images for variant '${variant.name}'"
it.mustRunAfter(deleteSnapshots)
jrodbx marked this conversation as resolved.
Show resolved Hide resolved
}
recordVariants.configure { it.dependsOn(recordTaskProvider) }
val cleanRecordTaskProvider = project.tasks.register("cleanRecordPaparazzi$variantSlug") {
it.group = VERIFICATION_GROUP
it.description = "Clean and record golden images for variant '${variant.name}'"
it.dependsOn(deleteSnapshots, recordTaskProvider)
}
cleanRecordVariants.configure { it.dependsOn(cleanRecordTaskProvider) }
val verifyTaskProvider = project.tasks.register("verifyPaparazzi$variantSlug", PaparazziTask::class.java) {
it.group = VERIFICATION_GROUP
it.description = "Run screenshot tests for variant '${variant.name}'"
Expand Down