fastlane-plugin-waldo 1.2.0 → 1.6.0

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
- SHA1:
3
- metadata.gz: f32ec479ee63b1ab4f8927cb26ee7b49562c5ea8
4
- data.tar.gz: 42c8849320d5ff492788e542866c71b45a9b3773
2
+ SHA256:
3
+ metadata.gz: 930bf4de096a32ef717f5f4e9a488cf85e13ec1a8c58058ace10ebf583948302
4
+ data.tar.gz: 1d044beebccaaf38e426370990f046fd3fbc59d08d657bccfa8321cf757fa733
5
5
  SHA512:
6
- metadata.gz: 49ea9aef680aa191a35d3b3a6a0bdf2f9ce809ffc4ce69e373e2b0d8ca2462547b1a806a92ca0669528a3c9ff4c565251f81d688ebb8c1ec6592339368d0a361
7
- data.tar.gz: 2bd510d3f86f923f9ac982b26e90032e678f4aaed3bff69f4f9413c3f628cdaca7c2c4898224dbaf0cf31382d23465b482b9097637354b8a17465537f79762e4
6
+ metadata.gz: df074478d0982a2851bc5d2e936859d5843735002dfb505bd12c60a3e5db091618894db725d0734a23540b4106ff254134534b42e2a3f003301429bd4fd52cb2
7
+ data.tar.gz: 533d8fae7a307686e93af2908bc11d3e858f8b6f8cd7ef1136e97851873e425103bf7a85015ce455989685147d7222075289cfe82e724fa8e3762bf54e61e2c9
@@ -2,34 +2,26 @@ module Fastlane
2
2
  module Actions
3
3
  class WaldoAction < Action
4
4
  def self.run(params)
5
- params.values # validate all inputs
5
+ mparams = Helper::WaldoHelper.filter_parameters(params)
6
6
 
7
- platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
7
+ return unless Helper::WaldoHelper.validate_parameters(mparams)
8
8
 
9
- if platform == :android
10
- UI.error("You must pass an APK path to the Waldo action") and return unless params[:apk_path]
11
- elsif platform == :ios || platform.nil?
12
- UI.error("You must pass an IPA or app path to the Waldo action") and return unless params[:ipa_path] || params[:app_path]
13
- end
14
-
15
- UI.error("You must pass an upload token to the Waldo action") and return unless params[:upload_token]
16
-
17
- FastlaneCore::PrintTable.print_values(config: params,
9
+ FastlaneCore::PrintTable.print_values(config: mparams,
18
10
  title: "Summary for waldo #{Fastlane::Waldo::VERSION.to_s}")
19
11
 
20
- Helper::WaldoHelper.upload_build(params)
12
+ Helper::WaldoHelper.upload_build
13
+ Helper::WaldoHelper.upload_symbols
21
14
  end
22
15
 
23
16
  def self.authors
24
- ["eBardX"]
17
+ ['eBardX']
25
18
  end
26
19
 
27
20
  def self.available_options
28
- platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
29
-
30
- if platform == :android
31
- apk_path_default = Dir["*.apk"].last || Dir[File.join("app", "build", "outputs", "apk", "app-release.apk")].last
32
- elsif platform == :ios || platform.nil?
21
+ case Helper::WaldoHelper.get_platform
22
+ when :android
23
+ apk_path_default = Dir["*.apk"].last || Dir[File.join('app', 'build', 'outputs', 'apk', 'app-release.apk')].last
24
+ when :ios
33
25
  app_path_default = Dir["*.app"].sort_by { |x| File.mtime(x) }.last
34
26
  ipa_path_default = Dir["*.ipa"].sort_by { |x| File.mtime(x) }.last
35
27
  end
@@ -37,50 +29,45 @@ module Fastlane
37
29
  [
38
30
  # iOS-specific
39
31
  FastlaneCore::ConfigItem.new(key: :app_path,
40
- env_name: "WALDO_APP_PATH",
41
- description: "Path to your app file",
32
+ env_name: 'WALDO_APP_PATH',
33
+ description: 'Path to your app file',
42
34
  default_value: app_path_default,
43
35
  default_value_dynamic: true,
44
- optional: true,
45
- verify_block: proc do |value|
46
- UI.error("Unable to find app file at path '#{value.to_s}'") unless File.exist?(value)
47
- end),
36
+ optional: true),
48
37
  FastlaneCore::ConfigItem.new(key: :ipa_path,
49
- env_name: "WALDO_IPA_PATH",
50
- description: "Path to your IPA file (optional if you use the _gym_ or _xcodebuild_ action)",
38
+ env_name: 'WALDO_IPA_PATH',
39
+ description: 'Path to your IPA file (optional if you use the _gym_ or _xcodebuild_ action)',
51
40
  default_value: Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH] || ipa_path_default,
52
41
  default_value_dynamic: true,
42
+ optional: true),
43
+ FastlaneCore::ConfigItem.new(key: :dsym_path,
44
+ env_name: 'WALDO_DSYM_PATH',
45
+ description: 'Path to your dSYM file(s)',
46
+ optional: true),
47
+ FastlaneCore::ConfigItem.new(key: :include_symbols,
48
+ env_name: 'WALDO_INCLUDE_SYMBOLS',
49
+ description: 'Include symbols in upload if true',
53
50
  optional: true,
54
- verify_block: proc do |value|
55
- UI.error("Unable to find IPA file at path '#{value.to_s}'") unless File.exist?(value)
56
- end),
51
+ default_value: false,
52
+ is_string: false),
57
53
  # Android-specific
58
54
  FastlaneCore::ConfigItem.new(key: :apk_path,
59
- env_name: "WALDO_APK_PATH",
60
- description: "Path to your APK file (optional if you use the _gradle_ action)",
55
+ env_name: 'WALDO_APK_PATH',
56
+ description: 'Path to your APK file (optional if you use the _gradle_ action)',
61
57
  default_value: Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH] || apk_path_default,
62
58
  default_value_dynamic: true,
63
- optional: true,
64
- verify_block: proc do |value|
65
- UI.error("Unable to find APK file at path '#{value.to_s}'") unless File.exist?(value)
66
- end),
59
+ optional: true),
67
60
  # General
68
61
  FastlaneCore::ConfigItem.new(key: :upload_token,
69
- env_name: "WALDO_UPLOAD_TOKEN",
70
- description: "Waldo upload token",
62
+ env_name: 'WALDO_UPLOAD_TOKEN',
63
+ description: 'Waldo upload token',
71
64
  optional: true,
72
- sensitive: true,
73
- verify_block: proc do |value|
74
- UI.error("No upload token for Waldo given, pass using `upload_token: 'value'`") unless value && !value.empty?
75
- end),
65
+ sensitive: true),
76
66
  FastlaneCore::ConfigItem.new(key: :variant_name,
77
- env_name: "WALDO_VARIANT_NAME",
78
- description: "Waldo variant name",
67
+ env_name: 'WALDO_VARIANT_NAME',
68
+ description: 'Waldo variant name',
79
69
  optional: true,
80
- sensitive: true,
81
- verify_block: proc do |value|
82
- UI.error("No variant name for Waldo given, pass using `variant_name: 'value'`") unless value && !value.empty?
83
- end)
70
+ sensitive: true)
84
71
  ]
85
72
  end
86
73
 
@@ -89,27 +76,27 @@ module Fastlane
89
76
  end
90
77
 
91
78
  def self.description
92
- "Upload a new build to [Waldo](https://www.waldo.io)"
79
+ 'Upload a new build to [Waldo](https://www.waldo.io)'
93
80
  end
94
81
 
95
82
  def self.example_code
96
83
  [
97
84
  'waldo',
98
- 'waldo(
99
- upload_token: "..."
100
- )',
101
- 'waldo(
102
- apk_path: "./YourApp.apk",
103
- upload_token: "..."
104
- )',
105
- 'waldo(
106
- ipa_path: "./YourApp.ipa",
107
- upload_token: "..."
108
- )',
109
- 'waldo(
110
- app_path: "./YourApp.app",
111
- upload_token: "..."
112
- )'
85
+ "waldo(
86
+ upload_token: '...'
87
+ )",
88
+ "waldo(
89
+ apk_path: './YourApp.apk',
90
+ upload_token: '...'
91
+ )",
92
+ "waldo(
93
+ ipa_path: './YourApp.ipa',
94
+ upload_token: '...'
95
+ )",
96
+ "waldo(
97
+ app_path: './YourApp.app',
98
+ upload_token: '...'
99
+ )"
113
100
  ]
114
101
  end
115
102
 
@@ -1,65 +1,229 @@
1
+ require 'base64'
2
+ require 'json'
1
3
  require 'net/http'
2
4
 
3
5
  module Fastlane
4
6
  module Helper
5
7
  class WaldoHelper
6
- def self.upload_build(params)
7
- UI.success('Uploading the build to Waldo. This could take a while…')
8
+ def self.convert_commit(sha)
9
+ puts "Entering convert_commit(#{sha})"
8
10
 
9
- begin
10
- variant_name = params[:variant_name] || Actions.lane_context[Actions::SharedValues::GRADLE_BUILD_TYPE]
11
- uri_string = 'https://api.waldo.io/versions'
11
+ prefix = 'remotes/origin/'
12
+ pfxlen = prefix.length
12
13
 
13
- uri_string += "?variantName=#{variant_name}" if variant_name
14
+ full_name = get_git_commit_name(sha)
14
15
 
15
- uri = URI(uri_string)
16
+ if full_name.start_with?(prefix)
17
+ abbr_name = full_name[pfxlen..-1]
18
+ else
19
+ abbr_name = "local:#{full_name}"
20
+ end
16
21
 
17
- request = build_request(uri, params)
22
+ %("#{sha[0..7]}-#{abbr_name}")
23
+ end
18
24
 
19
- dump_request(request) if FastlaneCore::Globals.verbose?
25
+ def self.dump_request(request)
26
+ len = request.body ? request.body.length : 0
20
27
 
21
- Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
22
- http.read_timeout = 120 # 2 minutes
28
+ puts "Request: #{request.method} #{request.path} (#{len} bytes)"
23
29
 
24
- parse_response(http.request(request))
25
- end
26
- rescue Net::ReadTimeout
27
- UI.error("Upload to Waldo timed out!")
28
- rescue => exc
29
- UI.error("Something went wrong uploading to Waldo: #{exc.inspect.to_s}")
30
- ensure
31
- request.body_stream.close if request && request.body_stream
30
+ request.each_capitalized do |key, value|
31
+ puts " #{key}: #{value}"
32
32
  end
33
+
34
+ puts '-------'
33
35
  end
34
36
 
35
- def self.build_request(uri, params)
36
- platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
37
+ def self.dump_response(response)
38
+ puts "Response: #{response.code} #{response.message} (#{response.body.length} bytes)"
39
+
40
+ response.each_capitalized do |key, value|
41
+ puts " #{key}: #{value}"
42
+ end
43
+
44
+ puts "#{response.body}"
45
+ end
46
+
47
+ def self.filter_parameters(in_params)
48
+ out_params = {}
49
+
50
+ apk_path = in_params[:apk_path]
51
+ app_path = in_params[:app_path]
52
+ dsym_path = in_params[:dsym_path]
53
+ include_symbols = in_params[:include_symbols]
54
+ ipa_path = in_params[:ipa_path]
55
+ upload_token = in_params[:upload_token]
56
+ variant_name = in_params[:variant_name]
57
+
58
+ apk_path.gsub!("\\ ", ' ') if apk_path
59
+ app_path.gsub!("\\ ", ' ') if app_path
60
+ dsym_path.gsub!("\\ ", ' ') if dsym_path
61
+ ipa_path.gsub!("\\ ", ' ') if ipa_path
62
+
63
+ out_params[:apk_path] = apk_path if apk_path
64
+
65
+ if app_path && ipa_path
66
+ if !File.exist?(app_path)
67
+ out_params[:ipa_path] = ipa_path
68
+
69
+ app_path = nil
70
+ elsif !File.exist?(ipa_path)
71
+ out_params[:app_path] = app_path
37
72
 
38
- if platform == :android
39
- body_path = params[:apk_path]
40
- flavor = "Android"
41
- elsif platform == :ios || platform.nil?
42
- if params[:app_path]
43
- app_dir_path = File.dirname(params[:app_path])
44
- app_name = File.basename(params[:app_path])
45
- body_path = File.join(Dir.tmpdir, "#{app_name}.zip")
73
+ ipa_path = nil
74
+ elsif File.mtime(app_path) < File.mtime(ipa_path)
75
+ out_params[:ipa_path] = ipa_path
46
76
 
47
- Actions.sh(%(cd "#{app_dir_path}" && zip -qry "#{body_path}" "#{app_name}"))
77
+ app_path = nil
48
78
  else
49
- body_path = params[:ipa_path]
79
+ out_params[:app_path] = app_path
80
+
81
+ ipa_path = nil
82
+ end
83
+ else
84
+ out_params[:app_path] = app_path if app_path
85
+ out_params[:ipa_path] = ipa_path if ipa_path
86
+ end
87
+
88
+ if app_path
89
+ if include_symbols
90
+ if !dsym_path
91
+ tmp_path = "#{app_path}.dSYM.zip"
92
+ dsym_path = tmp_path if File.exist?(tmp_path)
93
+ end
94
+
95
+ if !dsym_path
96
+ tmp_path = "#{app_path}.dSYM"
97
+ dsym_path = tmp_path if File.exist?(tmp_path)
98
+ end
99
+ end
100
+
101
+ out_params[:dsym_path] = dsym_path if dsym_path
102
+ else
103
+ out_params[:dsym_path] = dsym_path if dsym_path && ipa_path
104
+ end
105
+
106
+ out_params[:upload_token] = upload_token if upload_token && !upload_token.empty?
107
+ out_params[:variant_name] = variant_name if variant_name
108
+
109
+ out_params
110
+ end
111
+
112
+ def self.get_authorization
113
+ "Upload-Token #{@upload_token}"
114
+ end
115
+
116
+ def self.get_flavor
117
+ case get_platform
118
+ when :android
119
+ "Android"
120
+ when :ios
121
+ "iOS"
122
+ else
123
+ "unknown"
124
+ end
125
+ end
126
+
127
+ def self.get_git_commit_name(sha)
128
+ cmd = %(git name-rev --exclude='tags/*' --name-only "#{sha}")
129
+
130
+ puts "Calling: #{cmd}" if FastlaneCore::Globals.verbose?
131
+
132
+ result = Actions.sh(cmd, log: false).chomp
133
+
134
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
135
+
136
+ result
137
+ end
138
+
139
+ def self.get_git_commits
140
+ cmd = %(git log --format=%H -50)
141
+
142
+ result = Actions.sh(cmd, log: false).chomp
143
+
144
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
145
+
146
+ result.split(' ')
147
+ end
148
+
149
+ def self.get_history
150
+ history = get_git_commits
151
+
152
+ return '' unless !history.empty?
153
+
154
+ history = history.map { |sha| convert_commit(sha) }
155
+
156
+ Base64.strict_encode64("[#{history.join(',')}]")
157
+ end
158
+
159
+ def self.get_platform
160
+ Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] || :ios
161
+ end
162
+
163
+ def self.get_user_agent
164
+ "Waldo fastlane/#{get_flavor} v#{Fastlane::Waldo::VERSION}"
165
+ end
166
+
167
+ def self.handle_error(message)
168
+ UI.error(message)
169
+
170
+ UI.error('No token for error report upload to Waldo!') unless @upload_token
171
+
172
+ upload_error(message) if @upload_token
173
+ end
174
+
175
+ def self.has_git_command?
176
+ cmd = %(which git)
177
+
178
+ result = Actions.sh(cmd, log: false).chomp
179
+
180
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
181
+
182
+ !result.empty?
183
+ end
184
+
185
+ def self.is_git_repository?
186
+ cmd = %(git rev-parse)
187
+
188
+ result = true
189
+
190
+ Actions.sh(cmd,
191
+ log: false,
192
+ error_callback: ->(ignore) { result = false }
193
+ ).chomp
194
+
195
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
196
+
197
+ result
198
+ end
199
+
200
+ def self.make_build_request(uri)
201
+ if @apk_path
202
+ body_path = @apk_path
203
+ elsif @ipa_path
204
+ body_path = @ipa_path
205
+ else
206
+ app_basename = File.basename(@app_path)
207
+ app_dirname = File.dirname(@app_path)
208
+
209
+ body_path = File.join(Dir.tmpdir, "#{app_basename}.zip")
210
+
211
+ unless zip(src_path: app_basename,
212
+ zip_path: body_path,
213
+ cd_path: app_dirname)
214
+ return nil
50
215
  end
51
- flavor = "iOS"
52
216
  end
53
217
 
54
218
  request = Net::HTTP::Post.new(uri.request_uri)
55
219
 
56
- request['Authorization'] = "Upload-Token #{params[:upload_token]}"
220
+ request['Authorization'] = get_authorization
57
221
  request['Transfer-Encoding'] = 'chunked'
58
- request['User-Agent'] = "Waldo fastlane/#{flavor} v#{Fastlane::Waldo::VERSION}"
222
+ request['User-Agent'] = get_user_agent
59
223
 
60
224
  request.body_stream = WaldoReadIO.new(body_path)
61
225
 
62
- if params[:app_path]
226
+ if @app_path
63
227
  request.content_type = 'application/zip'
64
228
  else
65
229
  request.content_type = 'application/octet-stream'
@@ -68,39 +232,324 @@ module Fastlane
68
232
  request
69
233
  end
70
234
 
71
- def self.dump_request(request)
72
- len = request.body ? request.body.length : 0
235
+ def self.make_build_uri
236
+ if !has_git_command?
237
+ history_error = "noGitCommandFound"
238
+ elsif !is_git_repository?
239
+ history_error = "notGitRepository"
240
+ else
241
+ history = get_history
242
+ end
73
243
 
74
- puts "Request: #{request.method} #{request.path} (#{len} bytes)"
244
+ query = ''
75
245
 
76
- request.each_capitalized do |key, value|
77
- puts " #{key}: #{value}"
246
+ if history
247
+ query += "&history=#{history}"
248
+ elsif history_error
249
+ query += "&historyError=#{history_error}"
78
250
  end
79
251
 
80
- puts "-------"
252
+ query += "&variantName=#{@variant_name}" if @variant_name
253
+
254
+ uri_string = 'https://api.waldo.io/versions'
255
+
256
+ uri_string += "?#{query[1..-1]}" if !query.empty?
257
+
258
+ URI(uri_string)
81
259
  end
82
260
 
83
- def self.dump_response(response)
84
- puts "Response: #{response.code} #{response.message} (#{response.body.length} bytes)"
261
+ def self.make_error_request(uri, message)
262
+ request = Net::HTTP::Post.new(uri.request_uri)
85
263
 
86
- response.each_capitalized do |key, value|
87
- puts " #{key}: #{value}"
264
+ request['Authorization'] = get_authorization
265
+ request['User-Agent'] = get_user_agent
266
+
267
+ request.body = { "message": message }.to_json
268
+ request.content_type = 'application/json'
269
+
270
+ request
271
+ end
272
+
273
+ def self.make_error_uri
274
+ uri_string = 'https://api.waldo.io/uploadError'
275
+
276
+ URI(uri_string)
277
+ end
278
+
279
+ def self.make_symbols_request(uri)
280
+ if File.file?(@dsym_path)
281
+ body_path = @dsym_path
282
+ else
283
+ dsym_basename = File.basename(@dsym_path)
284
+ dsym_dirname = File.dirname(@dsym_path)
285
+
286
+ body_path = File.join(Dir.tmpdir, "#{dsym_basename}.zip")
287
+
288
+ unless zip(src_path: dsym_basename,
289
+ zip_path: body_path,
290
+ cd_path: dsym_dirname)
291
+ return nil
292
+ end
88
293
  end
89
294
 
90
- puts "#{response.body}"
295
+ request = Net::HTTP::Post.new(uri.request_uri)
296
+
297
+ request['Authorization'] = get_authorization
298
+ request['Transfer-Encoding'] = 'chunked'
299
+ request['User-Agent'] = get_user_agent
300
+
301
+ request.body_stream = WaldoReadIO.new(body_path)
302
+ request.content_type = 'application/zip'
303
+
304
+ request
305
+ end
306
+
307
+ def self.make_symbols_uri
308
+ uri_string = 'https://api.waldo.io/versions/'
309
+
310
+ uri_string += @build_upload_id
311
+ uri_string += '/symbols'
312
+
313
+ URI(uri_string)
91
314
  end
92
315
 
93
- def self.parse_response(response)
316
+ def self.parse_build_response(response)
94
317
  dump_response(response) if FastlaneCore::Globals.verbose?
95
318
 
96
319
  case response.code.to_i
97
320
  when 200..299
98
321
  UI.success('Build successfully uploaded to Waldo!')
99
322
  when 401
100
- UI.error("Upload token is invalid or missing!")
323
+ handle_error('Token is invalid or missing for build upload to Waldo!')
324
+ else
325
+ handle_error("Build failed to upload to Waldo: #{response.code} #{response.message}")
326
+ end
327
+
328
+ result = JSON.parse(response.body)
329
+
330
+ @build_upload_id = result["id"]
331
+ end
332
+
333
+ def self.parse_error_response(response)
334
+ dump_response(response) if FastlaneCore::Globals.verbose?
335
+
336
+ case response.code.to_i
337
+ when 200..299
338
+ UI.success('Error report successfully uploaded to Waldo!')
339
+ when 401
340
+ UI.error('Token is invalid or missing for error report upload to Waldo!')
341
+ else
342
+ UI.error("Error report failed to upload to Waldo: #{response.code} #{response.message}")
343
+ end
344
+ end
345
+
346
+ def self.parse_symbols_response(response)
347
+ dump_response(response) if FastlaneCore::Globals.verbose?
348
+
349
+ case response.code.to_i
350
+ when 200..299
351
+ UI.success('Symbols successfully uploaded to Waldo!')
352
+ when 401
353
+ UI.error('Token is invalid or missing for symbols upload to Waldo!')
354
+ else
355
+ UI.error("Symbols failed to upload to Waldo: #{response.code} #{response.message}")
356
+ end
357
+ end
358
+
359
+ def self.upload_build
360
+ begin
361
+ @variant_name ||= Actions.lane_context[Actions::SharedValues::GRADLE_BUILD_TYPE]
362
+
363
+ uri = make_build_uri
364
+
365
+ request = make_build_request(uri)
366
+
367
+ return unless request
368
+
369
+ UI.success('Uploading build to Waldo')
370
+
371
+ dump_request(request) if FastlaneCore::Globals.verbose?
372
+
373
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
374
+ http.read_timeout = 120 # 2 minutes
375
+
376
+ parse_build_response(http.request(request))
377
+ end
378
+ rescue Net::ReadTimeout => exc
379
+ handle_error('Build upload to Waldo timed out!')
380
+ rescue => exc
381
+ handle_error("Something went wrong uploading build to Waldo: #{exc.inspect.to_s}")
382
+ ensure
383
+ request.body_stream.close if request && request.body_stream
384
+ end
385
+ end
386
+
387
+ def self.upload_error(message)
388
+ begin
389
+ uri = make_error_uri
390
+
391
+ request = make_error_request(uri, message)
392
+
393
+ UI.error('Uploading error report to Waldo')
394
+
395
+ dump_request(request) if FastlaneCore::Globals.verbose?
396
+
397
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
398
+ http.read_timeout = 30 # seconds
399
+
400
+ parse_error_response(http.request(request))
401
+ end
402
+ rescue Net::ReadTimeout => exc
403
+ UI.error('Error report upload to Waldo timed out!')
404
+ rescue => exc
405
+ UI.error("Something went wrong uploading error report to Waldo: #{exc.inspect.to_s}")
406
+ end
407
+ end
408
+
409
+ def self.upload_symbols
410
+ begin
411
+ return unless @dsym_path
412
+
413
+ uri = make_symbols_uri
414
+
415
+ request = make_symbols_request(uri)
416
+
417
+ return unless request
418
+
419
+ UI.success('Uploading symbols to Waldo')
420
+
421
+ dump_request(request) if FastlaneCore::Globals.verbose?
422
+
423
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
424
+ http.read_timeout = 120 # 2 minutes
425
+
426
+ parse_symbols_response(http.request(request))
427
+ end
428
+ rescue Net::ReadTimeout => exc
429
+ handle_error('Symbols upload to Waldo timed out!')
430
+ rescue => exc
431
+ handle_error("Something went wrong uploading symbols to Waldo: #{exc.inspect.to_s}")
432
+ ensure
433
+ request.body_stream.close if request && request.body_stream
434
+ end
435
+ end
436
+
437
+ def self.validate_parameters(params)
438
+ @apk_path = params[:apk_path]
439
+ @app_path = params[:app_path]
440
+ @dsym_path = params[:dsym_path]
441
+ @ipa_path = params[:ipa_path]
442
+ @upload_token = params[:upload_token]
443
+ @variant_name = params[:variant_name]
444
+
445
+ unless @upload_token
446
+ handle_error('You must pass a nonempty upload token to the Waldo action')
447
+
448
+ return false
449
+ end
450
+
451
+ case get_platform
452
+ when :android
453
+ unless @apk_path
454
+ handle_error('You must pass an APK path to the Waldo action')
455
+
456
+ return false
457
+ end
458
+
459
+ unless File.exist?(@apk_path)
460
+ handle_error("Unable to find APK at path '#{@apk_path.to_s}'")
461
+
462
+ return false
463
+ end
464
+
465
+ unless File.file?(@apk_path) && File.readable?(@apk_path)
466
+ handle_error("Unable to read APK at path '#{@apk_path.to_s}'")
467
+
468
+ return false
469
+ end
470
+ when :ios
471
+ unless @app_path || @ipa_path
472
+ handle_error('You must pass an IPA or app path to the Waldo action')
473
+
474
+ return false
475
+ end
476
+
477
+ if @app_path
478
+ unless File.exist?(@app_path)
479
+ handle_error("Unable to find app at path '#{@app_path.to_s}'")
480
+
481
+ return false
482
+ end
483
+
484
+ unless File.directory?(@app_path) && File.readable?(@app_path)
485
+ handle_error("Unable to read app at path '#{@app_path.to_s}'")
486
+
487
+ return false
488
+ end
489
+ elsif @ipa_path
490
+ unless File.exist?(@ipa_path)
491
+ handle_error("Unable to find IPA at path '#{@ipa_path.to_s}'")
492
+
493
+ return false
494
+ end
495
+
496
+ unless File.file?(@ipa_path) && File.readable?(@ipa_path)
497
+ handle_error("Unable to read IPA at path '#{@ipa_path.to_s}'")
498
+
499
+ return false
500
+ end
501
+ end
502
+
503
+ if @dsym_path
504
+ unless File.exist?(@dsym_path)
505
+ handle_error("Unable to find symbols at path '#{@dsym_path.to_s}'")
506
+
507
+ return false
508
+ end
509
+
510
+ unless (File.directory?(@dsym_path) || File.file?(@dsym_path)) && File.readable?(@dsym_path)
511
+ handle_error("Unable to read symbols at path '#{@dsym_path.to_s}'")
512
+
513
+ return false
514
+ end
515
+ end
101
516
  else
102
- UI.error("Build failed to upload to Waldo: #{response.code} #{response.message}")
517
+ handle_error("Unsupported platform: '#{get_platform.to_s}'")
518
+
519
+ return false
520
+ end
521
+
522
+ if @variant_name && @variant_name.empty?
523
+ handle_error('Empty variant name for Waldo given')
524
+
525
+ return false
526
+ end
527
+
528
+ return true
529
+ end
530
+
531
+ def self.zip(src_path:, zip_path:, cd_path:)
532
+ unless FastlaneCore::CommandExecutor.which('zip')
533
+ handle_error("Command not found: 'zip'")
534
+
535
+ return false
103
536
  end
537
+
538
+ FileUtils.cd(cd_path) do
539
+ cmd = %(zip -qry "#{zip_path}" "#{src_path}")
540
+
541
+ result = Actions.sh(cmd, log: false)
542
+
543
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
544
+
545
+ unless result.empty?
546
+ handle_error("Unable to zip folder at path '#{src_path.to_s}' into '#{zip_path.to_s}'")
547
+
548
+ return false
549
+ end
550
+ end
551
+
552
+ return true
104
553
  end
105
554
  end
106
555
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Waldo
3
- VERSION = "1.2.0"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-waldo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J. G. Pusey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.5.2.3
100
+ rubygems_version: 3.1.2
102
101
  signing_key:
103
102
  specification_version: 4
104
103
  summary: Upload build to Waldo