fastlane-plugin-android_testlab_script_swit 0.1.0 → 0.1.1

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: 544c96a23ea810aac737ecc922a626b5502e1932268c9efbb4aec58c12f40b9b
4
- data.tar.gz: 52990223d6f31acf67041c4d44d4001d23b5d652b8ea0a2a03a560e990f04635
3
+ metadata.gz: 90925af61109137f31adaef901546546b2f4d1267ea3543498eddc0ee1c29918
4
+ data.tar.gz: 326ce020193510ac39afde3c317c5af83454a84e2dcb7abf24b09fc850b6f580
5
5
  SHA512:
6
- metadata.gz: 1aa78e6af867191f619ed47a4ad5c0f4797a5d4c5928aca118463edf43a16681282d9c83e322926e836c57b4935a1b9dde8de62ece5420849343795d3fa74513
7
- data.tar.gz: ef6c7314c32232b8a5b0696c0d31e64afd63a96d4ebacdbd90e9b6550b12b9cb89e419633a3bb1e72f12e145b6f57d44a4b0cc40252618e5c02284bf6d6582bc
6
+ metadata.gz: 2bd0300e61403d752e7422a7e6eb956221ef3172435edd6abba8f58c719facb188fed92966dbe39e6fb6dd24a19f23f7a140778f49a8b076702cf2efd4540eef
7
+ data.tar.gz: 51df4aa680c547cbd5aa8d3d6b47839e42eb0f2e0dac5b4702ffb809c45f94d03039ba571846d7335c8e0e6e0f086ac5c34c978a2e10b7ea40c8584858d0aa60
@@ -2,7 +2,7 @@ require 'fastlane/action'
2
2
  require 'json'
3
3
  require 'fileutils'
4
4
 
5
- require_relative '../helper/firebase_testlab_with_script_android_helper'
5
+ require_relative '../helper/android_testlab_script_swit_helper.rb'
6
6
 
7
7
  module Fastlane
8
8
  module Actions
@@ -1,16 +1,139 @@
1
1
  require 'fastlane_core/ui/ui'
2
2
 
3
3
  module Fastlane
4
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
4
+
5
+ # Outcome
6
+ PASSED = 'Passed'
7
+ FAILED = 'Failed'
8
+ SKIPPED = 'Skipped'
9
+ INCONCLUSIVE = 'Inconclusive'
5
10
 
6
11
  module Helper
7
- class AndroidTestlabScriptSwitHelper
8
- # class methods that you define here become available in your action
9
- # as `Helper::AndroidTestlabScriptSwitHelper.your_method`
10
- #
11
- def self.show_message
12
- UI.message("Hello from the android_testlab_script_swit plugin helper!")
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AndroidTestlabScriptSwit
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 나비이쁜이