From 02de768f2e76cc206d4e3a430b624e9a49deb601 Mon Sep 17 00:00:00 2001 From: Nemanja Risteski Date: Thu, 19 Dec 2024 15:06:17 -0500 Subject: [PATCH] don't create debug builds --- .../maestro_orchestration_android_action.rb | 27 ++++++++++++------ .../maestro_orchestration_ios_action.rb | 28 ++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb index eda07f8..1b80845 100644 --- a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb +++ b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_android_action.rb @@ -18,18 +18,30 @@ def self.run(params) end UI.message("Emualtor_device: #{params[:emulator_device]}") + adb = "#{params[:sdk_dir]}/platform-tools/adb" setup_emulator(params) sleep(5) demo_mode(params) - build_and_install_android_app(params) + install_android_app(params) UI.message("Running Maestro tests on Android...") - sh("maestro test #{params[:maestro_flow_file]}") - UI.success("Finished Maestro tests on Android.") + devices = `adb devices`.split("\n").drop(1) + if devices.empty? + UI.message("No running emulators found.") + else + sleep(2) + UI.message("Devices: #{devices}") + devices.each do |device| + serial = device.split("\t").first # Extract the serial number + if serial.include?("emulator") # Check if it's an emulator + sh("maestro --device #{serial} test #{params[:maestro_flow_file]}") + UI.success("Finished Maestro tests on Android.") + end + end + end UI.message("Exit demo mode and kill Android emulator...") - adb = "#{params[:sdk_dir]}/platform-tools/adb" system("#{adb} shell am broadcast -a com.android.systemui.demo -e command exit") sleep(3) system("#{adb} emu kill") @@ -83,11 +95,10 @@ def self.demo_mode(params) sh("#{params[:sdk_dir]}/platform-tools/adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4") end - def self.build_and_install_android_app(params) - UI.message("Building Android app...") - other_action.gradle(task: "assembleDebug") + def self.install_android_app(params) + UI.message("Installing Android app...") - apk_path = Dir["app/build/outputs/apk/debug/app-debug.apk"].first + apk_path = Dir["app/build/outputs/apk/release/app-release.apk"].first if apk_path.nil? UI.user_error!("Error: APK file not found in build outputs.") diff --git a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_ios_action.rb b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_ios_action.rb index ebc9a53..58caa0e 100644 --- a/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_ios_action.rb +++ b/lib/fastlane/plugin/maestro_orchestration/actions/maestro_orchestration_ios_action.rb @@ -17,10 +17,14 @@ def self.run(params) end boot_ios_simulator(params) - build_and_install_ios_app(params) + install_ios_app(params) UI.message("Running Maestro tests on iOS...") - `maestro test #{params[:maestro_flow_file]}` + + simulators_list = `xcrun simctl list devices`.strip + device_status = simulators_list.match(/#{Regexp.quote(params[:simulator_name])}.*\(([^)]+)\) \(([^)]+)\)/) + device_id = device_status[1] + `maestro --device #{device_id} test #{params[:maestro_flow_file]}` UI.success("Finished Maestro tests on iOS.") UI.message("Killing iOS simulator...") @@ -64,25 +68,9 @@ def self.boot_ios_simulator(params) end end - def self.build_and_install_ios_app(params) - UI.message("Building iOS app with scheme: #{params[:scheme]}") - other_action.gym( - workspace: params[:workspace], - scheme: params[:scheme], - destination: "platform=iOS Simulator,name=#{params[:simulator_name]}", - configuration: "Debug", - clean: true, - sdk: "iphonesimulator", - build_path: "./build", - skip_archive: true, - skip_package_ipa: true, - include_symbols: false, - include_bitcode: false, - xcargs: "-UseModernBuildSystem=YES" - ) - + def self.install_ios_app(params) derived_data_path = File.expand_path("~/Library/Developer/Xcode/DerivedData") - app_path = Dir["#{derived_data_path}/**/#{params[:scheme]}.app"].first + app_path = Dir["#{derived_data_path}/**/Release-iphonesimulator/#{params[:scheme]}.app"].first if app_path.nil? UI.user_error!("Error: .app file not found in DerivedData.")