fastlane-plugin-android_reporter 0.0.8 → 0.1.15

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: f0b90169f94878450b4e1aa646ed3c76117bf8ff2a222dc4d4e6a1fc94c696f1
4
- data.tar.gz: f24479c3dcf65f4bb5a0f897654d3d73ce459af8469b1dba1268681a1d14b712
3
+ metadata.gz: d9d0979d38024ecd245c1814c4f4576b1506c7d5e9937905537b02062467bdf9
4
+ data.tar.gz: 13ad3cd3084e9d568608482ca58be913891e320ffbafcf359892f16e959d8609
5
5
  SHA512:
6
- metadata.gz: 1b1a165e6ad6b85e910226f0b0912b71e2e72621db12af3d8e6ffeac8c74f008b14775fe6a7feb63bc061851b15f9482557ba854d59fc968494498a52d64c762
7
- data.tar.gz: 7cb249b370ddc99d3692017e98b23616fefae53497efa83a153a2fe3ba512db5a0ab74cc988c00016f763165a29da699cd7a7b1eee30c1b55ac4de98dd4deb95
6
+ metadata.gz: 8f486801c352929c9f20dc61d7601191b4b271c38928a00bf74f4ed477d484bad2aced4ef2980ec30d425c56733efcd462078e5c7debb88bd26d12b4c6d777c0
7
+ data.tar.gz: 728fede9eeb5dfea9a87ba4e3e703600bfaed29e311857b5284a718a7cc85da2485cfd199ce10fca46d2d4548f731adbd81306d98fa2b1c74ced6499a3c2629e
@@ -1,6 +1,9 @@
1
1
  require 'fastlane/action'
2
2
  require_relative '../helper/android_reporter_helper'
3
3
  require 'open3'
4
+ require 'date'
5
+ require 'rubygems'
6
+ require 'slack-ruby-client'
4
7
 
5
8
  module Fastlane
6
9
  module Actions
@@ -14,7 +17,50 @@ module Fastlane
14
17
  generate_adb_file = params[:generate_adb_file]
15
18
  generate_gradle_files = params[:generate_gradle_files]
16
19
  gradle_task_testing_name = params[:gradle_task_testing_name]
20
+ is_slack_enabled = params[:is_slack_upload_reports_enabled]
21
+ slack_api_key = params[:slack_api_key]
22
+ time = Time.now.to_s
23
+ time = DateTime.parse(time).strftime("%d/%m/%Y %H:%M")
24
+ isLogcatFileUploaded = false
25
+ isGradleDebugFileUploaded = false
26
+ isGradleErrorFileUploaded = false
17
27
 
28
+ # 0. Checkout git to Current Branch to Run Tests on the Current Branch
29
+ if params[:tests_branch_name].to_s.length > 0
30
+ begin
31
+ sh("git fetch")
32
+ sh("git checkout ", params[:tests_branch_name].string)
33
+ rescue => error
34
+ UI.error("Something Error with Git Commands")
35
+ end
36
+ end
37
+
38
+ # 1. Send Slack Message from Android Reporter Bot That Testing Task Has been Started ....
39
+ if is_slack_enabled
40
+ UI.message("Slack Messages Bot Started .... [Configuration Step]")
41
+ Slack.configure do |config|
42
+ config.token = slack_api_key
43
+ end
44
+ client = Slack::Web::Client.new
45
+ begin
46
+ client.chat_postMessage(
47
+ channel: "#" + params[:slack_channel_name],
48
+ text: " ================================================================================== \n" +
49
+ " New UI Testing Task Started For Current Release : " + time + " \n " +
50
+ " Current Branch Build : " + sh("git branch") +
51
+ " ================================================================================== \n",
52
+ as_user: true
53
+ )
54
+
55
+ UI.message("Slack Build Task Message Result : [Send First Task Message] ")
56
+ rescue => error
57
+ UI.error("Something Error with Slack Configuration : [Failed Send First Task Message]")
58
+ puts error.backtrace
59
+ end
60
+ end
61
+
62
+ # 2. List All Available AVD's in The Device
63
+ # 3. Run the Target AVD Name From Params
18
64
  if params[:avd_name].to_s.length > 0
19
65
  Thread.new do
20
66
  UI.message("Android Reporting Started to Run AVD : (" + avd_name + ")")
@@ -23,22 +69,23 @@ module Fastlane
23
69
  sh(android_sdk_path + "/emulator/emulator", "-avd", avd_name)
24
70
  end
25
71
  end
26
- #
27
72
 
73
+ # 4. Clear the Logcat Server Before Start
28
74
  if params[:generate_adb_file]
29
75
  Process.fork do
30
76
  sh("adb logcat -c")
31
77
  end
32
78
  end
33
79
 
34
-
35
- sh("./gradlew clean")
80
+ # 5. Start Clean Task with Target UI Task
81
+ # 6. If Gradle Task Success then Will Generate ADB Log File then Kill Server Connection inside ADB
36
82
  begin
37
83
  UI.message([
38
84
  "Android Reporting Started to Run Gradle Testing Task ...",
39
85
  "Gradle Tasks : [Clean , Build , " + gradle_task_testing_name + "]"
40
86
  ])
41
87
  if params[:gradle_task_testing_name].to_s.length > 0
88
+ sh("./gradlew clean")
42
89
  gradle_task_result = sh("./gradlew " + gradle_task_testing_name)
43
90
  if gradle_task_result
44
91
  UI.message("Gradle Task Finished Successfully ...")
@@ -62,6 +109,7 @@ module Fastlane
62
109
  end
63
110
  end
64
111
 
112
+ # 7. Generate Gradle Tasks (Failed and Success Files)
65
113
  if params[:generate_gradle_files]
66
114
  Process.fork do
67
115
  sh("./gradlew build > android-logs.txt 2> android-error-logs.txt")
@@ -73,6 +121,110 @@ module Fastlane
73
121
  end
74
122
  end
75
123
 
124
+ # 8. Check Slack Option if Enabled or Not To Print The Message
125
+ if is_slack_enabled
126
+ UI.message("Slack Configuration Status : Started ...")
127
+ else
128
+ UI.message("Slack Configuration Status : Disabled ...")
129
+ end
130
+
131
+ # 9. Upload Files to Slack
132
+ if is_slack_enabled
133
+ begin
134
+ UI.message("Slack Messages Bot Upload Files Tasks Started ....")
135
+ if(File.exist?("logcat.txt"))
136
+ UI.message("logcat.txt File exists ...")
137
+ client.files_upload(
138
+ channels: "#" + params[:slack_channel_name],
139
+ as_user: true,
140
+ file: Faraday::UploadIO.new('logcat.txt', 'text/plain'),
141
+ title: "Android UI Testing (ADB Logcat Result)",
142
+ filename: "logcat.txt",
143
+ initial_comment: "Current UI Testing Build Result File Report [logcat.txt]"
144
+ )
145
+
146
+ isLogcatFileUploaded = true
147
+ UI.message("Slack Step Upload [logcat.txt]")
148
+ else
149
+ isLogcatFileUploaded = false
150
+ UI.error("File does not exist [logcat.txt]")
151
+ end
152
+ rescue => error
153
+ if error
154
+ UI.error("Something Error with Slack Upload File : [Step Upload Logcat.txt File to Slack]")
155
+ end
156
+ puts error.message
157
+ puts error.backtrace
158
+ end
159
+
160
+ begin
161
+ if(File.exist?("android-logs.txt"))
162
+ UI.message("android-logs.txt File exists ...")
163
+ client.files_upload(
164
+ channels: "#" + params[:slack_channel_name],
165
+ as_user: true,
166
+ file: Faraday::UploadIO.new('android-logs.txt', 'text/plain'),
167
+ title: "Android UI Testing (Gradle Debug File Result)",
168
+ filename: "android-logs.txt",
169
+ initial_comment: "Current UI Testing Build Result File Report [Gradle Debug Result]"
170
+ )
171
+
172
+ isGradleDebugFileUploaded = true
173
+ UI.message("Slack Step Upload [android-logs.txt]")
174
+ else
175
+ isGradleDebugFileUploaded = false
176
+ UI.error("File does not exist [android-logs.txt]")
177
+ end
178
+ rescue => error
179
+ if error
180
+ UI.error("Something Error with Slack Upload File : [Step Upload Logcat.txt File to Slack]")
181
+ end
182
+ puts error.message
183
+ puts error.backtrace
184
+ end
185
+
186
+ begin
187
+ if(File.exist?("android-error-logs.txt"))
188
+ UI.message("android-error-logs.txt File exists ...")
189
+ client.files_upload(
190
+ channels: "#" + params[:slack_channel_name],
191
+ as_user: true,
192
+ file: Faraday::UploadIO.new('android-error-logs.txt', 'text/plain'),
193
+ title: "Android UI Testing (Gradle Error File Result)",
194
+ filename: "android-error-logs.txt",
195
+ initial_comment: "Current UI Testing Build Result File Report [Gradle Error Result]"
196
+ )
197
+
198
+ isGradleErrorFileUploaded = true
199
+ UI.message("Slack Step Upload [android-error-logs.txt]")
200
+ else
201
+ isGradleErrorFileUploaded = false
202
+ UI.error("File does not exist [android-error-logs.txt]")
203
+ end
204
+ rescue => error
205
+ if error
206
+ UI.error("Something Error with Slack Upload File : [Step Upload Logcat.txt File to Slack]")
207
+ end
208
+ puts error.message
209
+ puts error.backtrace
210
+ end
211
+
212
+ slackFinalMessageContent = "Files Status : With Time : " + time + " : Info = \n"
213
+ if isGradleDebugFileUploaded
214
+ slackFinalMessageContent += "Gradle Debug File Uploaded \n"
215
+ end
216
+
217
+ if isGradleErrorFileUploaded
218
+ slackFinalMessageContent += "Gradle Error File Uploaded \n"
219
+ end
220
+
221
+ if isLogcatFileUploaded
222
+ slackFinalMessageContent += "Logcat ADB Logging File Uploaded \n"
223
+ end
224
+
225
+ client.chat_postMessage(channel: "#" + params[:slack_channel_name], text: slackFinalMessageContent, as_user: true)
226
+ end
227
+
76
228
  end
77
229
 
78
230
  def self.description
@@ -131,6 +283,37 @@ module Fastlane
131
283
  description: "This Option will Generate Gradle Report File (Success File, Error File)",
132
284
  optional: true,
133
285
  type: Boolean
286
+ ),
287
+ FastlaneCore::ConfigItem.new(
288
+ key: :is_slack_upload_reports_enabled,
289
+ env_name: "ANDROID_REPORT_FILES_SLACK_UPLOAD_ENABLED",
290
+ description: "This Option will Check if Slack Upload Files Enabled or Not",
291
+ optional: true,
292
+ type: Boolean
293
+ ),
294
+ FastlaneCore::ConfigItem.new(
295
+ key: :slack_api_key,
296
+ env_name: "SLACK_API_TOKEN",
297
+ description: "Add Slack Api Key",
298
+ optional: true,
299
+ type: String,
300
+ sensitive: true
301
+ ),
302
+ FastlaneCore::ConfigItem.new(
303
+ key: :slack_channel_name,
304
+ env_name: "SLACK_CHANNEL_NAME",
305
+ description: "Add Slack Channel Name for Bot to Send Messages on this Channel",
306
+ optional: true,
307
+ type: String,
308
+ sensitive: true
309
+ ),
310
+ FastlaneCore::ConfigItem.new(
311
+ key: :tests_branch_name,
312
+ env_name: "TESTS_BRANCH_NAME",
313
+ description: "Add Branch TO Run Tests on Target Git Branch",
314
+ optional: true,
315
+ type: String,
316
+ sensitive: true
134
317
  )
135
318
  ]
136
319
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AndroidReporter
3
- VERSION = "0.0.8"
3
+ VERSION = "0.1.15"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-android_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yazan Tarifi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry