Class: Fastlane::Actions::TestfairyAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::TestfairyAction
- Defined in:
- fastlane/lib/fastlane/actions/testfairy.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
231 232 233 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 231 def self. ["taka0125", "tcurdt"] end |
.available_options ⇒ Object
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 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 135 def self. [ # required FastlaneCore::ConfigItem.new(key: :api_key, env_name: "FL_TESTFAIRY_API_KEY", # The name of the environment variable description: "API Key for TestFairy", # a short description of this parameter sensitive: true, verify_block: proc do |value| UI.user_error!("No API key for TestFairy given, pass using `api_key: 'key'`") unless value.to_s.length > 0 end), FastlaneCore::ConfigItem.new(key: :ipa, env_name: 'TESTFAIRY_IPA_PATH', description: 'Path to your IPA file for iOS or APK for Android', default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], default_value_dynamic: true, verify_block: proc do |value| UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value) end), # optional FastlaneCore::ConfigItem.new(key: :symbols_file, optional: true, env_name: "FL_TESTFAIRY_SYMBOLS_FILE", description: "Symbols mapping file", default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH], default_value_dynamic: true, verify_block: proc do |value| UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :upload_url, env_name: "FL_TESTFAIRY_UPLOAD_URL", # The name of the environment variable description: "API URL for TestFairy", # a short description of this parameter default_value: "https://upload.testfairy.com", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :testers_groups, optional: true, type: Array, short_option: '-g', env_name: "FL_TESTFAIRY_TESTERS_GROUPS", description: "Array of tester groups to be notified", default_value: []), # the default value is an empty list FastlaneCore::ConfigItem.new(key: :metrics, optional: true, type: Array, env_name: "FL_TESTFAIRY_METRICS", description: "Array of metrics to record (cpu,memory,network,phone_signal,gps,battery,mic,wifi)", default_value: []), # max-duration # video # video-quality # video-rate FastlaneCore::ConfigItem.new(key: :comment, optional: true, env_name: "FL_TESTFAIRY_COMMENT", description: "Additional release notes for this upload. This text will be added to email notifications", default_value: 'No comment provided'), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :auto_update, optional: true, env_name: "FL_TESTFAIRY_AUTO_UPDATE", description: "Allows an easy upgrade of all users to the current version. To enable set to 'on'", default_value: 'off'), # not well documented FastlaneCore::ConfigItem.new(key: :notify, optional: true, env_name: "FL_TESTFAIRY_NOTIFY", description: "Send email to testers", default_value: 'off'), FastlaneCore::ConfigItem.new(key: :options, optional: true, type: Array, env_name: "FL_TESTFAIRY_OPTIONS", description: "Array of options (shake,video_only_wifi,anonymous)", default_value: []) ] end |
.category ⇒ Object
221 222 223 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 221 def self.category :beta end |
.description ⇒ Object
127 128 129 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 127 def self.description 'Upload a new build to TestFairy' end |
.details ⇒ Object
131 132 133 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 131 def self.details "You can retrieve your API key on [your settings page](https://free.testfairy.com/settings/)" end |
.example_code ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 211 def self.example_code [ 'testfairy( api_key: "...", ipa: "./ipa_file.ipa", comment: "Build #{lane_context[SharedValues::BUILD_NUMBER]}", )' ] end |
.is_supported?(platform) ⇒ Boolean
235 236 237 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 235 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.output ⇒ Object
225 226 227 228 229 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 225 def self.output [ ['TESTFAIRY_BUILD_URL', 'URL of the newly uploaded build'] ] end |
.run(params) ⇒ Object
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 40 def self.run(params) UI.success('Starting with ipa upload to TestFairy...') metrics_to_client = lambda do |metrics| metrics.map do |metric| case metric when :cpu, :memory, :network, :gps, :battery, :mic, :wifi metric.to_s when :phone_signal 'phone-signal' else UI.user_error!("Unknown metric: #{metric}") end end end = lambda do || .map do |option| case option.to_sym when :shake, :anonymous option.to_s when :video_only_wifi 'video-only-wifi' else UI.user_error!("Unknown option: #{option}") end end end # Rejecting key `upload_url` as we don't need it in options = Hash[params.values.reject do |key, value| key == :upload_url end.map do |key, value| case key when :api_key [key, value] when :ipa [key, value] when :symbols_file [key, value] when :testers_groups [key, value.join(',')] when :metrics [key, metrics_to_client.call(value).join(',')] when :comment [key, value] when :auto_update ['auto-update', value] when :notify [key, value] when :options [key, .call(value).join(',')] else UI.user_error!("Unknown parameter: #{key}") end end] return params[:ipa] if Helper.test? response = self.upload_build(params[:upload_url], params[:ipa], ) if parse_response(response) UI.success("Build URL: #{Actions.lane_context[SharedValues::TESTFAIRY_BUILD_URL]}") UI.success("Build successfully uploaded to TestFairy.") else UI.user_error!("Error when trying to upload ipa to TestFairy") end end |
.upload_build(upload_url, ipa, options) ⇒ Object
8 9 10 11 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 |
# File 'fastlane/lib/fastlane/actions/testfairy.rb', line 8 def self.upload_build(upload_url, ipa, ) require 'faraday' require 'faraday_middleware' UI.success("Uploading to #{upload_url}...") connection = Faraday.new(url: upload_url) do |builder| builder.request(:multipart) builder.request(:url_encoded) builder.request(:retry, max: 3, interval: 5) builder.response(:json, content_type: /\bjson$/) builder.use(FaradayMiddleware::FollowRedirects) builder.adapter(:net_http) end [:file] = Faraday::UploadIO.new(ipa, 'application/octet-stream') if ipa && File.exist?(ipa) symbols_file = .delete(:symbols_file) if symbols_file [:symbols_file] = Faraday::UploadIO.new(symbols_file, 'application/octet-stream') end begin connection.post do |req| req.url("/api/upload/") req.body = end rescue Faraday::Error::TimeoutError UI.crash!("Uploading build to TestFairy timed out ⏳") end end |