diff --git a/.github/workflows/ios_sentry_upload_snapshots.yml b/.github/workflows/ios_sentry_upload_snapshots.yml new file mode 100644 index 00000000..37a1aa4c --- /dev/null +++ b/.github/workflows/ios_sentry_upload_snapshots.yml @@ -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*] + +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" + + - name: Upload snapshots to Sentry + env: + SENTRY_SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_SENTRY_AUTH_TOKEN }} + run: bundle exec fastlane ios upload_sentry_preview_snapshots \ No newline at end of file diff --git a/ios/HackerNews.xcodeproj/project.pbxproj b/ios/HackerNews.xcodeproj/project.pbxproj index 742c85a8..1e0bd730 100644 --- a/ios/HackerNews.xcodeproj/project.pbxproj +++ b/ios/HackerNews.xcodeproj/project.pbxproj @@ -1271,7 +1271,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews"; requirement = { - branch = main; + branch = "cameroncooke/snapshot-ci"; kind = branch; }; }; diff --git a/ios/HackerNews.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/HackerNews.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f74453c2..5bbce42a 100644 --- a/ios/HackerNews.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ios/HackerNews.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "cd279061071a9be804a18a197dd9701ac5708de79c458383a585d24b3f0df7d0", + "originHash" : "77abd4b0c51c017fe6ce592791015e863646bc679a165e2613e1adb9a21f5e59", "pins" : [ { "identity" : "accessibilitysnapshotios26", @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/EmergeTools/SnapshotPreviews", "state" : { - "branch" : "main", - "revision" : "1b3bd9bb341de85d927a78ad8874a35d081a8a66" + "branch" : "cameroncooke/snapshot-ci", + "revision" : "c58a343e2aad105ee24eb4d4b954ac26946c35da" } }, { diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index cfcccf66..41a56dc2 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -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(