Skip to content

ci(snapshots): Add selective iOS snapshot upload workflow#268

Merged
cameroncooke merged 9 commits into
mainfrom
cameroncooke/EME-1182-selective_snapshots_workflow
Jun 8, 2026
Merged

ci(snapshots): Add selective iOS snapshot upload workflow#268
cameroncooke merged 9 commits into
mainfrom
cameroncooke/EME-1182-selective_snapshots_workflow

Conversation

@cameroncooke

Copy link
Copy Markdown
Contributor

Adds a GitHub Actions workflow that uploads iOS snapshots from Examples/MultiModuleDemo to Sentry.

The workflow builds the test bundle once, reuses the generated .xctestrun for snapshot rendering, selects the relevant snapshot test group from pull request file changes, and uploads the rendered subset with a full image-name manifest so Sentry can distinguish rendered, skipped, and removed snapshots.

Selective test selection

Pull requests touching ModuleA run the Module A snapshot group. Pull requests touching ModuleB or ModuleC run the Module B/C snapshot group. Broader demo, source, or package changes run both groups.

Sentry upload

The upload job requires SENTRY_AUTH_TOKEN and SENTRY_APP_ID repository secrets. It installs sentry-cli, aggregates rendered snapshot artifacts, downloads the generated full image-name list, and uploads with --all-image-file-names-file.

Add a GitHub Actions workflow that builds, generates, and uploads iOS
snapshot images to Sentry. The workflow maps changed paths to the
relevant snapshot tests so pull requests only regenerate the snapshots
affected by their changes, while pushes to main and unmatched changes
fall back to the full test set.

Build products are produced once via build-for-testing and shared across
the snapshot generation and image-name jobs to avoid redundant builds.
The aggregated images and image-name manifest are then uploaded with
sentry-cli.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 8, 2026

Copy link
Copy Markdown

EME-1182

Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Fixed
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Fixed
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Fixed
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Fixed
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Fixed
Restrict the workflow token to read-only repository access and pass the Sentry project secret required by snapshot uploads.

Co-Authored-By: Codex <noreply@openai.com>
@cameroncooke

Copy link
Copy Markdown
Contributor Author

Fixed the upload failure in 792838f by adding SENTRY_PROJECT as a required secret and passing it to sentry-cli build snapshots with --project.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: PR diff uses wrong git range
    • Changed git diff from two-dot to three-dot syntax (BASE_SHA...HEAD_SHA) to compare from merge-base, ensuring only PR changes are detected.

Create PR

Or push these changes by commenting:

@cursor push ddd1930820
Preview (ddd1930820)
diff --git a/.github/workflows/ios_sentry_upload_snapshots.yml b/.github/workflows/ios_sentry_upload_snapshots.yml
--- a/.github/workflows/ios_sentry_upload_snapshots.yml
+++ b/.github/workflows/ios_sentry_upload_snapshots.yml
@@ -60,7 +60,7 @@
           if [ "${{ github.event_name }}" = "pull_request" ]; then
             BASE_SHA="${{ github.event.pull_request.base.sha }}"
             HEAD_SHA="${{ github.event.pull_request.head.sha }}"
-            changed_files="$(git diff --name-only "${BASE_SHA}" "${HEAD_SHA}")"
+            changed_files="$(git diff --name-only "${BASE_SHA}...${HEAD_SHA}")"
           else
             changed_files=""
           fi

You can send follow-ups to the cloud agent here.

Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Outdated
Check out the repository in the snapshot upload job so sentry-cli can detect git metadata automatically when uploading snapshots.

Co-Authored-By: Codex <noreply@openai.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Missing selective upload flag
    • Added the --selective flag to the sentry-cli build snapshots command so Sentry correctly distinguishes between skipped and removed snapshots during partial test runs.

Create PR

Or push these changes by commenting:

@cursor push a0e29d705d
Preview (a0e29d705d)
diff --git a/.github/workflows/ios_sentry_upload_snapshots.yml b/.github/workflows/ios_sentry_upload_snapshots.yml
--- a/.github/workflows/ios_sentry_upload_snapshots.yml
+++ b/.github/workflows/ios_sentry_upload_snapshots.yml
@@ -325,4 +325,5 @@
             --auth-token "${SENTRY_AUTH_TOKEN}" \
             --project "${SENTRY_PROJECT}" \
             --app-id "${SENTRY_APP_ID}" \
-            --all-image-file-names-file "${{ github.workspace }}/snapshot-image-names/all-image-names.txt"
+            --all-image-file-names-file "${{ github.workspace }}/snapshot-image-names/all-image-names.txt" \
+            --selective

You can send follow-ups to the cloud agent here.

Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Outdated
Use the PR merge-base diff when selecting snapshot test classes.

Fan out snapshot generation by selected test class so each class runs in its own GitHub Actions matrix job. This avoids shared dynamic preview state between test classes while keeping the test-without-building runs parallel in CI.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@cameroncooke

Copy link
Copy Markdown
Contributor Author

Addressed the valid diff-range feedback in 1dddfd2 by switching snapshot test selection to the PR merge-base diff (BASE_SHA...HEAD_SHA).

I intentionally did not add --selective: this workflow uses --all-image-file-names-file, and the Sentry selective-testing docs say that passing an image-name file marks the upload as selective on its own. That mode is the intended one here because we generate the complete image-name set separately from the rendered subset.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Nested artifacts mismatch manifest names
    • Added merge-multiple: true to flatten snapshot artifacts into a single directory structure, aligning uploaded paths with the basename-only manifest entries.

Create PR

Or push these changes by commenting:

@cursor push 9dca3dc870
Preview (9dca3dc870)
diff --git a/.github/workflows/ios_sentry_upload_snapshots.yml b/.github/workflows/ios_sentry_upload_snapshots.yml
--- a/.github/workflows/ios_sentry_upload_snapshots.yml
+++ b/.github/workflows/ios_sentry_upload_snapshots.yml
@@ -285,6 +285,7 @@
         with:
           path: ${{ env.SNAPSHOT_UPLOAD_BASE_DIR }}
           pattern: snapshots-*
+          merge-multiple: true
 
       - name: Download image names
         uses: actions/download-artifact@v5

You can send follow-ups to the cloud agent here.

Comment thread .github/workflows/ios_sentry_upload_snapshots.yml
Merge snapshot matrix artifacts into the upload root so uploaded image paths match the generated all-image-name file.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@sentry

sentry Bot commented Jun 8, 2026

Copy link
Copy Markdown

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
com.example.multimoduledemo
com.example.multimoduledemo
- - - - - - ✅ 7 uploaded

No base snapshots found to compare against. Make sure snapshots are uploaded from your main branch.

⚙️ snapshot-previews Snapshot Settings

Run each full-coverage image-name test class in its own matrix job so it can execute alongside selected snapshot generation.

Aggregate the per-class image-name artifacts before uploading to Sentry so the upload still receives one complete image-name file.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Wrong manifest path for upload
    • Replaced hardcoded path with ALL_IMAGE_NAMES_FILE environment variable to reference the correct manifest location in snapshot-images/ directory.

Create PR

Or push these changes by commenting:

@cursor push d016d2878e
Preview (d016d2878e)
diff --git a/.github/workflows/ios_sentry_upload_snapshots.yml b/.github/workflows/ios_sentry_upload_snapshots.yml
--- a/.github/workflows/ios_sentry_upload_snapshots.yml
+++ b/.github/workflows/ios_sentry_upload_snapshots.yml
@@ -332,4 +332,4 @@
             --auth-token "${SENTRY_AUTH_TOKEN}" \
             --project "${SENTRY_PROJECT}" \
             --app-id "${SENTRY_APP_ID}" \
-            --all-image-file-names-file "${{ github.workspace }}/snapshot-image-names/all-image-names.txt"
+            --all-image-file-names-file "${{ env.ALL_IMAGE_NAMES_FILE }}"

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 1d487d1. Configure here.

Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Outdated
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml Outdated
Pass the merged all-image-name manifest produced by the upload job to sentry-cli.

This keeps the parallel image-name jobs while ensuring Sentry receives the manifest path that the aggregation step actually writes.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Comment thread .github/workflows/ios_sentry_upload_snapshots.yml
cameroncooke and others added 2 commits June 8, 2026 16:52
Replace mapfile with a Bash 3.2-compatible read loop when collecting per-shard image-name manifests.

macOS runners use Bash 3.2 by default, so mapfile is not available in the upload job.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Add explanatory comments to the snapshot upload workflow describing each
job's role in the selective testing flow: how pull requests narrow the
test set by changed paths, why image-name generation always runs the full
suite, and how the aggregated manifest lets Sentry distinguish skipped
snapshots from removed ones. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cameroncooke cameroncooke merged commit f470d76 into main Jun 8, 2026
26 of 27 checks passed
@cameroncooke cameroncooke deleted the cameroncooke/EME-1182-selective_snapshots_workflow branch June 8, 2026 17:18
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.

3 participants