Skip to content

Conversation

@geoff-powell
Copy link
Collaborator

No description provided.

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

SimonMarquis added a commit to SimonMarquis/paparazzi that referenced this pull request Feb 8, 2025
…t present

This is the 2nd PR to finally close cashapp#1716.

Also relates to:
- cashapp#1692
- cashapp#1695

since this still requires the presence of the `src/test/snapshots/images` input to work.
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