Skip to content

CI: Add Roborazzi Screenshot comparison GitHub Action#20951

Open
david-allison wants to merge 5 commits intoankidroid:mainfrom
david-allison:roborazzi-ci-1
Open

CI: Add Roborazzi Screenshot comparison GitHub Action#20951
david-allison wants to merge 5 commits intoankidroid:mainfrom
david-allison:roborazzi-ci-1

Conversation

@david-allison
Copy link
Copy Markdown
Member

@david-allison david-allison commented May 5, 2026

Note

Assisted-by: Claude Opus 4.7

Purpose / Description

Brayan wanted to get our Roborazzi screenshot tests running in CI, so a user was informed explicitly if their code changes changed the app visuals.

This was primarily for his theming/Material You improvements, but this affects all users positively, allowing us to automate regression testing, or allowing a user to add a test to produce up-to-date screenshots exposing a new feature across all themes.

Screenshot 2026-05-05 at 14 35 15 image

Fixes

Approach

Follow the Roborazzi guide, then make changes

This introduces 3 files:

  • screenshot_store.yml: store a baseline in an artifact for commits to main
  • screenshot_compare.yml: on a PR branch, build a snapshot and compare it with main
  • screenshot_comment.yml: when screenshot_compare.yml completes, add a comment to the PR listing changes, OR updates the comment if changes are resolved

Major Changes

  • For security, instead of creating a branch in ankidroid/Anki-Android, reference the artifact
    • We lose inline screenshots
  • Action naming: map to this repo
  • screenshot-diff artifact is now more useable
    • Remove a deeply nested structure
    • Name the extracted folder: screenshot-diff-pr-N
      • Contains 1 folder per test class
        • 3 images per failing test: x.png x_actual.png x_compare.png
  • Limit the comment to ensure we don't go over the 65k comment size limit

How Has This Been Tested?

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison david-allison requested a review from BrayanDSO May 5, 2026 13:43
@david-allison david-allison marked this pull request as draft May 5, 2026 13:53
@david-allison

This comment was marked as resolved.

@david-allison david-allison marked this pull request as ready for review May 5, 2026 14:35
@david-allison david-allison added this to the 2.25 release milestone May 5, 2026
Using Roborazzi for the implementation

* 'screenshot_store': runs on `main` store an artifact with
  a baseline
* 'screenshot_compare': an artifact is generated on PRs if changes are ,
  detected against `main`'s artifact
* 'screenshot_comment': if an artifact is generated, a PR comment is
added

Original sources

https://github.com/takahirom/roborazzi/blob/main/.github/workflows/CompareScreenshot.yml
https://github.com/takahirom/roborazzi/blob/main/.github/workflows/CompareScreenshotComment.yml
https://github.com/takahirom/roborazzi/blob/main/.github/workflows/StoreScreenshot.yml

- compare_screenshot_comment: quote the bot email so the [bot]
  brackets aren't interpreted by the shell
- StudyScreenScreenshotTest: keep per-test-class subdirectory in the
  capture path so future screenshot tests don't collide
- Use dedicated Roborazzi gradle tasks (compareRoborazziPlayDebug)
- Remove pinned workflows to match repo style
- Use open source gradle cache provider
- Rename workflows
- Add Apache header

Issue 20942

Assisted-by: Claude Opus 4.7
A branch was deemed too risky from a security perspective

Assisted-by: Claude Opus 4.7
* remove the nested folder tree (build/outputs/roborazzi)
* name the directory: screenshot-diff.zip contains
`screenshot-diff-pr-123` so conflicts don't occur and cleanup is easier

Assisted-by: Claude Opus 4.7 - all

Issue 20942
If the regressions were fixed, mark the PR as resolved
Do not post a comment if one already existed

Issue 20942

Assisted-by: Claude Opus 4.7 - all
Store only needs to be executed on `main`

We run on some file changes, in case they break the upload process, but
this is only defensive.

Note: this does upload artifacts, this could be avoided, but the
complexity makes the 'happy path' of this workflow harder to reason
about.

Issue 20942

Assisted-by: Claude Opus 4.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Add Roborazzi Screenshot comparison GitHub Action

1 participant