diff --git a/.github/workflows/unit_tests_enterprise.yml b/.github/workflows/unit_tests_enterprise.yml index 8c467d913..99d179a63 100644 --- a/.github/workflows/unit_tests_enterprise.yml +++ b/.github/workflows/unit_tests_enterprise.yml @@ -28,36 +28,21 @@ jobs: submodules: recursive token: ${{ secrets.ELEMENT_BOT_TOKEN }} - - uses: actions/cache@v5 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems- - - name: Setup environment run: source ci_scripts/ci_common.sh && setup_github_actions_environment - name: Configure Enterprise run: swift run pipeline configure-element-pro - - name: SwiftFormat - run: swiftformat --lint . - - name: Run tests - run: bundle exec fastlane unit_tests skip_previews:true - - - name: Zip results # for faster upload - if: failure() - working-directory: fastlane/test_output - run: zip -r UnitTests.zip UnitTests.xcresult - + run: swift run -q tools ci unit-tests --skip-previews + - name: Archive artifacts uses: actions/upload-artifact@v7 # We only care about artefacts if the tests fail if: failure() with: name: Results - path: fastlane/test_output/UnitTests.zip + path: test_output/UnitTests.zip retention-days: 1 if-no-files-found: ignore diff --git a/Tools/Sources/Commands/CI/UnitTests.swift b/Tools/Sources/Commands/CI/UnitTests.swift index 122999469..d29c0cb03 100644 --- a/Tools/Sources/Commands/CI/UnitTests.swift +++ b/Tools/Sources/Commands/CI/UnitTests.swift @@ -12,6 +12,9 @@ struct UnitTests: AsyncParsableCommand { @Option(help: "iOS version for the simulator.") var osVersion = "26.1" + @Flag(help: "Skip preview tests") + var skipPreviews = false + func run() async throws { try await CI.lint() @@ -31,19 +34,21 @@ struct UnitTests: AsyncParsableCommand { logger.error("\n❌ Unit tests failed. \(error)\n") } - // Run preview tests on a smaller device - do { - logger.info("\n🧪 Running preview tests…\n") - try await RunTests.parse([ - "--scheme", "PreviewTests", - "--device", "iPhone SE (3rd generation)", - "--os-version", osVersion, - "--create-simulator-name", "iPhone SE (3rd generation)", - "--create-simulator-type", "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation" - ]).run() - } catch { - failures.append("Preview tests failed: \(error)") - logger.error("\n❌ Preview tests failed.\n") + if !skipPreviews { + // Run preview tests on a smaller device + do { + logger.info("\n🧪 Running preview tests…\n") + try await RunTests.parse([ + "--scheme", "PreviewTests", + "--device", "iPhone SE (3rd generation)", + "--os-version", osVersion, + "--create-simulator-name", "iPhone SE (3rd generation)", + "--create-simulator-type", "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation" + ]).run() + } catch { + failures.append("Preview tests failed: \(error)") + logger.error("\n❌ Preview tests failed.\n") + } } // Zip results (best-effort, useful for CI artifact uploads) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 797927a55..f3c14969e 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -12,39 +12,6 @@ before_all do ENV["SENTRY_LOG_LEVEL"] = "DEBUG" end -lane :unit_tests do |options| - reset_simulator = ENV.key?('CI') - - run_tests( - scheme: "UnitTests", - device: "iPhone 17 (#{simulator_version})", - ensure_devices_found: true, - result_bundle: true, - number_of_retries: 3, - reset_simulator: reset_simulator, - xcodebuild_formatter: "xcbeautify --quiet --is-ci --renderer github-actions" - ) - - if !options[:skip_previews] - create_simulator_if_necessary( - name: "iPhone SE (3rd generation)", - type: "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation" - ) - - run_tests( - scheme: "PreviewTests", - device: "iPhone SE (3rd generation) (#{simulator_version})", - ensure_devices_found: true, - result_bundle: true, - number_of_retries: 3, - reset_simulator: reset_simulator, - xcodebuild_formatter: "xcbeautify --quiet --is-ci --renderer github-actions" - ) - end - - # We use xcresultparser in the workflow to collect coverage from both result bundles. -end - lane :config_production do sh("(cd .. && swift run pipeline update-foss-secrets)") xcodegen(spec: "project.yml")