From 08e3def1e7356d5b0f7b8720b63f5cf7ef619f98 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Wed, 12 Jun 2024 18:28:16 +0200 Subject: [PATCH 1/3] fix(xcode): Xcode command line builds fail with `--allow-failure` --- CHANGELOG.md | 5 +++++ scripts/sentry-xcode-debug-files.sh | 9 ++++++++- scripts/sentry-xcode.sh | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014f3d0cab..35797c92e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ - This doesn't change the app start measurement length, but add child spans (more detail) into the existing app start span - Added JS Bundle Execution start information to the application start measurements ([#3857](https://github.com/getsentry/sentry-react-native/pull/3857)) +### Fixes + +- Ensure `sentry-cli` doesn't trigger Xcode `error:` prefix ([#3887](https://github.com/getsentry/sentry-react-native/pull/3887)) + - Fixes `--allow-failure` failing Xcode builds + ### Dependencies - Bump Cocoa SDK from v8.27.0 to v8.28.0 ([#3866](https://github.com/getsentry/sentry-react-native/pull/3866)) diff --git a/scripts/sentry-xcode-debug-files.sh b/scripts/sentry-xcode-debug-files.sh index 8fcc403fbd..9cdaee2e8e 100755 --- a/scripts/sentry-xcode-debug-files.sh +++ b/scripts/sentry-xcode-debug-files.sh @@ -35,5 +35,12 @@ if [ "$SENTRY_DISABLE_AUTO_UPLOAD" == true ]; then elif echo "$XCODE_BUILD_CONFIGURATION" | grep -iq "debug"; then # case insensitive check for "debug" echo "Skipping debug files upload for *Debug* configuration" else - /bin/sh -c "\"$LOCAL_NODE_BINARY\" $UPLOAD_DEBUG_FILES" + # 'warning:' triggers a warning in Xcode, 'error:' triggers an error + SENTRY_UPLOAD_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $UPLOAD_DEBUG_FILES") + if [ $? -eq 0 ]; then + echo "output: sentry-cli - $SENTRY_UPLOAD_COMMAND_OUTPUT" + else + echo "message: sentry-cli - To disable native debug files auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" + echo "error: sentry-cli - $SENTRY_UPLOAD_COMMAND_OUTPUT" + fi fi diff --git a/scripts/sentry-xcode.sh b/scripts/sentry-xcode.sh index 3752345c3d..47047860c3 100755 --- a/scripts/sentry-xcode.sh +++ b/scripts/sentry-xcode.sh @@ -23,7 +23,14 @@ ARGS="$NO_AUTO_RELEASE $SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_RN_XCODE_EXTRA_ARGS" REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $ARGS \"$REACT_NATIVE_XCODE\"" if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then - /bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY" + # 'warning:' triggers a warning in Xcode, 'error:' triggers an error + SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY") + if [ $? -eq 0 ]; then + echo "output: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" + else + echo "message: sentry-cli - To disable source maps auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" + echo "error: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" + fi else echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload" /bin/sh -c "$REACT_NATIVE_XCODE" From 6c5d246aeb8622f5d4cc33525bc999d8bed3ef06 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Wed, 12 Jun 2024 19:10:29 +0200 Subject: [PATCH 2/3] fix error from debug output --- scripts/sentry-xcode-debug-files.sh | 6 ++++-- scripts/sentry-xcode.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/sentry-xcode-debug-files.sh b/scripts/sentry-xcode-debug-files.sh index 9cdaee2e8e..13e031847c 100755 --- a/scripts/sentry-xcode-debug-files.sh +++ b/scripts/sentry-xcode-debug-files.sh @@ -36,9 +36,11 @@ elif echo "$XCODE_BUILD_CONFIGURATION" | grep -iq "debug"; then # case insensiti echo "Skipping debug files upload for *Debug* configuration" else # 'warning:' triggers a warning in Xcode, 'error:' triggers an error - SENTRY_UPLOAD_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $UPLOAD_DEBUG_FILES") + set +x # disable printing commands otherwise we might print `error:` by accident + SENTRY_UPLOAD_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $UPLOAD_DEBUG_FILES" 2>&1) if [ $? -eq 0 ]; then - echo "output: sentry-cli - $SENTRY_UPLOAD_COMMAND_OUTPUT" + echo "$SENTRY_UPLOAD_COMMAND_OUTPUT" | awk '{print "output: sentry-cli - " $0}' + set -x # re-enable printing commands else echo "message: sentry-cli - To disable native debug files auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" echo "error: sentry-cli - $SENTRY_UPLOAD_COMMAND_OUTPUT" diff --git a/scripts/sentry-xcode.sh b/scripts/sentry-xcode.sh index 47047860c3..4e627b182c 100755 --- a/scripts/sentry-xcode.sh +++ b/scripts/sentry-xcode.sh @@ -24,9 +24,11 @@ REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $A if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then # 'warning:' triggers a warning in Xcode, 'error:' triggers an error - SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY") + set +x # disable printing commands otherwise we might print `error:` by accident + SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY" 2>&1) if [ $? -eq 0 ]; then - echo "output: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" + echo "$SENTRY_XCODE_COMMAND_OUTPUT" | awk '{print "output: sentry-cli - " $0}' + set -x # re-enable printing commands else echo "message: sentry-cli - To disable source maps auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" echo "error: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" From 498aeef4bd004ecc25aa46d36b2482280e803738 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 13 Jun 2024 12:48:27 +0200 Subject: [PATCH 3/3] fix printing the error --- scripts/sentry-xcode-debug-files.sh | 6 +++--- scripts/sentry-xcode.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/sentry-xcode-debug-files.sh b/scripts/sentry-xcode-debug-files.sh index 13e031847c..236a4df7d1 100755 --- a/scripts/sentry-xcode-debug-files.sh +++ b/scripts/sentry-xcode-debug-files.sh @@ -36,13 +36,13 @@ elif echo "$XCODE_BUILD_CONFIGURATION" | grep -iq "debug"; then # case insensiti echo "Skipping debug files upload for *Debug* configuration" else # 'warning:' triggers a warning in Xcode, 'error:' triggers an error - set +x # disable printing commands otherwise we might print `error:` by accident + set +x +e # disable printing commands otherwise we might print `error:` by accident and allow continuing on error SENTRY_UPLOAD_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $UPLOAD_DEBUG_FILES" 2>&1) if [ $? -eq 0 ]; then echo "$SENTRY_UPLOAD_COMMAND_OUTPUT" | awk '{print "output: sentry-cli - " $0}' - set -x # re-enable printing commands else - echo "message: sentry-cli - To disable native debug files auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" + echo "error: sentry-cli - To disable native debug files auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" echo "error: sentry-cli - $SENTRY_UPLOAD_COMMAND_OUTPUT" fi + set -x -e # re-enable fi diff --git a/scripts/sentry-xcode.sh b/scripts/sentry-xcode.sh index 4e627b182c..e36fa74e03 100755 --- a/scripts/sentry-xcode.sh +++ b/scripts/sentry-xcode.sh @@ -24,15 +24,15 @@ REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $A if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then # 'warning:' triggers a warning in Xcode, 'error:' triggers an error - set +x # disable printing commands otherwise we might print `error:` by accident + set +x +e # disable printing commands otherwise we might print `error:` by accident and allow continuing on error SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY" 2>&1) if [ $? -eq 0 ]; then echo "$SENTRY_XCODE_COMMAND_OUTPUT" | awk '{print "output: sentry-cli - " $0}' - set -x # re-enable printing commands else - echo "message: sentry-cli - To disable source maps auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" + echo "error: sentry-cli - To disable source maps auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" echo "error: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" fi + set -x -e # re-enable else echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload" /bin/sh -c "$REACT_NATIVE_XCODE"