fastlane-plugin-android_reporter 0.0.8 → 0.1.0

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