Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c2b918e
Use SnapshotPreviews from `cameroncooke/snapshot-ci` branch
cameroncooke Apr 7, 2026
56fdd63
Upload workflow to support new SnapshotPreviews image exports
cameroncooke Apr 1, 2026
81230e5
fix: use absolute path for snapshot export dir to avoid test bootstra…
cameroncooke Apr 1, 2026
676b945
Update package reference
cameroncooke Apr 3, 2026
4b99f38
ci(ios): Hoist snapshot env vars to job level and boot iPad sim separ…
cameroncooke Apr 7, 2026
5f81e4c
ci(ios): Add pull_request trigger to snapshot upload workflow
cameroncooke Apr 7, 2026
1c63516
Disable iPad run
cameroncooke Apr 7, 2026
86400e6
feat(fastlane): Add lane to upload SnapshotPreviews snapshots to Sentry
cameroncooke Apr 7, 2026
1a07a3c
ci(ios): Cache DerivedData and split build/test phases for snapshots
cameroncooke Apr 7, 2026
5a524f3
ci(ios): Pin DD path, skip SPM updates, enable compilation caching
cameroncooke Apr 7, 2026
4693c5c
ci: trigger snapshot workflow to test warm cache
cameroncooke Apr 8, 2026
7832aa8
ci(ios): Remove redundant SPM cache step
cameroncooke Apr 8, 2026
7ffad21
ci(ios): Recombine build and test into single xcodebuild invocation
cameroncooke Apr 8, 2026
887a063
Update to use latest SnapshotPreviews branch commit
cameroncooke Apr 8, 2026
05b0f54
ci(ios): Replace -skipPackageUpdates with -skipPackagePluginValidation
cameroncooke Apr 8, 2026
bf734e6
ci(ios): Remove DD cache, restore original SPM cache
cameroncooke Apr 8, 2026
d363a7c
ci(ios): Pin arm64 arch in simulator destination to skip disambiguation
cameroncooke Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/ios_sentry_upload_snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Sentry iOS Upload (Snapshots)

on:
push:
branches: [main]
paths: [ios/**, .github/workflows/ios*]
pull_request:
branches: [main]
paths: [ios/**, .github/workflows/ios*]
Comment on lines +7 to +9
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The workflow will fail on pull requests from forked repositories because secrets like SENTRY_SENTRY_AUTH_TOKEN are not available, causing the Sentry upload step to fail.
Severity: MEDIUM

Suggested Fix

To fix this, consider running the Sentry upload step only on push events to the main branch, or use a pull_request_target trigger with appropriate security controls like environment approval gates. This ensures that steps requiring secrets only run in a trusted context.

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_snapshots.yml#L7-L9

Potential issue: The workflow is configured to trigger on `pull_request` events. For
pull requests originating from forked repositories, GitHub Actions does not provide
secrets for security reasons. As a result, the `SENTRY_SENTRY_AUTH_TOKEN` secret will be
an empty string. The `fastlane` action `upload_sentry_preview_snapshots` requires a
valid authentication token and will fail when the token is empty. This will cause the CI
workflow to fail for any external contributor submitting a pull request from a fork,
blocking their contribution.


jobs:
upload_sentry_snapshots:
runs-on: macos-26

defaults:
run:
working-directory: ./ios

env:
TEST_RUNNER_SNAPSHOTS_EXPORT_DIR: "${{ github.workspace }}/ios/snapshot-images"
XCODE_RUNNING_FOR_PREVIEWS: 1

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.10
bundler-cache: true

- name: Setup gems
run: exec ../.github/scripts/ios/setup.sh

- name: Boot iPhone simulator
run: xcrun simctl boot "iPhone 17 Pro Max" || true

- name: Cache Swift Package Manager
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData/HackerNews-*/SourcePackages
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: ${{ runner.os }}-spm-

- name: Generate snapshot images (iPhone)
run: |
set -o pipefail && xcodebuild test \
-scheme HackerNews \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro Max,arch=arm64' \
-only-testing:HackerNewsTests/HackerNewsSnapshotTest \
-resultBundlePath ../SnapshotResults-iphone.xcresult \
-skipPackagePluginValidation \
ONLY_ACTIVE_ARCH=YES \
TARGETED_DEVICE_FAMILY=1 \
SUPPORTS_MACCATALYST=NO \
CODE_SIGNING_ALLOWED=NO \
COMPILATION_CACHING=YES \
EAGER_LINKING=YES \
FUSE_BUILD_SCRIPT_PHASES=YES \
| xcpretty

# - name: Boot iPad simulator
# run: xcrun simctl boot "iPad Air 11-inch (M3)" || true

# - name: Generate snapshot images (iPad)
# run: |
# set -o pipefail && xcodebuild test \
# -scheme HackerNews \
# -sdk iphonesimulator \
# -destination 'platform=iOS Simulator,name=iPad Air 11-inch (M3)' \
# -only-testing:HackerNewsTests/HackerNewsSnapshotTest \
# -resultBundlePath ../SnapshotResults-ipad.xcresult \
# ONLY_ACTIVE_ARCH=YES \
# TARGETED_DEVICE_FAMILY="1,2" \
# SUPPORTS_MACCATALYST=NO \
# | xcpretty

- name: List generated images
run: |
echo "Generated snapshot images:"
ls -1 snapshot-images/
echo "Total: $(ls -1 snapshot-images/ | wc -l | tr -d ' ') images"
Comment on lines +84 to +88
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The workflow will fail if no snapshot images are generated because the ls command will error when the snapshot-images/ directory is not found.
Severity: MEDIUM

Suggested Fix

Add a defensive step to ensure the directory exists before listing its contents, such as mkdir -p snapshot-images, or add continue-on-error: true to the "List generated images" step to prevent a workflow failure.

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_snapshots.yml#L83-L87

Potential issue: The workflow includes a step to list generated snapshot images using
`ls -1 snapshot-images/`. However, if the preceding snapshot generation step produces no
images, the `snapshot-images/` directory may not be created by the external
`cameroncooke/snapshot-ci` tool. The workflow does not defensively create this directory
or handle potential errors from the `ls` command. If the directory is absent, the `ls`
command will fail with a non-zero exit code, causing the entire workflow run to fail.


- name: Upload snapshots to Sentry
env:
SENTRY_SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_SENTRY_AUTH_TOKEN }}
run: bundle exec fastlane ios upload_sentry_preview_snapshots
2 changes: 1 addition & 1 deletion ios/HackerNews.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews";
requirement = {
branch = main;
branch = "cameroncooke/snapshot-ci";
kind = branch;
};
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ platform :ios do
UI.success("Successfully replaced app in XCArchive with thinned build for #{device_type}")
end

desc 'Upload SnapshotPreviews snapshots to Sentry'
lane :upload_sentry_preview_snapshots do
sentry_upload_snapshots(
path: 'snapshot-images',
app_id: 'com.emergetools.hackernews',
auth_token: ENV['SENTRY_SENTRY_AUTH_TOKEN'],
org_slug: 'sentry',
project_slug: 'hackernews-ios'
)
end

desc 'Upload swift-snapshot-testing snapshots to Sentry'
lane :upload_sentry_snapshots do
sentry_upload_snapshots(
Expand Down
Loading