Class: FirebaseTestLabIntegration::Helper::Options

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

Class Method Summary collapse

Class Method Details

.authorsObject



15
16
17
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 15

def self.authors
  ["Cristian Boarna"]
end

.available_options_androidObject



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

def self.available_options_android
  self.available_options_common + [
    FastlaneCore::ConfigItem.new(
      key: :app_path,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_APP_PATH",
      description: "The path to the app to be tested",
      type: String,
      optional: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :devices,
      description: "Devices to test the app on",
      optional: true,
      type: Array,
      default_value: [{
                        model: "redfin",
                        version: "30",
                        locale: "en_US",
                        orientation: "portrait"
                      }],
      verify_block: proc do |value|
        verify_devices(value)
      end
    )
  ]
end

.available_options_commonObject



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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 19

def self.available_options_common
  [
    FastlaneCore::ConfigItem.new(
      key: :gcp_project,
      description: "Google Cloud Platform project ID",
      optional: false,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_GCP_PROJECT"
    ),
    FastlaneCore::ConfigItem.new(
      key: :gcp_key_file,
      description: "Google Cloud Platform authentication key file path",
      optional: false,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_GCP_KEY_FILE"
    ),
    FastlaneCore::ConfigItem.new(
      key: :gcloud_channel,
      description: "If you use beta or alpha channel. Defaults to stable (alpha/beta)",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_GCP_CHANNEL",
      default_value: "stable"
    ),
    FastlaneCore::ConfigItem.new(
      key: :gcloud_results_bucket,
      description: "Name of Google Storage for Firebase Test Lab results bucket. Defaults to '`gcp_project`_firebase_testlab'",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_GCP_RESULTS_BUCKET",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :gcloud_results_dir,
      description: "Name of Google Storage for Firebase Test Lab results directory",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_GCP_RESULTS_DIR",
      default_value: "firebase_test_lab_result_#{DateTime.now.strftime('%Y-%m-%d-%H:%M:%S')}"
    ),
    FastlaneCore::ConfigItem.new(
      key: :timeout,
      description: "The max time this test execution can run before it is cancelled. Default: 5m (this value must be greater than or equal to 1m)",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_TIMEOUT",
      default_value: "5m"
    ),
    FastlaneCore::ConfigItem.new(
      key: :quiet,
      description: "Mutes all potentially sensitive `gcloud`, `gsutil` output",
      optional: true,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_QUIET",
      default_value: false,
      is_string: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :app_path_test,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_APP_PATH_TEST",
      description: "The path for your Android test APK. If not present assuming robo test",
      type: String,
      optional: true,
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :type,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_TYPE",
      description: "The type of the test, one of: instrumentation, robo, game-loop, or xctest. Default: depends on platform",
      type: String,
      optional: true,
      verify_block: proc do |value|
        if !value.nil? && value != "robo" && value != "instrumentation" && value != "game-loop" && value != "xctest"
          FastlaneCore::UI.user_error!("Only robo, instrumentation, xctest and game-loop are supported")
        end
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :results_download_dir,
      description: "Target directory to download screenshots from Firebase",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_RESULTS_DOWNLOAD_DIR",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :results_log_file_name,
      description: "The filename to save the output results. Default: ./firebase_test_lab_integration.log",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_OUTPUT_LOG_FILE_NAME",
      default_value: "./firebase_test_lab_integration.log"
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_owner,
      description: "Github Owner name of the repo",
      optional: true,
      type: String,
      env_name: "GH_OWNER",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_repository,
      description: "Github Repository name",
      optional: true,
      type: String,
      env_name: "GH_REPOSITORY",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_pr_number,
      description: "Github Pull request number",
      optional: true,
      type: String,
      env_name: "GH_PR_NUMBER",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_api_token,
      description: "GitHub API Token",
      optional: true,
      type: String,
      env_name: "GH_API_TOKEN",
      default_value: nil
    ),
    FastlaneCore::ConfigItem.new(
      key: :extra_options,
      description: "Extra options that you may pass directly to the `gcloud` command. Default: empty string",
      optional: true,
      type: String,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_EXTRA_OPTIONS",
      default_value: ""
    )
  ]
end

.available_options_iosObject



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

def self.available_options_ios
  self.available_options_common + [
    FastlaneCore::ConfigItem.new(
      key: :app_path,
      env_name: "FIREBASE_TEST_LAB_INTEGRATION_APP_PATH",
      description: "The path to the app to be tested",
      type: String,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :devices,
      description: "Devices to test the app on",
      optional: true,
      type: Array,
      default_value: [{
                        model: "iphone13pro",
                        version: "15.2",
                        locale: "en_US",
                        orientation: "portrait"
                      }],
      verify_block: proc do |value|
        verify_devices(value)
      end
    )
  ]
end

.check_has_property(hash_obj, property) ⇒ Object



224
225
226
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 224

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

.description(platform) ⇒ Object



7
8
9
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 7

def self.description(platform)
  "Run #{platform} integration tests on Firebase Test Lab"
end

.detailsObject



11
12
13
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 11

def self.details
  "Test your app on Firebase Test Lab with ease using fastlane"
end

.set_default_property(hash_obj, property, default) ⇒ Object



228
229
230
231
232
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 228

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

.verify_devices(value) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/fastlane/plugin/firebase_test_lab_integration/helper/options.rb', line 208

def self.verify_devices(value)
  if value.empty?
    FastlaneCore::UI.user_error!("Devices cannot be empty")
  end
  value.each do |current|
    if current.class != Hash
      FastlaneCore::UI.user_error!("Each device must be represented by a Hash object, " \
                                   "#{current.class} found")
    end
    check_has_property(current, :model)
    check_has_property(current, :version)
    set_default_property(current, :locale, "en_US")
    set_default_property(current, :orientation, "portrait")
  end
end