fastlane-plugin-android_testlab_script_swit 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e93124b8e59702a6ff9337ed377bf6ba3f1a9d33814915161f3e28370f8d3422
|
4
|
+
data.tar.gz: ba846c1b4b1f6a722ddcbafb81fe5424b71df30839e4f497ca3ce7f7e7e65289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e462efe0ee18e14df5346031555b8a5dbd1f0c7843e2550b5cbc435ce3532f08b89820f5be82066cc1b0864f229fc32d3eb7217ad4065f286ac1e1d48b3e00
|
7
|
+
data.tar.gz: 7f381468f6f55b1d4dac9caf2926066f8776630aeee817889db26c8fc442faa2071ea355971a20cde8cf54627d8810f3ebaaf4cf7b0b3e1e3bc2bb6292f87980
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 나비이쁜이
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|