|
3 | 3 | module Fastlane
|
4 | 4 | module Actions
|
5 | 5 | module SharedValues
|
6 |
| - FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE |
| 6 | + FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE # FirebaseTestLabResult object, for internal consumption |
7 | 7 | FIREBASE_TEST_LOG_FILE_PATH = :FIREBASE_TEST_LOG_FILE_PATH
|
| 8 | + FIREBASE_TEST_MORE_DETAILS_URL = :FIREBASE_TEST_MORE_DETAILS_URL |
8 | 9 | end
|
9 | 10 |
|
10 | 11 | class AndroidFirebaseTestAction < Action
|
@@ -45,13 +46,20 @@ def self.run(params)
|
45 | 46 | key_file_path: params[:key_file]
|
46 | 47 | )
|
47 | 48 |
|
48 |
| - FastlaneCore::UI.test_failure! "Firebase Tests failed – more information can be found at #{result.more_details_url}" unless result.success? |
| 49 | + Fastlane::Actions.lane_context[SharedValues::FIREBASE_TEST_MORE_DETAILS_URL] = result.more_details_url |
49 | 50 |
|
50 |
| - UI.success 'Firebase Tests Complete' |
| 51 | + if result.success? |
| 52 | + UI.success 'Firebase Tests Complete' |
| 53 | + return true |
| 54 | + else |
| 55 | + ui_method = params[:crash_on_test_failure] ? :test_failure! : :error |
| 56 | + FastlaneCore::UI.send(ui_method, "Firebase Tests failed – more information can be found at #{result.more_details_url}") |
| 57 | + return false |
| 58 | + end |
51 | 59 | end
|
52 | 60 |
|
53 | 61 | # Fastlane doesn't eagerly validate options for us, so we'll do it first to have control over
|
54 |
| - # when they're evalutated. |
| 62 | + # when they're evaluated. |
55 | 63 | def self.validate_options(params)
|
56 | 64 | available_options
|
57 | 65 | .reject { |opt| opt.optional || !opt.default_value.nil? }
|
@@ -180,9 +188,28 @@ def self.available_options
|
180 | 188 | optional: true,
|
181 | 189 | type: String
|
182 | 190 | ),
|
| 191 | + FastlaneCore::ConfigItem.new( |
| 192 | + key: :crash_on_test_failure, |
| 193 | + description: 'If set to `true` (the default), will stop fastlane with `test_failure!`. ' \ |
| 194 | + + 'If `false`, the action will return the test status, without interrupting the rest of your Fastlane run on failure, letting the caller handle the failure on their side', |
| 195 | + optional: true, |
| 196 | + type: Boolean, |
| 197 | + default_value: true |
| 198 | + ), |
183 | 199 | ]
|
184 | 200 | end
|
185 | 201 |
|
| 202 | + def self.output |
| 203 | + [ |
| 204 | + ['FIREBASE_TEST_LOG_FILE_PATH', 'Path to the `output.log` file containing the logs or invoking the tests'], |
| 205 | + ['FIREBASE_TEST_MORE_DETAILS_URL', 'URL to the Firebase Console dashboard showing the details of the test run (and failures, if any)'], |
| 206 | + ] |
| 207 | + end |
| 208 | + |
| 209 | + def self.return_value |
| 210 | + 'True if the test succeeded, false if they failed' |
| 211 | + end |
| 212 | + |
186 | 213 | def self.authors
|
187 | 214 | ['Automattic']
|
188 | 215 | end
|
|
0 commit comments