Use SnapshotPreviews from Cameroncooke/snapshots ci branch#780
Use SnapshotPreviews from Cameroncooke/snapshots ci branch#780cameroncooke wants to merge 19 commits intomainfrom
Cameroncooke/snapshots ci branch#780Conversation
📸 Snapshot Test1 modified, 71 unchanged
🛸 Powered by Emerge Tools |
📲 Install BuildsiOS
|
7502a1a to
beb2055
Compare
…p crash The test process working directory differs from the shell's, so a relative path caused the SnapshotCIExportCoordinator to fail creating the export directory, triggering a preconditionFailure (SIGTRAP) during test bootstrapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ately Move TEST_RUNNER_SNAPSHOTS_EXPORT_DIR and XCODE_RUNNING_FOR_PREVIEWS into the job-level env block so both iPhone and iPad test steps share the same absolute export path. Add a dedicated boot step for the iPad simulator and clarify the existing boot step name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
537b41f to
4b99f38
Compare
Run the snapshot upload workflow on PRs targeting main in addition to pushes, scoped to ios and workflow file paths for both triggers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add upload_sentry_preview_snapshots lane that uploads snapshot images generated by SnapshotPreviews to Sentry, separate from the existing swift-snapshot-testing upload lane. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add branch-scoped DerivedData caching and split the single xcodebuild test into build-for-testing + test-without-building to improve CI wall-clock time and give better visibility into build vs test duration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move sim boot before cache steps so it boots during cache restore - Pin DerivedData to a fixed path with -derivedDataPath so cache reliably hits across runs - Add -skipPackageUpdates to avoid ~2min SPM resolution (Package.resolved is committed) - Enable COMPILATION_CACHING, EAGER_LINKING, FUSE_BUILD_SCRIPT_PHASES for faster incremental and zero-change builds - Strip redundant build settings from test-without-building step - Simplify SPM cache path (DD cache now covers SourcePackages) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DerivedData cache already contains SourcePackages, and -skipPackageUpdates prevents xcodebuild from fetching. The SPM cache was downloading 759MB for no benefit — removing it saves ~4 minutes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The split into build-for-testing + test-without-building was paying ~2min xcodebuild startup tax twice. For 23 snapshot tests that run in 10s, the visibility tradeoff isn't worth ~1min of added overhead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-skipPackageUpdates prevents xcodebuild from fetching new commits when Package.resolved changes, causing failures. Since the DD cache is keyed on branch name (not Package.resolved), we need to allow SPM to fetch deltas. -skipPackagePluginValidation still skips plugin trust prompts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DerivedData cache download time was too variable (1.5-5 min) on GHA network, often outweighing build savings. Restore the original SPM cache which is smaller and more predictable. Keep COMPILATION_CACHING and other build settings which work independently of DD caching. Also removed -derivedDataPath to use default location (matches SPM cache paths). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
xcodebuild was matching both arm64 and x86_64 for the same simulator, triggering a warning and potentially slowing destination resolution. Pinning arch=arm64 eliminates the ambiguity on Apple Silicon runners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a new GitHub Actions workflow that runs SwiftSnapshotTest and uploads the generated images to Sentry. Recording is controlled via the SNAPSHOT_TESTING_RECORD env var instead of hardcoding record: .all in the test file, so local runs default to reference comparison while CI always records fresh snapshots. - New workflow: ios_sentry_upload_swift_snapshots.yml - Remove invokeTest() override from SwiftSnapshotTest.swift - Use continue-on-error on test step since record mode fails assertions Refs EME-1030 Co-Authored-By: Claude <noreply@anthropic.com>
Sentry Snapshot Testing
|
| super.invokeTest() | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
@NicoHinderling Yes, because Swift Snapshot Testing does diffing locally, we would only want to enable recording on CI workflows. We use an environmental variable in the GitHub workflow example TEST_RUNNER_SNAPSHOT_TESTING_RECORD which causes the library to record. This allows the user to run tests and catch regressions locally before pushing via the Pointfree library's own diff algo and on CI it will just be used to export images. It's also worth noting enabling recording causes XCTest failures which we ignore on CI but will run as real regression tests locally.
| # COMPILATION_CACHING=YES \ | ||
| # EAGER_LINKING=YES \ | ||
| # FUSE_BUILD_SCRIPT_PHASES=YES \ | ||
| # | xcpretty |
There was a problem hiding this comment.
I think lets actually uncomment and keep this in here! I think it's a great example :)
There was a problem hiding this comment.
@NicoHinderling There is actually one issue at the moment the filenames don't include the simulator device info or runtime so iPad images would overwrite the iOS ones. What do we think the best strategy is for users on this?
- Should we use nested folders does that name space on Sentry?
- Should we just rename the files adding a prefix or suffix post generation?
- Should the library automatically name images based on device/runtime?
Some things that are not clear to me is how we disambiguate on the Sentry end and what the expected exp. is for multiple platform/device snapshots.
There was a problem hiding this comment.
i actually just merged a PR related to this yesterday to add proper subdirectory support within the snapshots images-to-upload folder...
so I think two things:
- In our example, we should upload the ipad and iphone images as nested subdirectories, that way the
image_file_namevalue will be unique for all images - the deviceType is exactly the kind of metadata that the
snapshotPreviewslibrary should expose that we can then pass into the JSON sidecar metadata thanks to your PR :)
As a reminder, the setup currently allows you to include whatever extra fields you want in the metadata upload, so could you make sure for this example we include declaredDevice/simulatorDeviceName in this upload?
Upstream SnapshotPreviews CI-export changes have merged to main, so the temporary cameroncooke/snapshot-ci branch pin is no longer needed. Reverts both project.pbxproj and Package.resolved to match main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| restore-keys: ${{ runner.os }}-spm- | ||
|
|
||
| - name: Generate snapshot images | ||
| continue-on-error: true |
There was a problem hiding this comment.
Bug: The snapshot generation workflow uses an unrecognized environment variable TEST_RUNNER_SNAPSHOT_TESTING_RECORD, causing tests to fail silently due to continue-on-error: true without generating any snapshots.
Severity: HIGH
Suggested Fix
Either pass the environment variable without the TEST_RUNNER_ prefix directly to the xcodebuild command, or add code within the test target to read the prefixed variable from ProcessInfo.processInfo.environment and configure the snapshot testing library accordingly.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: .github/workflows/ios_sentry_upload_swift_snapshots.yml#L51
Potential issue: The CI workflow `ios_sentry_upload_swift_snapshots.yml` is configured
to generate snapshot tests by setting the `TEST_RUNNER_SNAPSHOT_TESTING_RECORD`
environment variable. However, the `swift-snapshot-testing` library does not recognize
this variable; it expects `SNAPSHOT_TESTING_RECORD`. Concurrently, the code that
previously enabled recording, `withSnapshotTesting(record: .all)`, has been removed. As
a result, the tests will not enter recording mode and will fail because no reference
snapshots exist. This failure is masked by `continue-on-error: true` in the workflow,
causing the job to proceed silently without generating or uploading any snapshots,
despite appearing to succeed.
There was a problem hiding this comment.
This is in fact correct, SNAPSHOT_TESTING_RECORD is used by PointFree's SwiftSnashotTesting library to force snapshot recording. The TEST_RUNNER_ prefix is a way to pass environmental variables to the test runner. xcodebuild will remove the prefix before making the environmental variable available to the test runner process. See: https://developer.apple.com/documentation/xcode/environment-variable-reference
Cameroncooke/snapshots ci branchCameroncooke/snapshots ci branch
This branch exists just to test the
unreleasednow merged changes to SnapshowPreviews on the here: EmergeTools/SnapshotPreviews#252See workflow run which is using SnapshotPreviews with CI export functionality:
https://github.com/EmergeTools/hackernews/actions/runs/23857485626/job/69554642234?pr=780
Resulting Sentry Snapshots URL:
https://sentry.sentry.io/preprod/snapshots/177173/