Skip to content

Removes stale paywall template screenshots if necessary#3595

Merged
JayShortway merged 2 commits into
mainfrom
cursor/remove-stale-paywall-template-screenshots-7727
Jun 16, 2026
Merged

Removes stale paywall template screenshots if necessary#3595
JayShortway merged 2 commits into
mainfrom
cursor/remove-stale-paywall-template-screenshots-7727

Conversation

@JayShortway

@JayShortway JayShortway commented Jun 12, 2026

Copy link
Copy Markdown
Member

Description

We would only ever add new paywall screenshots to paywall-rendering-validation, never remove ones that we deleted from paywall-preview-resources. This PR implements just that.

iOS equivalent: RevenueCat/purchases-ios#6984

Open in Web Open in Cursor 

Note

Medium Risk
Automated deletion in an external repo could remove valid screenshots if offering IDs fail to parse or the recorder returns an incomplete set; the empty-list guard mitigates total wipe on zero output.

Overview
The automated paywall template screenshot flow now removes stale Android assets from the validation repo when templates disappear from preview resources, matching the iOS behavior.

While moving Paparazzi PNGs into screenshots/templates/{offering_id}/, the lane collects produced_offering_ids and then runs remove_stale_android_template_screenshots, which deletes android.png (only) for offering folders not in that set and drops empty directories. If the run produces no screenshots, pruning is skipped so a failed recording cannot wipe the repo.

Reviewed by Cursor Bugbot for commit a47a2fb. Bugbot is set up for automated code reviews on this repo. Configure here.

The screenshot upload lane was add-only, so when a paywall is removed,
renamed, or its directory name changes, the old android.png lingered
forever in paywall-rendering-validation. Track the offering IDs rendered
in each run and delete any android.png whose directory is no longer
produced, then remove directories that become empty. Only android.png is
touched, so screenshots owned by other platforms (ios.png, mac-*.png) are
never affected. A guard refuses to prune if nothing was produced, to
avoid wiping everything on a failed render.

Co-authored-by: joop <joop@revenuecat.com>
@JayShortway JayShortway self-assigned this Jun 12, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.26%. Comparing base (935b029) to head (a47a2fb).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3595   +/-   ##
=======================================
  Coverage   80.26%   80.26%           
=======================================
  Files         378      378           
  Lines       15448    15448           
  Branches     2143     2143           
=======================================
  Hits        12400    12400           
  Misses       2189     2189           
  Partials      859      859           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JayShortway JayShortway changed the title Remove stale Android paywall template screenshots on upload Removes stale Android paywall template screenshots if necessary Jun 16, 2026
@JayShortway JayShortway requested review from a team June 16, 2026 10:37
@JayShortway JayShortway marked this pull request as ready for review June 16, 2026 10:37
@JayShortway JayShortway requested a review from a team as a code owner June 16, 2026 10:37

@AlvaroBrey AlvaroBrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left a comment, but approved anyway!

Comment thread fastlane/Fastfile
target_repository_path = options[:target_repository_path] || UI.user_error!("No target_repository_path provided")
produced_offering_ids = options[:produced_offering_ids] || UI.user_error!("No produced_offering_ids provided")

UI.user_error!("No Android screenshots were produced; refusing to prune stale screenshots.") if produced_offering_ids.empty?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, the empty check will not prevent deletion of screenshots if there is a partial failure, but I'm not sure that partial failures are possible in our current setup.

What i mean by this is, if a screenshot fails to generate silently, we would delete the baseline too.

The ideal way to fix this would be to not rely on the generated files, but on the tests themselves.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm that's a good point... TBH, I don't think partial failures would be possible, as in, if there is an issue running the screenshots at some point, it would fail the whole process, but could be an interesting improvement nonetheless.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point indeed, although the only alternative I can come up with is parsing the Offering IDs from the JSON files before generating the screenshots, to know which IDs we should expect. I'm not sure that's worth the complexity. The output of this lane will be a PR in paywall-rendering-validation, so any deleted screenshots should already be checked there during review.

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good point in the previous comment... But yeah, I would say it shouldn't happen so probably ok to merge for now.

Comment thread fastlane/Fastfile
target_repository_path = options[:target_repository_path] || UI.user_error!("No target_repository_path provided")
produced_offering_ids = options[:produced_offering_ids] || UI.user_error!("No produced_offering_ids provided")

UI.user_error!("No Android screenshots were produced; refusing to prune stale screenshots.") if produced_offering_ids.empty?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm that's a good point... TBH, I don't think partial failures would be possible, as in, if there is an issue running the screenshots at some point, it would fail the whole process, but could be an interesting improvement nonetheless.

@JayShortway JayShortway added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 60c2e79 Jun 16, 2026
43 checks passed
@JayShortway JayShortway deleted the cursor/remove-stale-paywall-template-screenshots-7727 branch June 16, 2026 12:36
@JayShortway JayShortway changed the title Removes stale Android paywall template screenshots if necessary Removes stale paywall template screenshots if necessary Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants