fastlane-plugin-aws_device_farm 0.3.15.pre.alpha.pre.117 → 0.3.15.pre.alpha.pre.121

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a55ddebd68c61e0c3008640e38f8a89258e113f571e35823219bd40be4670d8b
4
- data.tar.gz: 75bf474c5fa987693212b6c00cdfce2310e8829ec5da4ea2310a5c8f3083bc43
3
+ metadata.gz: 9396a0955f5b4e41b798b30b6b2aeb5cb3040f4efc5fe0d4e58522ec17e4c39c
4
+ data.tar.gz: a1a5a5ba71f779226b8357554f22d806a2d23e9136ff1abeac3387ca50782820
5
5
  SHA512:
6
- metadata.gz: 181cc5f4fc63d18e19145c4d5081e00b5a43e697740f9ebde3b8279dbf823ada15594cc1afa71aec24631dab6dbd5db12f07cdece64bf2ea3f166ca23ba4709b
7
- data.tar.gz: 6e4e31e191db389ad71c9b16a35071194cca41d77e424cdb485690984a38a908084b78abf28aa8d826251b49eb38cb9bfb2b08fc8981e2f60c9a9eb5287ebc9e
6
+ metadata.gz: eefaf3fbbe9ba44c2d9a00c93058d324ec138825d624abc34608f18cad8882c2a078cefaf30f8eb536b805f3f485abc4b3c029bd7f41e1489726e1beb8e8e248
7
+ data.tar.gz: 419918e31a9eefb7b2d9248bd318831746e1fa1706ac3851e3a1da3d0347ce50e3d19c0506657e5b3a043644b88b38535d0dc7438864cd95ad4b04dc2d2c8b56
@@ -1,4 +1,5 @@
1
1
  require 'aws-sdk'
2
+
2
3
  module Fastlane
3
4
  module Actions
4
5
  # rubocop:disable Metrics/ClassLength
@@ -69,6 +70,8 @@ module Fastlane
69
70
  if params[:wait_for_completion]
70
71
  UI.message 'Waiting for the run to complete. ☕️'
71
72
  run = wait_for_run project, run, params
73
+ run = create_test_result run, params
74
+
72
75
  if params[:allow_failed_tests] == false
73
76
  if params[:allow_device_errors] == true
74
77
  raise "#{run.message} Failed 🙈" unless %w[PASSED WARNED ERRORED].include? run.result
@@ -291,6 +294,22 @@ module Fastlane
291
294
  is_string: false,
292
295
  optional: true,
293
296
  default_value: true
297
+ ),
298
+ FastlaneCore::ConfigItem.new(
299
+ key: :junit_xml_output_path,
300
+ env_name: 'FL_JUNIT_XML_OUTPUT_PATH',
301
+ description: 'JUnit xml output path',
302
+ is_string: true,
303
+ optional: true,
304
+ default_value: "junit.xml"
305
+ ),
306
+ FastlaneCore::ConfigItem.new(
307
+ key: :junit_xml,
308
+ env_name: 'FL_ALLOW_JUNIT_XML',
309
+ description: 'Do you create JUnit.xml?',
310
+ is_string: false,
311
+ optional: true,
312
+ default_value: false
294
313
  )
295
314
  ]
296
315
  end
@@ -417,11 +436,16 @@ module Fastlane
417
436
  UI.verbose "PROJECT ARN: #{project.arn}."
418
437
  ENV["AWS_DEVICE_FARM_PROJECT_ARN"] = project.arn
419
438
 
439
+ run
440
+ end
441
+
442
+ def self.create_test_result(run, params)
420
443
  job = @client.list_jobs({
421
- arn: run.arn
422
- })
444
+ arn: run.arn
445
+ })
423
446
 
424
447
  rows = []
448
+ test_results = {}
425
449
  job.jobs.each do |j|
426
450
  if j.result == "PASSED"
427
451
  status = "💚 (#{j.result})"
@@ -431,7 +455,48 @@ module Fastlane
431
455
  status = "💥 (#{j.result})"
432
456
  end
433
457
  rows << [status, j.name, j.device.form_factor, j.device.platform, j.device.os]
458
+
459
+ suite = @client.list_suites({
460
+ arn: j.arn
461
+ })
462
+
463
+ test_suites = []
464
+ suite.suites.each do |suite|
465
+ test = @client.list_tests({
466
+ arn: suite.arn
467
+ })
468
+
469
+ test_lists = []
470
+ test.tests.each do |test|
471
+ test_lists << {
472
+ "class_name" => suite.name,
473
+ "name" => test.name,
474
+ "time" => test.device_minutes.metered
475
+ }
476
+ end
477
+
478
+ test_suites << {
479
+ "name" => suite.name,
480
+ "tests" => suite.counters.total,
481
+ "failures" => suite.counters.failed,
482
+ "errors" => suite.counters.errored,
483
+ "time" => suite.device_minutes.metered,
484
+ "test_lists" => test_lists
485
+ }
486
+
487
+ # test results
488
+ test_results = {
489
+ "name" => j.name,
490
+ "tests" => j.counters.total,
491
+ "failures" => j.counters.failed,
492
+ "errors" => j.counters.errored,
493
+ "time" => j.device_minutes.metered,
494
+ "test_suites" => test_suites
495
+ }
496
+ Helper::AwsDeviceFarmHelper.create_junit_xml(test_results: test_results, file_path: params[:junit_xml_output_path]) if params[:junit_xml]
497
+ end
434
498
  end
499
+
435
500
  puts ""
436
501
  puts Terminal::Table.new(
437
502
  title: "Device Farm Summary".green,
@@ -442,6 +507,7 @@ module Fastlane
442
507
 
443
508
  run
444
509
  end
510
+
445
511
  def self.get_run_url_from_arn(arn)
446
512
  project_id = get_project_id_from_arn arn
447
513
  run_id = get_run_id_from_arn arn
@@ -1,12 +1,48 @@
1
+ require 'rexml/document'
2
+ require 'fileutils'
3
+
1
4
  module Fastlane
2
5
  module Helper
3
6
  class AwsDeviceFarmHelper
4
- # class methods that you define here become available in your action
5
- # as `Helper::AwsDeviceFarmHelper.your_method`
6
- #
7
- def self.show_message
8
- UI.message("Hello from the aws_device_farm plugin helper!")
7
+
8
+ # create Junit.xml
9
+ def self.create_junit_xml(test_results:, file_path:)
10
+ doc = REXML::Document.new
11
+ doc << REXML::XMLDecl.new('1.0', 'UTF-8')
12
+
13
+ # test_suites
14
+ root = REXML::Element.new('testsuites')
15
+ root.add_attribute('name', "#{test_results['name']}")
16
+ root.add_attribute('tests', "#{test_results['tests']}")
17
+ root.add_attribute('failures', "#{test_results['failures']}")
18
+ root.add_attribute('time', "#{test_results['time']}")
19
+ doc.add_element(root)
20
+
21
+ test_results['test_suites'].each do |suite|
22
+ testsuite = REXML::Element.new('testsuite')
23
+ testsuite.add_attribute('name', "#{suite['name']}")
24
+ testsuite.add_attribute('tests', "#{suite['tests']}")
25
+ testsuite.add_attribute('errors', "#{suite['errors']}")
26
+ testsuite.add_attribute('failures', "#{suite['failures']}")
27
+ testsuite.add_attribute('time', "#{suite['time']}")
28
+ root.add_element(testsuite)
29
+
30
+ suite['test_lists'].each do |test|
31
+ testcase = REXML::Element.new('testcase')
32
+ testcase.add_attribute('classname', "#{test['class_name']}")
33
+ testcase.add_attribute('name', "#{test['name']}")
34
+ testcase.add_attribute('time', "#{test['time']}")
35
+ testsuite.add_element(testcase)
36
+ end
37
+ end
38
+
39
+ # output
40
+ FileUtils.mkdir_p(File.dirname(file_path))
41
+ File.open(file_path, 'w') do |file|
42
+ doc.write(file, indent=2)
43
+ end
9
44
  end
45
+
10
46
  end
11
47
  end
12
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-aws_device_farm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15.pre.alpha.pre.117
4
+ version: 0.3.15.pre.alpha.pre.121
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helmut Januschka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk