Class: Fastlane::Actions::AwsDeviceFarmAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb

Overview

rubocop:disable Metrics/ClassLength

Documentation collapse

POLLING_INTERVAL =
10

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



376
377
378
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 376

def self.authors
  ["fousa/fousa", "hjanuschka", "cmarchal"]
end

.available_optionsObject



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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 105

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key:         :name,
      env_name:    'FL_AWS_DEVICE_FARM_NAME',
      description: 'Define the name of the device farm project',
      is_string:   true,
      default_value: 'fastlane',
      optional:    false
    ),
    FastlaneCore::ConfigItem.new(
      key:         :run_name,
      env_name:    'FL_AWS_DEVICE_FARM_RUN_NAME',
      description: 'Define the name of the device farm run',
      is_string:   true,
      optional:    true
    ),
    FastlaneCore::ConfigItem.new(
      key:         :binary_path,
      env_name:    'FL_AWS_DEVICE_FARM_PATH',
      description: 'Define the path of the application binary (apk or ipa) to upload to the device farm project',
      is_string:   true,
      optional:    false,
      verify_block: proc do |value|
        raise "Application binary not found at path '#{value}'. 🙈".red unless File.exist?(File.expand_path(value))
      end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :test_binary_path,
      env_name:    'FL_AWS_DEVICE_FARM_TEST_PATH',
      description: 'Define the path of the test bundle to upload to the device farm project',
      is_string:   true,
      optional:    true,
      verify_block: proc do |value|
        raise "Test bundle not found at path '#{value}'. 🙈".red unless File.exist?(File.expand_path(value))
      end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :test_package_type,
      env_name:    'FL_AWS_DEVICE_FARM_TEST_PACKAGE_TYPE',
      description: 'Define the type of the test binary to upload to the device farm project',
      is_string:   true,
      optional:    true,
      verify_block: proc do |value|
        valid_values = ['APPIUM_JAVA_JUNIT_TEST_PACKAGE',
                        'APPIUM_JAVA_TESTNG_TEST_PACKAGE',
                        'APPIUM_PYTHON_TEST_PACKAGE',
                        'APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE',
                        'APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE',
                        'APPIUM_WEB_PYTHON_TEST_PACKAGE',
                        'CALABASH_TEST_PACKAGE',
                        'INSTRUMENTATION_TEST_PACKAGE',
                        'UIAUTOMATION_TEST_PACKAGE',
                        'UIAUTOMATOR_TEST_PACKAGE',
                        'XCTEST_TEST_PACKAGE',
                        'XCTEST_UI_TEST_PACKAGE',
                        'APPIUM_NODE_TEST_PACKAGE',
                        'APPIUM_RUBY_TEST_PACKAGE',
                        'APPIUM_WEB_NODE_TEST_PACKAGE',
                        'APPIUM_WEB_RUBY_TEST_PACKAGE',
                        'APPIUM_JAVA_JUNIT_TEST_SPEC',
                        'APPIUM_JAVA_TESTNG_TEST_SPEC',
                        'APPIUM_PYTHON_TEST_SPEC',
                        'APPIUM_NODE_TEST_SPEC',
                        'APPIUM_RUBY_TEST_SPEC',
                        'APPIUM_WEB_JAVA_JUNIT_TEST_SPEC',
                        'APPIUM_WEB_JAVA_TESTNG_TEST_SPEC',
                        'APPIUM_WEB_PYTHON_TEST_SPEC',
                        'APPIUM_WEB_NODE_TEST_SPEC',
                        'APPIUM_WEB_RUBY_TEST_SPEC',
                        'INSTRUMENTATION_TEST_SPEC',
                        'XCTEST_UI_TEST_SPEC']
        raise "Test package type not found valid values are: '#{valid_values}'. 🙈".red unless valid_values.include? value
      end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :test_type,
      env_name:    'FL_AWS_DEVICE_FARM_TEST_TYPE',
      description: 'Define the type of the test binary to upload to the device farm project',
      is_string:   true,
      optional:    true,
      verify_block: proc do |value|
        valid_values = ['UIAUTOMATOR',
                        'APPIUM_WEB_PYTHON',
                        'CALABASH',
                        'APPIUM_JAVA_TESTNG',
                        'UIAUTOMATION',
                        'BUILTIN_FUZZ',
                        'INSTRUMENTATION',
                        'APPIUM_JAVA_JUNIT',
                        'XCTEST_UI',
                        'APPIUM_WEB_JAVA_JUNIT',
                        'APPIUM_PYTHON',
                        'BUILTIN_EXPLORER',
                        'XCTEST',
                        'APPIUM_WEB_JAVA_TESTNG',
                        'WEB_PERFORMANCE_PROFILE',
                        'APPIUM_NODE',
                        'APPIUM_RUBY',
                        'APPIUM_WEB_NODE',
                        'APPIUM_WEB_RUBY',
                        'REMOTE_ACCESS_RECORD',
                        'REMOTE_ACCESS_REPLAY']
        raise "Test type not found valid values are: '#{valid_values}'. 🙈".red unless valid_values.include? value
      end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :path,
      env_name:    'FL_AWS_DEVICE_FARM_PATH',
      description: 'Define the path of the application binary (apk or ipa) to upload to the device farm project',
      is_string:   true,
      optional:    false,
      verify_block: proc do |value|
        raise "Application binary not found at path '#{value}'. 🙈".red unless File.exist?(File.expand_path(value))
      end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :device_pool,
      env_name:    'FL_AWS_DEVICE_FARM_POOL',
      description: 'Define the device pool you want to use for running the applications',
      default_value: 'IOS',
      is_string:   true,
      optional:    false
    ),
    FastlaneCore::ConfigItem.new(
      key:         :network_profile_arn,
      env_name:    'FL_AWS_DEVICE_FARM_NETWORK_PROFILE_ARN',
      description: 'Network profile arn you want to use for running the applications',
      optional:    true,
      is_string:   true
    ),
    FastlaneCore::ConfigItem.new(
      key:           :wait_for_completion,
      env_name:      'FL_AWS_DEVICE_FARM_WAIT_FOR_COMPLETION',
      description:   'Wait for the scheduled run to complete',
      is_string:     false,
      optional:      true,
      default_value: true
    ),
    FastlaneCore::ConfigItem.new(
      key:           :allow_device_errors,
      env_name:      'FL_AWS_DEVICE_FARM_ALLOW_ERROR',
      description:   'Do you want to allow device booting errors?',
      is_string:     false,
      optional:      true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
      key:           :allow_failed_tests,
      env_name:      'FL_AWS_DEVICE_FARM_ALLOW_FAILED_TESTS',
      description:   'Do you want to allow failing tests?',
      is_string:     false,
      optional:      true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
      key:           :filter,
      env_name:      'FL_AWS_DEVICE_FARM_FILTER',
      description:   'Define a filter for your test run and only run the tests in the filter',
      is_string:     true,
      optional:      true,
      default_value: ''
    ),
    FastlaneCore::ConfigItem.new(
      key:           :billing_method,
      env_name:      'FL_AWS_DEVICE_FARM_BILLING_METHOD',
      description:   'Specify the billing method for the run',
      is_string:     true,
      optional:      true,
      default_value: 'METERED' # accepts METERED, UNMETERED
    ),
    FastlaneCore::ConfigItem.new(
      key:           :locale,
      env_name:      'FL_AWS_DEVICE_FARM_LOCALE',
      description:   'Specify the locale for the run',
      is_string:     true,
      optional:      true,
      default_value: 'en_US'
    ),
    FastlaneCore::ConfigItem.new(
      key:         :test_spec,
      env_name:    'FL_AWS_TEST_SPEC',
      description: 'Define the device farm custom TestSpec ARN to use (can be obtained using the AWS CLI `devicefarm list-uploads` command)',
      is_string:   true,
      optional:    true
    ),
    FastlaneCore::ConfigItem.new(
      key:         :print_web_url_of_run,
      env_name:    'FL_AWS_DEVICE_FARM_WEB_URL_OF_RUN',
      description: 'Print the web url of the test run to or not',
      is_string:   false,
      optional:    true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :print_waiting_periods,
      env_name: 'FL_AWS_DEVICE_FARM_PRINT_WAITING_PERIODS',
      description: 'Prints a period while waiting for tests to complete',
      is_string: false,
      optional: true,
      default_value: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :junit_xml_output_path,
      env_name: 'FL_JUNIT_XML_OUTPUT_PATH',
      description: 'JUnit xml output path',
      is_string: true,
      optional: true,
      default_value: "junit.xml"
    ),
    FastlaneCore::ConfigItem.new(
      key: :junit_xml,
      env_name: 'FL_ALLOW_JUNIT_XML',
      description: 'Do you create JUnit.xml?',
      is_string: false,
      optional: true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
        key: :artifact,
        env_name: 'FL_ALLOW_ARTIFACT',
        description: 'Do you download Artifact?',
        is_string: false,
        optional: true,
        default_value: false
    ),
    FastlaneCore::ConfigItem.new(
        key: :artifact_output_dir,
        env_name: 'FL_ARTIFACT_OUTPUT_DIR',
        description: 'Artifact output directory',
        is_string: true,
        optional: true,
        default_value: "./test_outputs"
    ),
    FastlaneCore::ConfigItem.new(
        key: :artifact_types,
        env_name: 'FL_ARTIFACT_TYPES',
        description: 'Download Artifact types',
        is_string: false,
        type: Array,
        optional: true,
        default_value: [],
        verify_block: proc do |value|
          valid_values = ['LOG',
                          'SCREENSHOT', 
                          'FILE']
          raise "Artifact type concludes invalid values are: '#{(value - valid_values)}'. 🙈".red unless (value - valid_values).empty?
        end
    ),
    FastlaneCore::ConfigItem.new(
      key:         :additional_configuration,
      description: 'Additional configuration settings',
      type:        Hash,
      optional:    true,
    ),
    FastlaneCore::ConfigItem.new(
      key:         :test_parameters,
      description: 'The test parameters',
      type:        Hash,
      optional:    true,
    ),
  ]
end

.create_project_upload(project, path, type) ⇒ Object



391
392
393
394
395
396
397
398
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 391

def self.create_project_upload(project, path, type)
  @client.create_upload({
    project_arn:  project.arn,
    name:         File.basename(path),
    content_type: 'application/octet-stream',
    type:         type
  }).upload
end

.create_test_result(run, params) ⇒ Object



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 509

def self.create_test_result(run, params)
  job = @client.list_jobs({
          arn: run.arn
        })

  rows = []
  test_results = {}
  job.jobs.each do |j|
    if j.result == "PASSED"
      status = "💚 (#{j.result})"
    elsif j.result == "ERRORED"
      status = "📵 (#{j.result})"
    else
      status = "💥 (#{j.result})"
    end
    rows << [status, j.name, j.device.form_factor, j.device.platform, j.device.os]

    # artifact
    artifact_support_types = %w(LOG SCREENSHOT FILE)
    params[:artifact_types].each do |type|
      next unless artifact_support_types.include?(type) && params[:artifact]

      artifact = @client.list_artifacts({
                   arn: j.arn,
                   type: type
                 })

      artifact.artifacts.each do |artifact|
        case type
        when "LOG"
          file_name = "#{artifact.name}.#{artifact.extension}"
        when "SCREENSHOT"
          file_name = "#{artifact.name}.#{artifact.extension}"
        when "FILE"
          file_name = "#{artifact.name}.#{artifact.extension}"
        end

        file_dir_path = "#{params[:artifact_output_dir]}/#{j.name}/#{j.device.os}"
        Helper::AwsDeviceFarmHelper.get_artifact(url: artifact.url, file_dir_path: file_dir_path, file_name: file_name)
      end
    end

    # test suites
    suite = @client.list_suites({
              arn: j.arn
            })

    test_suites = []
    suite.suites.each do |suite|
      test = @client.list_tests({
               arn: suite.arn
             })

      test_lists = []
      test.tests.each do |test|
        test_lists << {
          "class_name" => suite.name,
          "name"       => test.name,
          "time"       => test.device_minutes.metered
        }
      end

      test_suites << {
        "name"     => suite.name,
        "tests"    => suite.counters.total,
        "failures" => suite.counters.failed,
        "errors"   => suite.counters.errored,
        "time"     => suite.device_minutes.metered,
        "test_lists" => test_lists
      }

      # test results
      test_results = {
        "name"     => j.name,
        "tests"    => j.counters.total,
        "failures" => j.counters.failed,
        "errors"   => j.counters.errored,
        "time"     => j.device_minutes.metered,
        "test_suites" => test_suites
      }

      # need multi device support
      file_prefix = "#{j.name}-#{j.device.os}"
      Helper::AwsDeviceFarmHelper.create_junit_xml(test_results: test_results, file_path: params[:junit_xml_output_path], file_prefix: file_prefix) if params[:junit_xml]
    end
  end

  puts ""
  puts Terminal::Table.new(
    title: "Device Farm Summary".green,
    headings: ["Status", "Name", "Form Factor", "Platform", "Version"],
    rows: rows
  )
  puts ""

  run
end

.descriptionObject

rubocop:enable Metrics/BlockNesting



97
98
99
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 97

def self.description
  'Upload the application to the AWS device farm'
end

.detailsObject



101
102
103
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 101

def self.details
  'Upload the application to the AWS device farm'
end

.fetch_device_pool(project, device_pool) ⇒ Object



424
425
426
427
428
429
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 424

def self.fetch_device_pool(project, device_pool)
  device_pools = @client.list_device_pools({
    arn: project.arn
  })
  device_pools.device_pools.detect { |p| p.name == device_pool }
end

.fetch_project(name) ⇒ Object



386
387
388
389
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 386

def self.fetch_project(name)
  projects = @client.list_projects.projects
  projects.detect { |p| p.name == name }
end

.fetch_run_status(run) ⇒ Object



484
485
486
487
488
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 484

def self.fetch_run_status(run)
  @client.get_run({
    arn:  run.arn
  }).run
end

.fetch_upload_status(upload) ⇒ Object



408
409
410
411
412
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 408

def self.fetch_upload_status(upload)
  @client.get_upload({
    arn:  upload.arn
  }).upload
end

.get_project_id_from_arn(arn) ⇒ Object



613
614
615
616
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 613

def self.get_project_id_from_arn(arn)
  project_run_id = split_run_arn arn
  project_run_id[0]
end

.get_region_from_arn(arn) ⇒ Object



621
622
623
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 621

def self.get_region_from_arn(arn)
  arn.split(':')[3]
end

.get_run_id_from_arn(arn) ⇒ Object



617
618
619
620
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 617

def self.get_run_id_from_arn(arn)
  project_run_id = split_run_arn arn
  project_run_id[1]
end

.get_run_url_from_arn(arn) ⇒ Object



607
608
609
610
611
612
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 607

def self.get_run_url_from_arn(arn)
  project_id = get_project_id_from_arn arn
  run_id = get_run_id_from_arn arn
  region_id = get_region_from_arn arn
  "https://#{region_id}.console.aws.amazon.com/devicefarm/home?region=#{region_id}#/projects/#{project_id}/runs/#{run_id}"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


380
381
382
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 380

def self.is_supported?(platform)
  platform == :ios || platform == :android
end

.outputObject



369
370
371
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 369

def self.output
  []
end

.return_valueObject



373
374
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 373

def self.return_value
end

.run(params) ⇒ Object



7
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 7

def self.run(params)
  Actions.verify_gem!('aws-sdk')
  UI.message 'Preparing the upload to the device farm.'

  # Instantiate the client.
  @client = ::Aws::DeviceFarm::Client.new

  # Fetch the project
  project = fetch_project params[:name]
  raise "Project '#{params[:name]}' not found on AWS - please go to 'Device Farm' and create a project named: 'fastlane', or set the 'name' parameter with your custom message." if project.nil?

  # Fetch the device pool.
  device_pool = fetch_device_pool project, params[:device_pool]
  raise "Device pool '#{params[:device_pool]}' not found. 🙈" if device_pool.nil?
  # Create the upload.
  path   = File.expand_path(params[:binary_path])
  type   = File.extname(path) == '.apk' ? 'ANDROID_APP' : 'IOS_APP'
  upload = create_project_upload project, path, type

  # Upload the application binary.
  UI.message 'Uploading the application binary. ☕️'
  upload upload, path

  # Upload the test package if needed.
  test_upload = nil
  if params[:test_binary_path]
    test_path = File.expand_path(params[:test_binary_path])
    if params[:test_package_type]
      test_upload = create_project_upload project, test_path, params[:test_package_type]
    else
      if type == "ANDROID_APP"
        test_upload = create_project_upload project, test_path, 'INSTRUMENTATION_TEST_PACKAGE'
      elsif params[:test_type] == 'XCTEST'
        test_upload = create_project_upload project, test_path, 'XCTEST_TEST_PACKAGE'
      else
        test_upload = create_project_upload project, test_path, 'XCTEST_UI_TEST_PACKAGE'
      end
    end

    # Upload the test binary.
    UI.message 'Uploading the test binary. ☕️'
    upload test_upload, test_path

    # Wait for test upload to finish.
    UI.message 'Waiting for the test upload to succeed. ☕️'
    test_upload = wait_for_upload test_upload
    raise 'Test upload failed. 🙈' unless test_upload.status == 'SUCCEEDED'
  end

  # Wait for upload to finish.
  UI.message 'Waiting for the application upload to succeed. ☕️'
  upload = wait_for_upload upload
  raise 'Binary upload failed. 🙈' unless upload.status == 'SUCCEEDED'

  # Schedule the run.
  run = schedule_run params[:run_name], project, device_pool, upload, test_upload, type, params
  run_url = get_run_url_from_arn run.arn
  ENV["AWS_DEVICE_FARM_WEB_URL_OF_RUN"] = run_url
  UI.message "The Device Farm console URL for the run: #{run_url}" if params[:print_web_url_of_run] == true

  # Wait for run to finish.
  # rubocop:disable  Metrics/BlockNesting
  if params[:wait_for_completion]
    UI.message 'Waiting for the run to complete. ☕️'
    run = wait_for_run project, run, params
    run = create_test_result run, params

    if params[:allow_failed_tests] == false
      if params[:allow_device_errors] == true
        raise "#{run.message} Failed 🙈" unless %w[PASSED WARNED ERRORED].include? run.result
      else
        raise "#{run.message} Failed 🙈" unless %w[PASSED WARNED].include? run.result
      end
    end
    UI.message 'Successfully tested the application on the AWS device farm. ✅'.green
  else
    UI.message 'Successfully scheduled the tests on the AWS device farm. ✅'.green
  end

  run
end

.schedule_run(name, project, device_pool, upload, test_upload, type, params) ⇒ Object



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 430

def self.schedule_run(name, project, device_pool, upload, test_upload, type, params)
  # Prepare the test hash depening if you passed the test apk.
  test_hash = { type: 'BUILTIN_FUZZ' }

  if params[:test_parameters]
    test_hash[:parameters] = params[:test_parameters]
  end

  if test_upload
    if params[:test_type]
      test_hash[:type] = params[:test_type]
    else
      if type == "ANDROID_APP"
        test_hash[:type] = 'INSTRUMENTATION'
      else
        test_hash[:type] = 'XCTEST_UI'
      end
    end

    if params[:test_spec]
        test_hash[:test_spec_arn] = params[:test_spec]
    else
        test_hash[:filter] = params[:filter]
    end

    test_hash[:test_package_arn] = test_upload.arn
  end

  configuration_hash = {
    billing_method: params[:billing_method],
    locale: params[:locale],
  }

  # Get the network profile from params if value is provided
  if params[:network_profile_arn]
    configuration_hash[:network_profile_arn] = params[:network_profile_arn]
  end

  # Add additional configuration arguments if provided.
  if params[:additional_configuration]
    configuration_hash.update(params[:additional_configuration])
  end

  @client.schedule_run({
    name:            name,
    project_arn:     project.arn,
    app_arn:         upload.arn,
    device_pool_arn: device_pool.arn,
    test:            test_hash,
    configuration:   configuration_hash
  }).run
end

.split_run_arn(arn) ⇒ Object



624
625
626
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 624

def self.split_run_arn(arn)
  arn.split(':')[6].split('/')
end

.upload(upload, path) ⇒ Object



400
401
402
403
404
405
406
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 400

def self.upload(upload, path)
  url = URI.parse(upload.url)
  contents = File.open(path, 'rb').read
  Net::HTTP.new(url.host).start do |http|
    http.send_request("PUT", url.request_uri, contents, { 'content-type' => 'application/octet-stream' })
  end
end

.wait_for_run(project, run, params) ⇒ Object



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 490

def self.wait_for_run(project, run, params)
  while run.status != 'COMPLETED'
    sleep POLLING_INTERVAL
    if params[:print_waiting_periods]
      print '.'
    end
    run = fetch_run_status run
  end
  UI.message "The run ended with result #{run.result}."
  UI.important "Minutes Counted: #{run.device_minutes.total}"

  UI.verbose "RUN ARN: #{run.arn}."
  ENV["AWS_DEVICE_FARM_RUN_ARN"] = run.arn
  UI.verbose "PROJECT ARN: #{project.arn}."
  ENV["AWS_DEVICE_FARM_PROJECT_ARN"] = project.arn

  run
end

.wait_for_upload(upload) ⇒ Object



414
415
416
417
418
419
420
421
422
# File 'lib/fastlane/plugin/aws_device_farm/actions/aws_device_farm_action.rb', line 414

def self.wait_for_upload(upload)
  upload = fetch_upload_status upload
  while upload.status == 'PROCESSING' || upload.status == 'INITIALIZED'
    sleep POLLING_INTERVAL
    upload = fetch_upload_status upload
  end

  upload
end