Class: Fastlane::Actions::RunTestsFirebaseTestlabAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::RunTestsFirebaseTestlabAction
- Defined in:
- lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb
Constant Summary collapse
- PIPE =
"testlab-pipe"
Class Attribute Summary collapse
-
.client_secret_file ⇒ Object
readonly
Returns the value of attribute client_secret_file.
-
.test_console_output_file ⇒ Object
readonly
Returns the value of attribute test_console_output_file.
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
Class Attribute Details
.client_secret_file ⇒ Object (readonly)
Returns the value of attribute client_secret_file.
9 10 11 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 9 def client_secret_file @client_secret_file end |
.test_console_output_file ⇒ Object (readonly)
Returns the value of attribute test_console_output_file.
9 10 11 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 9 def test_console_output_file @test_console_output_file end |
Class Method Details
.authors ⇒ Object
72 73 74 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 72 def self. ["bffcorreia"] end |
.available_options ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 95 def self. [ FastlaneCore::ConfigItem.new(key: :project_id, env_name: "PROJECT_ID", description: "Your Firebase project id", is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :devices, env_name: "DEVICES", description: "Devices to test the App on", type: Array, optional: true, verify_block: proc do |devices| devices.each do |d| if d.class != Hash UI.user_error!("Each device must be represented by a Hash object, #{d.class} found") end check_has_property(d, :model) check_has_property(d, :version) set_default_property(d, :locale, "en_US") set_default_property(d, :orientation, "portrait") end end), FastlaneCore::ConfigItem.new(key: :model, env_name: "MODEL", description: "The device's model on which the tests will be run", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :version, env_name: "VERSION", description: "The Android api version of the device", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :app_apk, env_name: "APP_APK", description: "The path for your app apk. Default: app/build/outputs/apk/debug/app-debug.apk", is_string: true, optional: true, default_value: "app/build/outputs/apk/debug/app-debug.apk"), FastlaneCore::ConfigItem.new(key: :android_test_apk, env_name: "ANDROID_TEST_APK", description: "The path for your android test apk. Default: app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk", is_string: true, optional: true, default_value: "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"), FastlaneCore::ConfigItem.new(key: :locale, env_name: "LOCALE", description: "The locale to test against. Default: en_US", is_string: true, optional: true, default_value: "en_US"), FastlaneCore::ConfigItem.new(key: :orientation, env_name: "ORIENTATION", description: "The orientation of the device. Default: portrait", is_string: true, optional: true, default_value: "portrait"), FastlaneCore::ConfigItem.new(key: :timeout, env_name: "TIMEOUT", description: "The max time this test execution can run before it is cancelled. Default: 30m", is_string: true, optional: true, default_value: "30m"), FastlaneCore::ConfigItem.new(key: :output_dir, env_name: "OUTPUT_DIR", description: "The directory to save the output results. Default: firebase", is_string: true, optional: true, default_value: "firebase"), FastlaneCore::ConfigItem.new(key: :bucket_url, env_name: "BUCKET_URL", description: "The bucket url where the test results were stored. Default: Parsed automatically from tests output", is_string: true, optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :delete_firebase_files, env_name: "DELETE_FIREBASE_FILES", description: "A flag to controll if the firebase files should be deleted from the bucket or not. Default: false", is_string: false, optional: true, default_value: false), FastlaneCore::ConfigItem.new(key: :extra_options, env_name: "EXTRA_OPTIONS", description: "Extra options that you need to pass to the gcloud command. Default: empty string", is_string: true, optional: true, default_value: ""), FastlaneCore::ConfigItem.new(key: :gcloud_service_key_file, env_name: "GCLOUD_SERVICE_KEY_FILE", description: "File path containing the gcloud auth key. Default: Created from GCLOUD_SERVICE_KEY environment variable", is_string: true, optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :download_results_from_firebase, env_name: "SHOULD_DOWNLOAD_FROM_FIREBASE", description: "A flag to control if the firebase files should be downloaded from the bucket or not. Default: true", is_string: false, optional: true, default_value: true) ] end |
.category ⇒ Object
216 217 218 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 216 def self.category :testing end |
.description ⇒ Object
68 69 70 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 68 def self.description "Runs Android tests in Firebase Test Lab." end |
.details ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 76 def self.details [ "Authenticates with Google Cloud.", "Runs tests in Firebase Test Lab.", "Fetches the results to a local directory.", "Deletes the results from firebase bucket if wanted." ].join("\n") end |
.example_code ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 201 def self.example_code [ 'run_tests_firebase_testlab( project_id: "your-firebase-project-id", devices: [ { model: "Nexus6P", version: "27" } ], delete_firebase_files: true )' ] end |
.is_supported?(platform) ⇒ Boolean
197 198 199 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 197 def self.is_supported?(platform) platform == :android end |
.output ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 85 def self.output [ ['bugreport.txt', 'A bugreport of the app.'], ['instrumentation.results', 'The results of the instrumentation tests.'], ['logcat', 'Logs from logcat.'], ['test_result_0.xml', 'A xml file that contains all the tests.'], ['video.mp4', 'A video of the tests.'] ] end |
.run(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fastlane/plugin/run_tests_firebase_testlab/actions/run_tests_firebase_testlab_action.rb', line 12 def self.run(params) UI.("Starting run_tests_firebase_testlab plugin...") validate_params(params) if params[:gcloud_service_key_file].nil? UI.("Save Google Cloud credentials.") File.open(@client_secret_file, 'w') do |file| file.write(ENV["GCLOUD_SERVICE_KEY"]) end else @client_secret_file = params[:gcloud_service_key_file] end UI.("Set Google Cloud target project.") Action.sh("#{Commands.config} #{params[:project_id]}") UI.("Authenticate with Google Cloud.") Action.sh("#{Commands.auth} --key-file #{@client_secret_file}") UI.("Running instrumentation tests in Firebase Test Lab...") remove_pipe_if_exists Action.sh("mkfifo #{PIPE}") begin Action.sh("tee #{@test_console_output_file} < #{PIPE} & "\ "#{Commands.run_tests} "\ "--type instrumentation "\ "--app #{params[:app_apk]} "\ "--test #{params[:android_test_apk]} "\ "#{create_devices_params(params)}"\ "--timeout #{params[:timeout]} "\ "#{params[:extra_options]} > #{PIPE} 2>&1") ensure remove_pipe_if_exists UI.("Create firebase directory (if not exists) to store test results.") FileUtils.mkdir_p(params[:output_dir]) if params[:bucket_url].nil? UI.("Parse firebase bucket url.") params[:bucket_url] = scrape_bucket_url UI.("bucket: #{params[:bucket_url]}") end if params[:download_results_from_firebase] UI.("Downloading instrumentation test results from Firebase Test Lab...") Action.sh("#{Commands.download_results} #{params[:bucket_url]} #{params[:output_dir]}") end if params[:delete_firebase_files] UI.("Deleting files from firebase storage...") Action.sh("#{Commands.delete_resuls} #{params[:bucket_url]}") end end end |