fastlane-plugin-maestro_orchestration 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16bca8a824864e18e5022ff562fb194076093be36b157665c8a9b35badbe047e
4
- data.tar.gz: 32fe2d534c4d295245009d6672750f748adfdfce4dcd6ca8864a60e989d19936
3
+ metadata.gz: 8a7c5dbca859567bb493407556a8f57fdcfa6c7ed7adb62283fab7b4eae6d9d2
4
+ data.tar.gz: 92419becfc82aabadf3086bc016937b3562c775e55d93c2af90d4641d6156a66
5
5
  SHA512:
6
- metadata.gz: 8f5c55f53f32f13711091ebb0e989b7475b133e64739ff839966a62239eef3fd8a53d555ee1c64da888c1ba810bed487b9316f61786f56cc4d8564fdcfe03a5c
7
- data.tar.gz: e923fa4cae04e21f78111f8d1dc0083b88a616f3c60a5d1570750087349014608eff5926dec3cc9d9cb734fa7963b13e46cbec082ff4022149e20f4a373bdb0b
6
+ metadata.gz: fea7514fa69e381fb3c7e2498bc317a26f109357b55ba6fabcb80af3fc2205064709665fedbba0661a5d82c1ab9eff6d5d5d1b3db10850ebd3d37e026cfa0a7c
7
+ data.tar.gz: 2b0a06c1410d717711657dccfed51f982dc25e4012ce13afe098673b32427fbfe70b8eb3c68d0f663acef6874d67fefc4129a97bb665ed97ea738fff51f29c0d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # maestro_orchestration plugin
2
2
 
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-maestro_orchestration)
3
+ [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-maestro_orchestration.svg)](https://badge.fury.io/rb/fastlane-plugin-maestro_orchestration)
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -17,7 +17,8 @@ module Fastlane
17
17
  raise "Missing required parameters: #{missing_params.join(', ')}"
18
18
  end
19
19
 
20
- UI.message("--------------\n\nSDK DIR: #{params[:sdk_dir]}\n\n--------------")
20
+ Helper::MaestroOrchestrationHelper.clear_maestro_logs if params[:clear_maestro_logs]
21
+
21
22
  adb = Helper::AdbHelper.new
22
23
 
23
24
  setup_emulator(params)
@@ -67,6 +68,17 @@ module Fastlane
67
68
  UI.message("Waiting for all emulators to stop...")
68
69
  sleep(10)
69
70
 
71
+ # Check if there is an AVD with this name, if so, delete it
72
+ UI.message("Checking if AVD exists with name: #{params[:emulator_name]}...")
73
+ avd_exists = `#{avdmanager.avdmanager_path} list avd`.include?(params[:emulator_name])
74
+
75
+ if avd_exists
76
+ UI.message("AVD found, deleting existing AVD: #{params[:emulator_name]}...")
77
+ avdmanager.delete_avd(name: params[:emulator_name])
78
+ else
79
+ UI.message("No existing AVD found with that name.")
80
+ end
81
+
70
82
  UI.message("Setting up new Android emulator...")
71
83
  avdmanager.create_avd(name: params[:emulator_name], package: params[:emulator_package], device: params[:emulator_device])
72
84
 
@@ -80,8 +92,23 @@ module Fastlane
80
92
  unless booted
81
93
  UI.error("Emulator failed to boot after #{max_retries} attempts. Restarting ADB server...")
82
94
  adb.trigger(command: "kill-server")
95
+
96
+ # Shut down the current emulator, delete it, create a new one, and restart ADB server
97
+ UI.message("Shutting down current emulator and deleting the AVD...")
98
+ adb.trigger(command: "emu kill", serial: "emulator-#{params[:emulator_port]}")
99
+ sleep(5) # Ensure the emulator is killed
100
+ avdmanager.delete_avd(name: params[:emulator_name])
101
+
102
+ UI.message("Creating new AVD...")
103
+ avdmanager.create_avd(name: params[:emulator_name], package: params[:emulator_package], device: params[:emulator_device])
104
+
105
+ UI.message("Restarting ADB server...")
83
106
  adb.trigger(command: "start-server")
84
- UI.message("ADB server restarted. Retrying boot process...")
107
+ UI.message("ADB server restarted. Starting new emulator...")
108
+
109
+ # Start the newly created emulator
110
+ emulator.start_emulator(name: params[:emulator_name], port: params[:emulator_port])
111
+ adb.trigger(command: "wait-for-device", serial: "emulator-#{params[:emulator_port]}")
85
112
 
86
113
  # Retry boot process after restarting ADB server
87
114
  booted = Helper::MaestroOrchestrationHelper.wait_for_emulator_to_boot(adb, max_retries, "emulator-#{params[:emulator_port]}")
@@ -90,7 +117,7 @@ module Fastlane
90
117
  if booted
91
118
  UI.success("Emulator is online and fully booted!")
92
119
  else
93
- UI.error("Emulator failed to boot even after restarting ADB server.")
120
+ UI.error("Emulator failed to boot even after restarting AVD and ADB server.")
94
121
  raise "Failed to boot emulator. Please check emulator logs and configuration."
95
122
  end
96
123
  end
@@ -185,6 +212,14 @@ module Fastlane
185
212
  description: "The path to the Maestro flow YAML file",
186
213
  optional: false,
187
214
  type: String
215
+ ),
216
+ FastlaneCore::ConfigItem.new(
217
+ key: :clear_maestro_logs,
218
+ env_name: "MAESTRO_CLEAR_LOGS",
219
+ description: "If true, clears all previous Maestro logs before running tests",
220
+ type: Boolean,
221
+ default_value: true,
222
+ optional: true
188
223
  )
189
224
  ]
190
225
  end
@@ -16,6 +16,8 @@ module Fastlane
16
16
  raise "Missing required parameters: #{missing_params.join(', ')}"
17
17
  end
18
18
 
19
+ Helper::MaestroOrchestrationHelper.clear_maestro_logs if params[:clear_maestro_logs]
20
+
19
21
  boot_ios_simulator(params)
20
22
  demo_mode(params)
21
23
  build_and_install_ios_app(params)
@@ -154,6 +156,14 @@ module Fastlane
154
156
  description: "The path to the Maestro flows YAML file",
155
157
  optional: false,
156
158
  type: String
159
+ ),
160
+ FastlaneCore::ConfigItem.new(
161
+ key: :clear_maestro_logs,
162
+ env_name: "MAESTRO_CLEAR_LOGS",
163
+ description: "If true, clears all previous Maestro logs before running tests",
164
+ type: Boolean,
165
+ default_value: true,
166
+ optional: true
157
167
  )
158
168
  ]
159
169
  end
@@ -40,6 +40,50 @@ module Fastlane
40
40
 
41
41
  booted
42
42
  end
43
+
44
+ def self.clear_maestro_logs
45
+ logs_path = File.expand_path("~/.maestro/tests")
46
+
47
+ unless Dir.exist?(logs_path)
48
+ UI.message("No Maestro logs directory found.")
49
+ return
50
+ end
51
+
52
+ UI.message("Clearing previous Maestro logs using")
53
+
54
+ # Handle file and directory removal separately
55
+ Dir.glob(File.join(logs_path, "*")).each do |path|
56
+ if File.directory?(path)
57
+ clear_directory(path)
58
+ else
59
+ delete_file(path)
60
+ end
61
+ end
62
+
63
+ UI.success("Previous Maestro logs cleared.")
64
+ end
65
+
66
+ def self.clear_directory(directory_path)
67
+ Dir.glob(File.join(directory_path, "**", "*")).reverse_each do |subpath|
68
+ if File.directory?(subpath)
69
+ Dir.rmdir(subpath)
70
+ else
71
+ File.delete(subpath)
72
+ end
73
+ rescue StandardError => e
74
+ UI.error("Error removing #{subpath}: #{e.message}")
75
+ end
76
+
77
+ Dir.rmdir(directory_path)
78
+ rescue StandardError => e
79
+ UI.error("Error removing directory #{directory_path}: #{e.message}")
80
+ end
81
+
82
+ def self.delete_file(file_path)
83
+ File.delete(file_path)
84
+ rescue StandardError => e
85
+ UI.error("Error removing file #{file_path}: #{e.message}")
86
+ end
43
87
  end
44
88
 
45
89
  class AvdHelper
@@ -87,6 +131,18 @@ module Fastlane
87
131
 
88
132
  trigger(command: command)
89
133
  end
134
+
135
+ # Delete an existing AVD
136
+ def delete_avd(name:)
137
+ raise "AVD name is required" if name.nil? || name.empty?
138
+
139
+ command = [
140
+ "delete avd",
141
+ "-n #{name.shellescape}"
142
+ ].join(" ")
143
+
144
+ trigger(command: command)
145
+ end
90
146
  end
91
147
 
92
148
  class EmulatorHelper
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module MaestroOrchestration
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-maestro_orchestration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nemanja Risteski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-31 00:00:00.000000000 Z
10
+ date: 2025-02-04 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: fastlane-plugin-android_emulator
@@ -30,7 +29,6 @@ dependencies:
30
29
  - - ">="
31
30
  - !ruby/object:Gem::Version
32
31
  version: 1.2.1
33
- description:
34
32
  email: nemanja.risteski@sourcetoad.com
35
33
  executables: []
36
34
  extensions: []
@@ -50,7 +48,6 @@ licenses:
50
48
  - MIT
51
49
  metadata:
52
50
  rubygems_mfa_required: 'true'
53
- post_install_message:
54
51
  rdoc_options: []
55
52
  require_paths:
56
53
  - lib
@@ -65,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
62
  - !ruby/object:Gem::Version
66
63
  version: '0'
67
64
  requirements: []
68
- rubygems_version: 3.1.6
69
- signing_key:
65
+ rubygems_version: 3.6.2
70
66
  specification_version: 4
71
67
  summary: Plugin for maestro testing framework.
72
68
  test_files: []