From 1485c65b1a65689a991dff364580229b317253e0 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 30 Nov 2022 12:58:24 +0100 Subject: [PATCH 1/3] Add ability for the caller to handle the firebase failures Especially so they can use `buildkite-annotate` and/or do other steps to report the failure before bailing --- .../actions/android/android_firebase_test.rb | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb index c33789d03..0b0bb5998 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb @@ -3,8 +3,9 @@ module Fastlane module Actions module SharedValues - FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE + FIREBASE_TEST_RESULT = :FIREBASE_TEST_LOG_FILE # FirebaseTestLabResult object, for internal consumption FIREBASE_TEST_LOG_FILE_PATH = :FIREBASE_TEST_LOG_FILE_PATH + FIREBASE_TEST_MORE_DETAILS_URL = :FIREBASE_TEST_MORE_DETAILS_URL end class AndroidFirebaseTestAction < Action @@ -45,13 +46,20 @@ def self.run(params) key_file_path: params[:key_file] ) - FastlaneCore::UI.test_failure! "Firebase Tests failed – more information can be found at #{result.more_details_url}" unless result.success? + Fastlane::Actions.lane_context[SharedValues::FIREBASE_TEST_MORE_DETAILS_URL] = result.more_details_url - UI.success 'Firebase Tests Complete' + if result.success? + UI.success 'Firebase Tests Complete' + return true + else + ui_method = params[:crash_on_test_failure] ? :test_failure! : :error + FastlaneCore::UI.send(ui_method, "Firebase Tests failed – more information can be found at #{result.more_details_url}") + return false + end end # Fastlane doesn't eagerly validate options for us, so we'll do it first to have control over - # when they're evalutated. + # when they're evaluated. def self.validate_options(params) available_options .reject { |opt| opt.optional || !opt.default_value.nil? } @@ -180,9 +188,28 @@ def self.available_options optional: true, type: String ), + FastlaneCore::ConfigItem.new( + key: :crash_on_test_failure, + description: 'If set to `true` (the default), will stop fastlane with `test_failure!`. ' \ + + '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', + optional: true, + type: Boolean, + default_value: true + ), ] end + def self.output + [ + ['FIREBASE_TEST_LOG_FILE_PATH', 'Path to the `output.log` file containing the logs or invoking the tests'], + ['FIREBASE_TEST_MORE_DETAILS_URL', 'URL to the Firebase Console dashboard showing the details of the test run (and failures, if any)'], + ] + end + + def self.return_value + 'True if the test succeeded, false if they failed' + end + def self.authors ['Automattic'] end From d1eff864aed7a7f8a0b3a9da3cb0323373416c2f Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 30 Nov 2022 13:42:12 +0100 Subject: [PATCH 2/3] Add CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed73415e0..a48a4b18b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ _None_ ### New Features -_None_ +* All `android_firebase_test` to not crash on failure, allowing the caller to do custom failure handling (e.g. Buildkite Annotations, etc) on their side. [#430] ### Bug Fixes From c7721e465069079313e816e3167b826604a8502e Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 30 Nov 2022 15:14:50 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a48a4b18b..27f9dab8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ _None_ ### New Features -* All `android_firebase_test` to not crash on failure, allowing the caller to do custom failure handling (e.g. Buildkite Annotations, etc) on their side. [#430] +* 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] ### Bug Fixes