diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 58a5b86..6272fea 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -3,6 +3,7 @@ name: iOS Build and Test permissions: contents: read pull-requests: write + checks: write on: push: @@ -19,14 +20,15 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: List available Xcode versions - run: ls /Applications | grep Xcode - - name: Set Xcode version run: sudo xcode-select -s /Applications/Xcode_26.0.1.app - - name: Show Xcode version - run: xcodebuild -version + - name: Use the exact SPM lockfile + run: | + # Ensure we use the committed lockfile, do not re-resolve + xcodebuild -resolvePackageDependencies \ + -project SnapSafe.xcodeproj \ + -scheme SnapSafe - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -34,23 +36,16 @@ jobs: bundler-cache: true ruby-version: '3.4' - - name: Install dependencies + - name: Install ruby dependencies for fastlane run: bundle install - - name: List available schemes - run: xcodebuild -list -project SnapSafe.xcodeproj + - name: Disable macro validation + run: | + defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES - - name: Run tests with fastlane (non-parallel) + - name: Run tests run: | - set -o pipefail - RESULTDIR="$RUNNER_TEMP/xcresult/$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-$(date +%s)" - mkdir -p "$RESULTDIR" - bundle exec fastlane scan \ - scheme:"SnapSafe" \ - result_bundle:true \ - disable_concurrent_testing:true \ - output_directory:"$RESULTDIR" \ - open_report:false + bundle exec fastlane test - name: Upload test results if: always() @@ -59,8 +54,10 @@ jobs: name: test-results path: | fastlane/test_output/ + # 'fastlane scan' creates these fastlane/test_output/*.junit fastlane/test_output/*.html + # xcodebuild creates this fastlane/test_output/*.xcresult retention-days: 30 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index bb0e5e4..260283d 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -60,6 +60,10 @@ jobs: mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles cp $PROVISION_PATH ~/Library/MobileDevice/Provisioning\ Profiles/ + - name: Run tests + run: | + bundle exec fastlane test + - name: Build release IPA run: bundle exec fastlane build_release diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 56a36da..61cba2c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -31,7 +31,7 @@ platform :ios do lane :test do run_tests( scheme: "SnapSafe", - devices: ["iPhone 17", "iPad Pro 11-inch (M4)"], + devices: ["iPhone 17"], only_testing: ["SnapSafeTests"] ) end @@ -40,10 +40,8 @@ platform :ios do # Test against latest and latest minus 1 ios_versions = ['18.5', '26.0'] - # Test on both iPhone and iPad device_types = [ { name: 'iPhone 17', type: 'iPhone' }, - { name: 'iPad Pro 11-inch (M4)', type: 'iPad' } ] ios_versions.each do |version| diff --git a/fastlane/Scanfile b/fastlane/Scanfile index 20beff7..62e095f 100644 --- a/fastlane/Scanfile +++ b/fastlane/Scanfile @@ -6,7 +6,7 @@ scheme("SnapSafe") project "SnapSafe.xcodeproj" -devices(["iPhone 17", "iPad Pro 11-inch (M4)"]) +devices(["iPhone 17"]) # Generate xcresult bundle which can be opened in Xcode for detailed results result_bundle(true) @@ -22,3 +22,15 @@ output_directory("./fastlane/test_output") # Enable skip_build to skip debug builds for faster test performance skip_build(false) + +# Skip macro validation in CI environments +# This is needed for Swift macro packages like Mockable +xcargs("-skipMacroValidation") + +# Simulator reliability settings +reset_simulator(true) # Reset simulator before running tests +disable_slide_to_type(false) # Don't disable slide to type (can cause issues) +prelaunch_simulator(true) # Boot simulator before running tests + +# Only run unit tests, not UI tests (UI tests can be run separately with snapshot) +only_testing(["SnapSafeTests"])