Class: Fastlane::Actions::AndroidTestlabScriptSwitAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AndroidTestlabScriptSwitAction
- Defined in:
- lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb
Class Method Summary collapse
-
.authors ⇒ Object
Authors.
-
.available_options ⇒ Object
Option val.
- .check_has_property(hash_obj, property) ⇒ Object
-
.description ⇒ Object
Short Detils.
-
.details ⇒ Object
Long Detils.
- .example_code ⇒ Object
-
.is_supported?(platform) ⇒ Boolean
android platform.
- .output ⇒ Object
- .return_value ⇒ Object
-
.run(params) ⇒ Object
actions run.
- .set_default_property(hash_obj, property, default) ⇒ Object
Class Method Details
.authors ⇒ Object
Authors
76 77 78 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 76 def self. ["나비이쁜이"] end |
.available_options ⇒ Object
Option val
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 92 def self. [ # project_id (true) FastlaneCore::ConfigItem.new(key: :project_id, env_name: "PROJECT_ID", description: "Your Firebase project id", is_string: true, optional: false), # gcloud_key_file (true) FastlaneCore::ConfigItem.new(key: :gcloud_key_file, env_name: "GCLOUD_KEY_FILE", description: "File path containing the gcloud auth key. Default: Created from GCLOUD_SERVICE_KEY environment variable", is_string: true, optional: false), # test type (true) FastlaneCore::ConfigItem.new(key: :type, env_name: "TYPE", description: "Test type. Default: robo (robo/instrumentation)", is_string: true, optional: true, default_value: "robo", verify_block: proc do |value| if value != "robo" && value != "instrumentation" UI.user_error!("Unknown test type.") end end), # device (true) FastlaneCore::ConfigItem.new(key: :devices, description: "Devices to test the app on", type: Array, default_value: [{ model: "Nexus6", version: "21", locale: "en_US", orientation: "portrait" }], verify_block: proc do |value| if value.empty? UI.user_error!("Devices cannot be empty") end value.each do |current| if current.class != Hash UI.user_error!("Each device must be represented by a Hash object, " \ "#{current.class} found") end check_has_property(current, :model) check_has_property(current, :version) set_default_property(current, :locale, "en_US") set_default_property(current, :orientation, "portrait") end end), # timeout (ture) FastlaneCore::ConfigItem.new(key: :timeout, env_name: "TIMEOUT", description: "The max time this test execution can run before it is cancelled. Default: 5m (this value must be greater than or equal to 1m)", type: String, optional: false, default_value: "3m"), # apk (true) FastlaneCore::ConfigItem.new(key: :app_apk, env_name: "APP_APK", description: "The path for your android app apk", type: String, optional: false), # test apk (false) FastlaneCore::ConfigItem.new(key: :app_test_apk, env_name: "APP_TEST_APK", description: "The path for your android test apk. Default: empty string", type: String, optional: true, default_value: nil), # orchestrator (false) FastlaneCore::ConfigItem.new(key: :use_orchestrator, env_name: "USE_ORCHESTRATOR", description: "If you use orchestrator when set instrumentation test. Default: false", type: Boolean, optional: true, default_value: false), # gcloud_components_channel (false) FastlaneCore::ConfigItem.new(key: :gcloud_components_channel, env_name: "gcloud_components_channel", description: "If you use beta or alpha components. Default stable (alpha/beta)", is_string: true, optional: true, default_value: "stable"), # console_log_file_name (false) FastlaneCore::ConfigItem.new(key: :console_log_file_name, env_name: "CONSOLE_LOG_FILE_NAME", description: "The filename to save the output results. Default: ./console_output.log", type: String, optional: true, default_value: "./console_output.log"), # extra_options (false) FastlaneCore::ConfigItem.new(key: :extra_options, env_name: "EXTRA_OPTIONS", description: "Extra options that you need to pass to the gcloud command. Default: empty string", type: String, optional: true, default_value: ""), # firebase_test_lab_results_bucket (false) FastlaneCore::ConfigItem.new(key: :firebase_test_lab_results_bucket, env_name: "FIREBASE_TEST_LAB_RESULTS_BUCKET", description: "Name of Firebase Test Lab results bucket", type: String, optional: true, default_value: nil), # firebase_test_lab_results_dir (false) FastlaneCore::ConfigItem.new(key: :firebase_test_lab_results_dir, env_name: "FIREBASE_TEST_LAB_RESULTS_DIR", description: "Name of Firebase Test Lab results directory", type: String, optional: true, default_value: nil), # download_dir (false) FastlaneCore::ConfigItem.new(key: :download_dir, env_name: "DOWNLOAD_DIR", description: "Target directory to download screenshots from firebase", type: String, optional: true, default_value: nil), # robo_script_path (false) FastlaneCore::ConfigItem.new(key: :robo_script_path, env_name: "ROBO_SCRIPT_PATH", description: "Path to Robo script JSON file", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find JSON file at path '#{value}'") unless File.exist?(value) end) ] end |
.check_has_property(hash_obj, property) ⇒ Object
237 238 239 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 237 def self.check_has_property(hash_obj, property) UI.user_error!("Each device must have #{property} property") unless hash_obj.key?(property) end |
.description ⇒ Object
Short Detils
71 72 73 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 71 def self.description "Android Firebase TestLab with Robo Script Test" end |
.details ⇒ Object
Long Detils
87 88 89 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 87 def self.details "This plug-in uses Firebase TestLab. You can also include RoboScript files." end |
.example_code ⇒ Object
257 258 259 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 257 def self.example_code end |
.is_supported?(platform) ⇒ Boolean
android platform
248 249 250 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 248 def self.is_supported?(platform) platform == :android end |
.output ⇒ Object
253 254 255 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 253 def self.output [['console_output.log', 'A console log when running Firebase Test Lab with gcloud']] end |
.return_value ⇒ Object
80 81 82 83 84 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 80 def self.return_value ["Authenticates with Google Cloud.", "Runs tests in Firebase Test Lab.", "Fetches the results to a local directory."].join("\n") end |
.run(params) ⇒ Object
actions run
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 12 def self.run(params) UI.("********************************") UI.("Start Action") UI.("********************************") # Result Bucket & Dir results_bucket = params[:firebase_test_lab_results_bucket] || "#{params[:project_id]}_test_results" results_dir = params[:firebase_test_lab_results_dir] || "firebase_test_result_#{DateTime.now.strftime('%Y-%m-%d-%H:%M:%S')}" # Set Target Project ID Helper.config(params[:project_id]) # Activate service account Helper.authenticate(params[:gcloud_key_file]) # RoboScriptOption robo_script_option = params[:robo_script_path].nil? ? "" : "--robo-script #{params[:robo_script_path]} " # Run Firebase Test Lab # 딜레이 params[:devices].each_with_index do |device, index| # 딜레이 추가 sleep(index * 30) # 각 디바이스별로 1분씩 증가하는 딜레이 end Helper.run_tests(params[:gcloud_components_channel], "--type #{params[:type]} "\ "--app #{params[:app_apk]} "\ "#{"--test #{params[:app_test_apk]} " unless params[:app_test_apk].nil?}"\ "#{"--use-orchestrator " if params[:type] == "instrumentation" && params[:use_orchestrator]}"\ "#{params[:devices].map { |d| "--device model=#{d[:model]},version=#{d[:version]},locale=#{d[:locale]},orientation=#{d[:orientation]} " }.join}"\ "--timeout #{params[:timeout]} "\ "--results-bucket #{results_bucket} "\ "--results-dir #{results_dir} "\ "#{params[:extra_options]} "\ "#{robo_script_option}"\ "--format=json 1>#{Helper.if_need_dir(params[:console_log_file_name])}" ) # Fetch results download_dir = params[:download_dir] if download_dir UI.("Fetch results from Firebase Test Lab results bucket") json.each do |status| axis = status["axis_value"] Helper.if_need_dir("#{download_dir}/#{axis}") Helper.copy_from_gcs("#{results_bucket}/#{results_dirresults_dir}/#{axis}", download_dir) Helper.set_public("#{results_bucket}/#{results_dir}/#{axis}") end end UI.("********************************") UI.("Finish Action") UI.("********************************") end |
.set_default_property(hash_obj, property, default) ⇒ Object
241 242 243 244 245 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb', line 241 def self.set_default_property(hash_obj, property, default) unless hash_obj.key?(property) hash_obj[property] = default end end |