Module: Fastlane::Helper
- Defined in:
- lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb
Class Method Summary collapse
- .authenticate(gcloud_key_file) ⇒ Object
- .config(project_id) ⇒ Object
- .emoji_status(outcome) ⇒ Object
- .firebase_object_url(bucket, path) ⇒ Object
- .firebase_test_lab_histories_url(project_id) ⇒ Object
- .format_device_name(axis_value) ⇒ Object
- .gcs_result_bucket_url(bucket, dir) ⇒ Object
- .is_failure(outcome) ⇒ Object
- .make_github_text(json, project_id, bucket, dir) ⇒ Object
- .make_slack_text(json) ⇒ Object
- .random_emoji_cat ⇒ Object
- .run_tests(arguments) ⇒ Object
Class Method Details
.authenticate(gcloud_key_file) ⇒ Object
30 31 32 33 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/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/firebase_test_lab_android/helper/Helper.rb', line 25 def self.config(project_id) UI. "Set Google Cloud target project" Action.sh("gcloud config set project #{project_id}") end |
.emoji_status(outcome) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 50 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_object_url(bucket, path) ⇒ Object
17 18 19 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 17 def self.firebase_object_url(bucket, path) "https://firebasestorage.googleapis.com/v0/b/#{bucket}/o/#{CGI.escape(path)}?alt=media" end |
.firebase_test_lab_histories_url(project_id) ⇒ Object
21 22 23 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/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 |
.format_device_name(axis_value) ⇒ Object
44 45 46 47 48 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 44 def self.format_device_name(axis_value) # Sample Nexus6P-23-ja_JP-portrait array = axis_value.split("-") "#{array[0]} (API #{array[1]})" end |
.gcs_result_bucket_url(bucket, dir) ⇒ Object
13 14 15 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 13 def self.gcs_result_bucket_url(bucket, dir) "https://console.developers.google.com/storage/browser/#{bucket}/#{CGI.escape(dir)}" end |
.is_failure(outcome) ⇒ Object
40 41 42 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 40 def self.is_failure(outcome) outcome == FAILED || outcome == INCONCLUSIVE end |
.make_github_text(json, project_id, bucket, dir) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 89 def self.make_github_text(json, project_id, bucket, dir) 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 = format_device_name(axis) outcome = data["outcome"] status = "#{emoji_status(outcome)} #{outcome}" = data["test_details"] logcat = "<a href=\"#{firebase_object_url(bucket, "#{dir}/#{axis}/logcat")}\" target=\"_blank\" >#{random_emoji_cat}</a>" sitemp = "<img src=\"#{firebase_object_url(bucket, "#{dir}/#{axis}/artifacts/sitemap.png")}\" height=\"64px\" loading=\"lazy\" target=\"_blank\" />" "| **#{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
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 73 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 = format_device_name(status["axis_value"]) "#{device}: #{emoji} #{outcome}\n" }.inject(&:+) return success, body end |
.random_emoji_cat ⇒ Object
67 68 69 70 71 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 67 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(arguments) ⇒ Object
35 36 37 38 |
# File 'lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb', line 35 def self.run_tests(arguments) UI.("Test running...") Action.sh("gcloud firebase test android run #{arguments}") end |