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

Fix non-existent snapshot directory when running verifyPaparazziDebug #1695

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

geoff-powell
Copy link
Collaborator

No description provided.

@@ -237,7 +237,7 @@ public class PaparazziPlugin @Inject constructor(
test.inputs.dir(
isVerifyRun.flatMap {
project.objects.directoryProperty().apply {
set(if (it) snapshotOutputDir else null)
set(if (it && snapshotOutputDir.asFile.exists()) snapshotOutputDir else null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a file collection instead you won't have this issue. This works but creating that directory will cause a configuration cache miss when the directory is later created I believe.

Copy link
Collaborator Author

@geoff-powell geoff-powell Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I noticed that in the gradle docs but didn't go that way. Let me check that.

Updated 👍🏽

Copy link
Contributor

@ansman ansman Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to this should work as a drop in replacement:

inputs.files(isVerifyRun.map { if (it) listOf(snapshotOutputDir) else emptyList() })
    .withPropertyName("paparazzi.snapshots")
    .withPathSensitivity(PathSensitivity.RELATIVE)
    .optional()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works because calling input.files with an empty directory simply adds no input files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this works but we don't want to cache based on the snapshot files themselves and we really want to rely on the snapshot path alone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make caching work (and predictive test selection) the files themselves need to be included in the cache key so using a file property is not a good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep makes sense, I opted to instead keep the directory property I originally had.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue with this approach is that the outcome can depend on when the task is configured. I also want to make clear that a directory property will still include the contents of the directory in the cache key for the task so you're still going to be checksumming all the snapshots (which is a good thing)

Comment on lines 239 to 240
project.objects.fileProperty().apply {
set(if (it) snapshotOutputDir.asFile else null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you either want to ditch the file property or change keep it as a directory property. I'm not sure what happens if you pass a file property that points to a directory.

@geoff-powell geoff-powell force-pushed the gpowell/no-snapshot-dir branch 2 times, most recently from 1ba787e to 995defe Compare November 20, 2024 19:30
@geoff-powell geoff-powell force-pushed the gpowell/no-snapshot-dir branch from 995defe to 7608ffb Compare November 20, 2024 19:49
Comment on lines +273 to +279
test.logger.log(
WARN,
"""
Snapshot directory not found: ${snapshotOutputDir.asFile.path}
Please run the `recordPaparazzi$variantSlug` task to generate snapshots.
""".trimIndent()
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jrodbx I added a warning log for cases where the verify task runs without a snapshot directory created.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a way to disable this warning? It'll be really annoying for us to always see this warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants