fastlane-plugin-android_testlab_script_swit 0.1.0 → 0.1.1
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 +4 -4
- data/lib/fastlane/plugin/android_testlab_script_swit/actions/android_testlab_script_swit_action.rb +1 -1
- data/lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb +131 -8
- data/lib/fastlane/plugin/android_testlab_script_swit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90925af61109137f31adaef901546546b2f4d1267ea3543498eddc0ee1c29918
|
4
|
+
data.tar.gz: 326ce020193510ac39afde3c317c5af83454a84e2dcb7abf24b09fc850b6f580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd0300e61403d752e7422a7e6eb956221ef3172435edd6abba8f58c719facb188fed92966dbe39e6fb6dd24a19f23f7a140778f49a8b076702cf2efd4540eef
|
7
|
+
data.tar.gz: 51df4aa680c547cbd5aa8d3d6b47839e42eb0f2e0dac5b4702ffb809c45f94d03039ba571846d7335c8e0e6e0f086ac5c34c978a2e10b7ea40c8584858d0aa60
|
data/lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb
CHANGED
@@ -1,16 +1,139 @@
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
2
2
|
|
3
3
|
module Fastlane
|
4
|
-
|
4
|
+
|
5
|
+
# Outcome
|
6
|
+
PASSED = 'Passed'
|
7
|
+
FAILED = 'Failed'
|
8
|
+
SKIPPED = 'Skipped'
|
9
|
+
INCONCLUSIVE = 'Inconclusive'
|
5
10
|
|
6
11
|
module Helper
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
|
13
|
+
def self.gcs_result_bucket_url(bucket, dir)
|
14
|
+
"https://console.developers.google.com/storage/browser/#{bucket}/#{CGI.escape(dir)}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.gcs_object_url(bucket, path)
|
18
|
+
"https://storage.googleapis.com/#{bucket}/#{CGI.escape(path)}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.firebase_test_lab_histories_url(project_id)
|
22
|
+
"https://console.firebase.google.com/u/0/project/#{project_id}/testlab/histories/"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.config(project_id)
|
26
|
+
UI.message "Set Google Cloud target project"
|
27
|
+
Action.sh("gcloud config set project #{project_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.authenticate(gcloud_key_file)
|
31
|
+
UI.message "Authenticate with GCP"
|
32
|
+
Action.sh("gcloud auth activate-service-account --key-file #{gcloud_key_file}")
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.run_tests(gcloud_components_channel, arguments)
|
36
|
+
UI.message("Test running...")
|
37
|
+
Action.sh("set +e; gcloud #{gcloud_components_channel unless gcloud_components_channel == "stable"} firebase test android run #{arguments}; set -e")
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.copy_from_gcs(bucket_and_path, copy_to)
|
41
|
+
UI.message("Copy from gs://#{bucket_and_path}")
|
42
|
+
Action.sh("gsutil -m cp -r gs://#{bucket_and_path} #{copy_to}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.set_public(bucket_and_path)
|
46
|
+
UI.message("Set public for reading gs://#{bucket_and_path}")
|
47
|
+
Action.sh("gsutil -m acl -r set public-read gs://#{bucket_and_path}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.is_failure(outcome)
|
51
|
+
outcome == FAILED || outcome == INCONCLUSIVE
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.if_need_dir(path)
|
55
|
+
dirname = File.dirname(path)
|
56
|
+
unless File.directory?(dirname)
|
57
|
+
UI.message("Crate directory: #{dirname}")
|
58
|
+
FileUtils.mkdir_p(dirname)
|
13
59
|
end
|
60
|
+
path
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.split_device_name(axis_value)
|
64
|
+
# Sample Nexus6P-23-ja_JP-portrait
|
65
|
+
array = axis_value.split("-")
|
66
|
+
"#{array[0]} (API #{array[1]})"
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.emoji_status(outcome)
|
70
|
+
# Github emoji list
|
71
|
+
# https://github.com/ikatyang/emoji-cheat-sheet
|
72
|
+
return case outcome
|
73
|
+
when PASSED
|
74
|
+
":tada:"
|
75
|
+
when FAILED
|
76
|
+
":fire:"
|
77
|
+
when INCONCLUSIVE
|
78
|
+
":warning:"
|
79
|
+
when SKIPPED
|
80
|
+
":expressionless:"
|
81
|
+
else
|
82
|
+
":question:"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.random_emoji_cat
|
87
|
+
# Github emoji list
|
88
|
+
# https://github.com/ikatyang/emoji-cheat-sheet#cat-face
|
89
|
+
%w(:smiley_cat: :smile_cat: :joy_cat: :heart_eyes_cat: :smirk_cat: :kissing_cat:).sample
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.make_slack_text(json)
|
93
|
+
success = true
|
94
|
+
json.each do |status|
|
95
|
+
success = !is_failure(status["outcome"])
|
96
|
+
break unless success
|
97
|
+
end
|
98
|
+
|
99
|
+
body = json.map { |status|
|
100
|
+
outcome = status["outcome"]
|
101
|
+
emoji = emoji_status(outcome)
|
102
|
+
device = split_device_name(status["axis_value"])
|
103
|
+
"#{device}: #{emoji} #{outcome}\n"
|
104
|
+
}.inject(&:+)
|
105
|
+
return success, body
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.make_github_text(json, project_id, bucket, dir, test_type)
|
109
|
+
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
|
+
cells = json.map { |data|
|
111
|
+
axis = data["axis_value"]
|
112
|
+
device = split_device_name(axis)
|
113
|
+
outcome = data["outcome"]
|
114
|
+
status = "#{emoji_status(outcome)} #{outcome}"
|
115
|
+
message = data["test_details"]
|
116
|
+
logcat = "<a href=\"#{gcs_object_url(bucket, "#{dir}/#{axis}/logcat")}\" target=\"_blank\" >#{random_emoji_cat}</a>"
|
117
|
+
if test_type == "robo"
|
118
|
+
sitemp = "<img src=\"#{gcs_object_url(bucket, "#{dir}/#{axis}/artifacts/sitemap.png")}\" height=\"64px\" loading=\"lazy\" target=\"_blank\" />"
|
119
|
+
else
|
120
|
+
sitemp = "--"
|
121
|
+
end
|
122
|
+
|
123
|
+
"| **#{device}** | #{status} | #{message} | #{logcat} | #{sitemp} |\n"
|
124
|
+
}.inject(&:+)
|
125
|
+
comment = <<~EOS
|
126
|
+
#{prefix}
|
127
|
+
|
128
|
+
### Results
|
129
|
+
Firebase console: [#{project_id}](#{Helper.firebase_test_lab_histories_url(project_id)})
|
130
|
+
Test results: [#{dir}](#{Helper.gcs_result_bucket_url(bucket, dir)})
|
131
|
+
|
132
|
+
| :iphone: Device | :thermometer: Status | :memo: Message | :eyes: Logcat | :japan: Sitemap |
|
133
|
+
| --- | :---: | --- | :---: | :---: |
|
134
|
+
#{cells}
|
135
|
+
EOS
|
136
|
+
return prefix, comment
|
14
137
|
end
|
15
138
|
end
|
16
|
-
end
|
139
|
+
end
|