Class: Fastlane::FirebaseTestLab::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/firebase_test_lab/options.rb

Class Method Summary collapse

Class Method Details

.available_optionsObject



6
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
# File 'lib/fastlane/plugin/firebase_test_lab/options.rb', line 6

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :gcp_project,
                                 description: "Google Cloud Platform project name",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :app_path,
                                 description: "Path to the app, either on the filesystem or GCS address (gs://)",
                                 default_value:
                                   Actions.lane_context[Actions::SharedValues::SCAN_ZIP_BUILD_PRODUCTS_PATH],
                                 verify_block: proc do |value|
                                   unless value.to_s.start_with?("gs://")
                                     v = File.expand_path(value.to_s)
                                     UI.user_error!("App file not found at path '#{v}'") unless File.exist?(v)
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :devices,
                                 description: "Devices to test the app on",
                                 type: Array,
                                 default_value: [{
                                   ios_model_id: "iphonex",
                                   ios_version_id: "11.2",
                                   locale: "en_US",
                                   orientation: "portrait"
                                 }],
                                 verify_block: proc do |value|
                                   if value.empty?
                                     UI.user_error!("Devices cannot be empty")
                                   end
                                   value.each do |current|
                                     if current.class != Hash
                                       UI.user_error!("Each device must be represented by a Hash object, " \
                                         "#{current.class} found")
                                     end
                                     check_has_property(current, :ios_model_id)
                                     check_has_property(current, :ios_version_id)
                                     set_default_property(current, :locale, "en_US")
                                     set_default_property(current, :orientation, "portrait")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :async,
                                 description: "Do not wait for test results",
                                 default_value: false,
                                 type: Fastlane::Boolean),
    FastlaneCore::ConfigItem.new(key: :timeout_sec,
                                 description: "After how long, in seconds, should tests be terminated",
                                 default_value: 180,
                                 optional: true,
                                 type: Integer,
                                 verify_block: proc do |value|
                                   UI.user_error!("Timeout must be less or equal to 45 minutes.") \
                                     if value <= 0 || value > 45 * 60
                                 end),
    FastlaneCore::ConfigItem.new(key: :result_storage,
                                 description: "GCS path to store test results",
                                 default_value: nil,
                                 optional: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Invalid GCS path: '#{value}'") \
                                     unless value.to_s.start_with?("gs://")
                                 end),
    FastlaneCore::ConfigItem.new(key: :oauth_key_file_path,
                                 description: "Use the given Google cloud service key file." \
                                              "If not set, application default credential will be used " \
                                              "(see https://cloud.google.com/docs/authentication/production)",
                                 default_value: nil,
                                 optional: true,
                                 verify_block: proc do |value|
                                   v = File.expand_path(value.to_s)
                                   UI.user_error!("Key file not found at path '#{v}'") unless File.exist?(v)
                                 end)
  ]
end

.check_has_property(hash_obj, property) ⇒ Object



79
80
81
# File 'lib/fastlane/plugin/firebase_test_lab/options.rb', line 79

def self.check_has_property(hash_obj, property)
  UI.user_error!("Each device must have #{property} property") unless hash_obj.key?(property)
end

.set_default_property(hash_obj, property, default) ⇒ Object



83
84
85
86
87
# File 'lib/fastlane/plugin/firebase_test_lab/options.rb', line 83

def self.set_default_property(hash_obj, property, default)
  unless hash_obj.key?(property)
    hash_obj[property] = default
  end
end