From 8203d22cfc857e6610460d343b1caa9be5c0eda1 Mon Sep 17 00:00:00 2001 From: Zeeshan Sheikh Date: Mon, 7 Oct 2024 20:36:23 +0500 Subject: [PATCH] Update Fastfile --- LocationServices/fastlane/Fastfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/LocationServices/fastlane/Fastfile b/LocationServices/fastlane/Fastfile index 172c621..ddabc35 100644 --- a/LocationServices/fastlane/Fastfile +++ b/LocationServices/fastlane/Fastfile @@ -48,6 +48,24 @@ platform :ios do include_simulator_logs: true, xcargs: "-test-iterations '5' -retry-tests-on-failure" ) + + # Fetch xcresult path + xcresult_path = Actions.lane_context[SharedValues::SCAN_GENERATED_XCRESULT_PATH] + + # Use a helper or some logic to inspect the xcresult file for final test status + sh("xcrun xcresulttool get --path #{xcresult_path} --format json > result.json") + + # Parse result.json and check if tests were passed on the last attempt + result = JSON.parse(File.read("result.json")) + failed_tests = result["issues"]["testFailures"] + + # If all tests have eventually passed, don't fail the lane + if failed_tests.nil? || failed_tests.empty? + UI.success("All tests passed eventually after retries.") + else + UI.user_error!("Some tests still failed after retries.") + end + ensure xcresult_path = Actions.lane_context[SharedValues::SCAN_GENERATED_XCRESULT_PATH] sh("echo xcresult_path=" + xcresult_path + " >> $GITHUB_ENV")