fastlane-plugin-android_testlab_script_swit 0.1.35 → 0.1.37

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
2
  SHA256:
3
- metadata.gz: d6d51c6fa24e37d820108bdd91abfd31b797ccf6536963fe29c08abc9ea32531
4
- data.tar.gz: 7ba826c9e0b4d72bf21bdd8cf9d9169b96bd1b7f79dec126e9e2a1004670c125
3
+ metadata.gz: 5c022838ee298ef493126bee4d45b3f57189b067498ace65b91e82e282de84ba
4
+ data.tar.gz: 6739c6875e6b390e16ed55f13cc7f23a8f73f32b9c71290c229abad624d548df
5
5
  SHA512:
6
- metadata.gz: d64285bbb1b4dcdf2da02a4d39a123b500f3ed7d90045f947e86cdb1ec9c2c23fd620db3c4c96f722e4433924a9d97b91bcb11b87825437952df271f35ccfe3a
7
- data.tar.gz: a2b1cc415986e5cc8c90c918f593631848eaf505ae2506a26980afe1a06dc5fd9a3d373117aa476ec2ae631c1a8e31a3d82504f9f490924eca9bb6982f8f2658
6
+ metadata.gz: 610d1881b5e91edfe3dc2c45209b611009495c91338a4fcdd2db6217e0c0be78db0d7bc93f3d77a331fbf2852cdafcc7ac88c827e7bdf14642a076821326ace2
7
+ data.tar.gz: afd6ff095e267d2e73409a4182c76792bb2718a8d2a95241869035c0f8d70d848f399554d61e0c5d9343b882a43fef654a453602f7ead2cfc7279febd9498e18
@@ -1,6 +1,8 @@
1
1
  require 'fastlane/action'
2
2
  require 'json'
3
3
  require 'fileutils'
4
+ require 'httparty'
5
+ require 'open-uri'
4
6
 
5
7
  module Fastlane
6
8
  module Actions
@@ -23,7 +25,7 @@ module Fastlane
23
25
  robo_script_option = params[:robo_script_path].nil? ? "" : "--robo-script #{params[:robo_script_path]} "
24
26
 
25
27
  # Run Firebase Test Lab
26
- Helper.run_tests(params[:gcloud_components_channel], "--type #{params[:type]} "\
28
+ result_url = Helper.run_tests(params[:gcloud_components_channel], "--type #{params[:type]} "\
27
29
  "--app #{params[:app_apk]} "\
28
30
  "#{"--test #{params[:app_test_apk]} " unless params[:app_test_apk].nil?}"\
29
31
  "#{"--use-orchestrator " if params[:type] == "instrumentation" && params[:use_orchestrator]}"\
@@ -36,24 +38,45 @@ module Fastlane
36
38
  "--format=json 1>#{Helper.if_need_dir(params[:console_log_file_name])}"
37
39
  )
38
40
 
39
- json = JSON.parse(File.read(params[:console_log_file_name]))
40
- UI.message("Test status: #{json}")
41
-
42
- # Fetch results
43
- download_dir = params[:download_dir]
44
- if download_dir
45
- UI.message("Fetch results from Firebase Test Lab results bucket")
46
- json.each do |status|
47
- axis = status["axis_value"]
48
- Helper.if_need_dir("#{download_dir}/#{axis}")
49
- Helper.copy_from_gcs("#{results_bucket}/#{results_dir}/#{axis}", download_dir)
50
- Helper.set_public("#{results_bucket}/#{results_dir}/#{axis}")
51
- end
52
- end
41
+ wait_for_test_to_complete(test_results_url)
42
+
43
+ swit_webhook_url = params[:swit_webhook_url]
44
+ swit_webhook_payload = params[:swit_webhook_payload]
45
+
46
+ HTTParty.post(swit_webhook_url, body: swit_webhook_payload.to_json, headers: { 'Content-Type' => 'application/json' })
47
+
48
+ # json = JSON.parse(File.read(params[:console_log_file_name]))
49
+ # UI.message("Test status: #{json}")
50
+ #
51
+ # # Fetch results
52
+ # download_dir = params[:download_dir]
53
+ # if download_dir
54
+ # UI.message("Fetch results from Firebase Test Lab results bucket")
55
+ # json.each do |status|
56
+ # axis = status["axis_value"]
57
+ # Helper.if_need_dir("#{download_dir}/#{axis}")
58
+ # Helper.copy_from_gcs("#{results_bucket}/#{results_dir}/#{axis}", download_dir)
59
+ # Helper.set_public("#{results_bucket}/#{results_dir}/#{axis}")
60
+ # end
61
+ # end
53
62
 
54
63
  UI.message("Finish Action")
55
64
  end
56
65
 
66
+ def wait_for_test_to_complete(url)
67
+ require 'open-uri'
68
+
69
+ loop do
70
+ html = open(url).read
71
+
72
+ if html.include?("Test is complete")
73
+ break
74
+ else
75
+ sleep(10) # wait for a few seconds before checking again.
76
+ end
77
+ end
78
+ end
79
+
57
80
  # Short Detils
58
81
  def self.description
59
82
  "Android Firebase TestLab with Robo Script Test"
@@ -146,6 +169,20 @@ module Fastlane
146
169
  type: String,
147
170
  optional: false),
148
171
 
172
+ # swit_webhook url (true)
173
+ FastlaneCore::ConfigItem.new(key: :swit_webhook_url,
174
+ env_name: "SWIT_WEBHOOK_URL",
175
+ description: "The Swit WebHOOK URL",
176
+ type: String,
177
+ optional: true),
178
+
179
+ # swit_webhook payload (false)
180
+ FastlaneCore::ConfigItem.new(key: :swit_webhook_payload,
181
+ env_name: "SWIT_WEBHOOK_PAYLOAD",
182
+ description: "The Swit WebHOOK PAYLOAD",
183
+ type: String,
184
+ optional: true),
185
+
149
186
  # test apk (false)
150
187
  FastlaneCore::ConfigItem.new(key: :app_test_apk,
151
188
  env_name: "APP_TEST_APK",
@@ -241,10 +278,24 @@ module Fastlane
241
278
  platform == :android
242
279
  end
243
280
 
281
+ #
244
282
  def self.output
245
283
  [['console_output.log', 'A console log when running Firebase Test Lab with gcloud']]
246
284
  end
247
285
 
286
+ #
287
+ def wait_for_test_to_complete(url)
288
+ loop do
289
+ html = open(url).read
290
+
291
+ if html.include?("TestLab is complete")
292
+ break
293
+ else
294
+ sleep(10) # wait for 10 seconds before checking again
295
+ end
296
+ end
297
+ end
298
+
248
299
  def self.example_code
249
300
 
250
301
  end
@@ -105,6 +105,10 @@ module Fastlane
105
105
  return success, body
106
106
  end
107
107
 
108
+ def self.swit_body_text(body_text)
109
+
110
+ end
111
+
108
112
  def self.make_github_text(json, project_id, bucket, dir, test_type)
109
113
  prefix = "<img src=\"https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android/blob/master/art/firebase_test_lab_logo.png?raw=true\" width=\"65%\" loading=\"lazy\" />"
110
114
  cells = json.map { |data|
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AndroidTestlabScriptSwit
3
- VERSION = "0.1.35"
3
+ VERSION = "0.1.37"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-android_testlab_script_swit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.35
4
+ version: 0.1.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - 나비이쁜이