Module: Fastlane::Helper
- Defined in:
- lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb
Class Method Summary collapse
- .authenticate(gcloud_key_file) ⇒ Object
- .config(project_id) ⇒ Object
- .copy_from_gcs(bucket_and_path, copy_to) ⇒ Object
- .emoji_status(outcome) ⇒ Object
- .firebase_test_lab_histories_url(project_id) ⇒ Object
- .gcs_object_url(bucket, path) ⇒ Object
- .gcs_result_bucket_url(bucket, dir) ⇒ Object
- .if_need_dir(path) ⇒ Object
- .is_failure(outcome) ⇒ Object
- .make_github_text(json, project_id, bucket, dir, test_type) ⇒ Object
- .make_slack_text(json) ⇒ Object
- .random_emoji_cat ⇒ Object
- .run_tests(gcloud_components_channel, arguments) ⇒ Object
- .set_public(bucket_and_path) ⇒ Object
- .split_device_name(axis_value) ⇒ Object
- .swit_body_text(body_text) ⇒ Object
Class Method Details
.authenticate(gcloud_key_file) ⇒ Object
30 31 32 33 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 30 def self.authenticate(gcloud_key_file) UI. "Authenticate with GCP" Action.sh("gcloud auth activate-service-account --key-file #{gcloud_key_file}") end |
.config(project_id) ⇒ Object
25 26 27 28 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 25 def self.config(project_id) UI. "Set Google Cloud target project" Action.sh("gcloud config set project #{project_id}") end |
.copy_from_gcs(bucket_and_path, copy_to) ⇒ Object
47 48 49 50 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 47 def self.copy_from_gcs(bucket_and_path, copy_to) UI.("Copy from gs://#{bucket_and_path}") Action.sh("gsutil -m cp -r gs://#{bucket_and_path} #{copy_to}") end |
.emoji_status(outcome) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 76 def self.emoji_status(outcome) # Github emoji list # https://github.com/ikatyang/emoji-cheat-sheet return case outcome when PASSED ":tada:" when FAILED ":fire:" when INCONCLUSIVE ":warning:" when SKIPPED ":expressionless:" else ":question:" end end |
.firebase_test_lab_histories_url(project_id) ⇒ Object
21 22 23 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 21 def self.firebase_test_lab_histories_url(project_id) "https://console.firebase.google.com/u/0/project/#{project_id}/testlab/histories/" end |
.gcs_object_url(bucket, path) ⇒ Object
17 18 19 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 17 def self.gcs_object_url(bucket, path) "https://storage.googleapis.com/#{bucket}/#{CGI.escape(path)}" end |
.gcs_result_bucket_url(bucket, dir) ⇒ Object
13 14 15 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 13 def self.gcs_result_bucket_url(bucket, dir) "https://console.developers.google.com/storage/browser/#{bucket}/#{CGI.escape(dir)}" end |
.if_need_dir(path) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 61 def self.if_need_dir(path) dirname = File.dirname(path) unless File.directory?(dirname) UI.("Crate directory: #{dirname}") FileUtils.mkdir_p(dirname) end path end |
.is_failure(outcome) ⇒ Object
57 58 59 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 57 def self.is_failure(outcome) outcome == FAILED || outcome == INCONCLUSIVE end |
.make_github_text(json, project_id, bucket, dir, test_type) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 119 def self.make_github_text(json, project_id, bucket, dir, test_type) 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\" />" cells = json.map { |data| axis = data["axis_value"] device = split_device_name(axis) outcome = data["outcome"] status = "#{emoji_status(outcome)} #{outcome}" = data["test_details"] logcat = "<a href=\"#{gcs_object_url(bucket, "#{dir}/#{axis}/logcat")}\" target=\"_blank\" >#{random_emoji_cat}</a>" if test_type == "robo" sitemp = "<img src=\"#{gcs_object_url(bucket, "#{dir}/#{axis}/artifacts/sitemap.png")}\" height=\"64px\" loading=\"lazy\" target=\"_blank\" />" else sitemp = "--" end "| **#{device}** | #{status} | #{message} | #{logcat} | #{sitemp} |\n" }.inject(&:+) comment = " \#{prefix}\n\n ### Results\n Firebase console: [\#{project_id}](\#{Helper.firebase_test_lab_histories_url(project_id)})\n Test results: [\#{dir}](\#{Helper.gcs_result_bucket_url(bucket, dir)})\n\n | :iphone: Device | :thermometer: Status | :memo: Message | :eyes: Logcat | :japan: Sitemap |\n | --- | :---: | --- | :---: | :---: |\n \#{cells}\n EOS\n return prefix, comment\nend\n" |
.make_slack_text(json) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 99 def self.make_slack_text(json) success = true json.each do |status| success = !is_failure(status["outcome"]) break unless success end body = json.map { |status| outcome = status["outcome"] emoji = emoji_status(outcome) device = split_device_name(status["axis_value"]) "#{device}: #{emoji} #{outcome}\n" }.inject(&:+) return success, body end |
.random_emoji_cat ⇒ Object
93 94 95 96 97 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 93 def self.random_emoji_cat # Github emoji list # https://github.com/ikatyang/emoji-cheat-sheet#cat-face %w(:smiley_cat: :smile_cat: :joy_cat: :heart_eyes_cat: :smirk_cat: :kissing_cat:).sample end |
.run_tests(gcloud_components_channel, arguments) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 35 def self.run_tests(gcloud_components_channel, arguments) UI.("Test running...") Action.sh("set +e; gcloud #{gcloud_components_channel} firebase test android run #{arguments}; set -e") # 커스텀 1 # Action.sh("set +e; gcloud#{' ' + gcloud_components_channel unless gcloud_components_channel == "stable"} firebase test android run #{arguments}; set -e") # 원본 # Action.sh("set +e; gcloud #{gcloud_components_channel unless gcloud_components_channel == "stable"} firebase test android run #{arguments}; set -e") end |
.set_public(bucket_and_path) ⇒ Object
52 53 54 55 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 52 def self.set_public(bucket_and_path) UI.("Set public for reading gs://#{bucket_and_path}") Action.sh("gsutil -m acl -r set public-read gs://#{bucket_and_path}") end |
.split_device_name(axis_value) ⇒ Object
70 71 72 73 74 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 70 def self.split_device_name(axis_value) # Sample Nexus6P-23-ja_JP-portrait array = axis_value.split("-") "#{array[0]} (API #{array[1]})" end |
.swit_body_text(body_text) ⇒ Object
115 116 117 |
# File 'lib/fastlane/plugin/android_testlab_script_swit/helper/android_testlab_script_swit_helper.rb', line 115 def self.swit_body_text(body_text) end |