Skip to content

Upload Snapshots to Sentry using SnapshotPreview and SwiftSnapshotTesting libraries #12

Upload Snapshots to Sentry using SnapshotPreview and SwiftSnapshotTesting libraries

Upload Snapshots to Sentry using SnapshotPreview and SwiftSnapshotTesting libraries #12

name: Sentry iOS Upload (Snapshots)
on:
push:
branches: [main]
pull_request:
branches: [main]
paths: [ios/**, .github/workflows/ios*]
jobs:
upload_sentry_snapshots:
runs-on: macos-26
defaults:
run:
working-directory: ./ios
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: 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: Boot simulator
run: xcrun simctl boot "iPhone 17 Pro Max" || true
- name: Generate snapshot images (iPhone)
env:
EMERGE_DEFAULT_DEVICE_NAME: iPhone 17 Pro Max
run: |
set -o pipefail && TEST_RUNNER_SNAPSHOTS_EXPORT_DIR="$PWD/snapshot-images" xcodebuild test \
-scheme HackerNews \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro Max' \
-only-testing:HackerNewsTests/HackerNewsSnapshotTest \
-resultBundlePath ../SnapshotResults-iphone.xcresult \
ONLY_ACTIVE_ARCH=YES \
TARGETED_DEVICE_FAMILY=1 \
SUPPORTS_MACCATALYST=NO \
| xcpretty
# - name: Generate snapshot images (iPad)
# env:
# EMERGE_DEFAULT_DEVICE_NAME: iPhone 17 Pro Max
# run: |
# set -o pipefail && TEST_RUNNER_SNAPSHOTS_EXPORT_DIR="snapshot-images/" 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"
- name: Upload snapshots to Sentry
env:
SENTRY_SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_SENTRY_AUTH_TOKEN }}
run: bundle exec fastlane ios upload_sentry_preview_snapshots