Skip to content

Commit b6ffaac

Browse files
authored
Merge pull request #430 from wordpress-mobile/firebase-test-return-url
Add ability for the caller to handle the firebase failures
2 parents dab6b16 + c7721e4 commit b6ffaac

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ _None_
1010

1111
### New Features
1212

13-
_None_
13+
* Allow `android_firebase_test` to not crash on failure, letting the caller do custom failure handling (e.g. Buildkite Annotations, etc) on their side. [#430]
1414

1515
### Bug Fixes
1616

lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
module Fastlane
44
module Actions
55
module SharedValues
6-
FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE
6+
FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE # FirebaseTestLabResult object, for internal consumption
77
FIREBASE_TEST_LOG_FILE_PATH = :FIREBASE_TEST_LOG_FILE_PATH
8+
FIREBASE_TEST_MORE_DETAILS_URL = :FIREBASE_TEST_MORE_DETAILS_URL
89
end
910

1011
class AndroidFirebaseTestAction < Action
@@ -45,13 +46,20 @@ def self.run(params)
4546
key_file_path: params[:key_file]
4647
)
4748

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
4950

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
5159
end
5260

5361
# 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.
5563
def self.validate_options(params)
5664
available_options
5765
.reject { |opt| opt.optional || !opt.default_value.nil? }
@@ -180,9 +188,28 @@ def self.available_options
180188
optional: true,
181189
type: String
182190
),
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+
),
183199
]
184200
end
185201

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+
186213
def self.authors
187214
['Automattic']
188215
end

0 commit comments

Comments
 (0)