Skip to content

CI: Add Roborazzi Screenshot comparison GitHub Action#20951

Merged
BrayanDSO merged 5 commits into
ankidroid:mainfrom
david-allison:roborazzi-ci-1
May 15, 2026
Merged

CI: Add Roborazzi Screenshot comparison GitHub Action#20951
BrayanDSO merged 5 commits into
ankidroid:mainfrom
david-allison:roborazzi-ci-1

Conversation

@david-allison

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

Copy link
Copy Markdown
Member

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
@BrayanDSO

Copy link
Copy Markdown
Member

GitHub is failing and I'm currently not able to do an actual review.

In screenshot_store.yml:

we will need to force screenshot tests to follow the ScreenshotTest naming style.

Also in paths:, doesn't **/ScreenshotTest.kt only match files named exactly ScreenshotTest.kt?

@david-allison

david-allison commented May 6, 2026

Copy link
Copy Markdown
Member Author

Also in paths:, doesn't **/ScreenshotTest.kt only match files named exactly ScreenshotTest.kt

I fear I wasn't clear. Could I have suggestions for a better comment.

store only runs on main.

If it runs on a PR branch (🛠️ Screenshots: Store / test), it only runs to ensure that we haven't broken the store mechanism, therefore we test on the gradle files, dependencies, and the base class of all Screenshot tests (this defines the category, and is the most likely to cause 'store' issues).

For the individual tests, these are run in compare

@BrayanDSO

Copy link
Copy Markdown
Member

made the comment too quickly. LGTM

@BrayanDSO BrayanDSO added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels May 6, 2026

@ericli3690 ericli3690 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fairly good to me overall. I've never really worked with yaml GitHub Actions code before, though, so maybe one more reviewer should take a skim. I see no issues. Should be fairly safe as it touches no production code and mostly serves to unblock two of David's PRs + Brayan's work + some testing stuff for me.

Will move this to pending merge for now. David, feel free to slap it in if you think I'm being overly cautious.

@ericli3690 ericli3690 added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels May 14, 2026
@BrayanDSO BrayanDSO added this pull request to the merge queue May 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 15, 2026
@BrayanDSO BrayanDSO added this pull request to the merge queue May 15, 2026
Merged via the queue into ankidroid:main with commit 7defb30 May 15, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in AnkiDroid 2.25 May 15, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CI: Add Roborazzi Screenshot comparison GitHub Action

3 participants