Class: Fastlane::Actions::UploadToLambdatestAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UploadToLambdatestAction
- Defined in:
- lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb
Constant Summary collapse
- SUPPORTED_EXTENSIONS =
["apk", "ipa", "aab"]
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .default_file_path ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .get_api_endpoint(is_real_device) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
-
.validate_file_path(file_path) ⇒ Object
Validating file_path and extension.
Class Method Details
.authors ⇒ Object
65 66 67 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 65 def self. ["Pawan Rai"] end |
.available_options ⇒ Object
84 85 86 87 88 89 90 91 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 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 84 def self. [ FastlaneCore::ConfigItem.new(key: :lt_username, description: "Lambdatest's username", optional: false, is_string: true, verify_block: proc do |value| UI.user_error!("No LT username given.") if value.to_s.empty? end), FastlaneCore::ConfigItem.new(key: :lt_access_key, description: "Lambdatest's access token", optional: false, is_string: true, verify_block: proc do |value| UI.user_error!("No lt_access_key given.") if value.to_s.empty? end), FastlaneCore::ConfigItem.new(key: :file_path, description: "App file path", optional: true, is_string: true, default_value: default_file_path), FastlaneCore::ConfigItem.new(key: :custom_id, description: "Custom ID", optional: true, is_string: false, default_value: nil), FastlaneCore::ConfigItem.new(key: :app_name, description: "App name", optional: true, is_string: true, default_value: "app"), FastlaneCore::ConfigItem.new(key: :visibility, description: "Visibility", optional: true, is_string: true, default_value: "individual"), FastlaneCore::ConfigItem.new(key: :is_real_device, description: "Real Device or Virtual Device", optional: true, is_string: false, default_value: true, type: Boolean), FastlaneCore::ConfigItem.new(key: :ios_keychain_enabled, description: "Enable iOS Keychain", optional: true, is_string: false, default_value: nil, type: Boolean) ] end |
.default_file_path ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 73 def self.default_file_path platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] if platform == :ios # Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/. return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH] else # Shared value for apk if it was generated by gradle. return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH] end end |
.description ⇒ Object
61 62 63 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 61 def self.description "LambdaTest fastlane plugin for android and ios apps." end |
.details ⇒ Object
69 70 71 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 69 def self.details "Uploads IPA and APK files to Lambdatest for test." end |
.example_code ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 145 def self.example_code [ 'upload_to_lambdatest', 'upload_to_lambdatest( lt_username: ENV["LT_USERNAME"], lt_access_key: ENV["LT_ACCESS_KEY"], file_path: "path_to_app_file", app_name: "android_app" )', 'upload_to_lambdatest( lt_username: ENV["LT_USERNAME"], lt_access_key: ENV["LT_ACCESS_KEY"], file_path: "path_to_app_file", app_name: "android_app", visibility: "team", is_real_device: true )' ] end |
.get_api_endpoint(is_real_device) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 44 def self.get_api_endpoint(is_real_device) if is_real_device "https://manual-api.lambdatest.com/app/upload/realDevice" else "https://manual-api.lambdatest.com/app/upload/virtualDevice" end end |
.is_supported?(platform) ⇒ Boolean
135 136 137 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 135 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.output ⇒ Object
139 140 141 142 143 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 139 def self.output [ ['APP_URL', 'App URL of uploaded app.'] ] end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 14 def self.run(params) lt_username = params[:lt_username] # Required lt_access_key = params[:lt_access_key] # Required file_path = params[:file_path].to_s # Required custom_id = params[:custom_id] # Optional app_name = params[:app_name] #Optional visibility = params[:visibility] #Optional is_real_device = params[:is_real_device] #Optional ios_keychain_enabled = params[:ios_keychain_enabled] # Optional api_endpoint = self.get_api_endpoint(is_real_device) self.validate_file_path(file_path) UI.("Started Uploading app to Lambdatest...") lt_app_url = Helper::LambdatestHelper.upload_file(lt_username, lt_access_key, file_path, api_endpoint, custom_id, app_name, visibility, ios_keychain_enabled) # Set 'APP_URL' environment variable, if app upload was successful. ENV['APP_URL'] = lt_app_url UI.success("Successfully uploaded app " + file_path + " to Lambdatest with app_url : " + lt_app_url + " ✅ ") UI.success("Setting Environment variable APP_URL = " + lt_app_url) # Setting APP_URL in SharedValues, which can be used by other fastlane actions. Actions.lane_context[SharedValues::APP_URL] = lt_app_url end |
.validate_file_path(file_path) ⇒ Object
Validating file_path and extension.
53 54 55 56 57 58 59 |
# File 'lib/fastlane/plugin/lambdatest/actions/upload_to_lambdatest.rb', line 53 def self.validate_file_path(file_path) UI.user_error!("file not found at '#{file_path}' ❌ .") unless File.exist?(file_path) file_path_parts = file_path.split(".") unless file_path_parts.length > 1 && SUPPORTED_EXTENSIONS.include?(file_path_parts.last) UI.user_error!("Invalid file extension, only files with extensions " + SUPPORTED_EXTENSIONS.to_s + " are allowed to be uploaded.") end end |