From bf99b613124856bc3ae209a9914d77c6a617d8d9 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 12 Nov 2023 20:31:43 -0500 Subject: [PATCH 1/3] Ensure that scripts don't swallow errors --- scripts/carthage.sh | 6 +++--- scripts/findproject.sh | 2 +- scripts/printformat.sh | 2 +- scripts/resolvepath.sh | 2 +- scripts/versions.sh | 2 +- scripts/workflowtests.sh | 10 +++++----- scripts/xcframework.sh | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/carthage.sh b/scripts/carthage.sh index 208740d..37ac844 100755 --- a/scripts/carthage.sh +++ b/scripts/carthage.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # Needed to circumvent an issue with Carthage version < 0.37.0: https://github.com/Carthage/Carthage/issues/3019 # @@ -6,9 +6,9 @@ # Usage example: ./carthage.sh build --platform iOS VERSION="$(carthage version)" -"$(dirname "$0")/versions.sh" "$VERSION" "0.37.0" +comparison=$("$(dirname "$0")/versions.sh" "$VERSION" "0.37.0"; echo $?) -if [ $? -ge 0 ]; then +if [ $comparison -ge 0 ]; then # Carthage version is greater than or equal to 0.37.0 meaning we can use the --use-xcframeworks flag carthage "$@" --use-xcframeworks else diff --git a/scripts/findproject.sh b/scripts/findproject.sh index e5f9b07..48ab171 100755 --- a/scripts/findproject.sh +++ b/scripts/findproject.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # xcframework.sh # Usage example: ./findproject.sh --project-name diff --git a/scripts/printformat.sh b/scripts/printformat.sh index 63f1460..25a6dee 100755 --- a/scripts/printformat.sh +++ b/scripts/printformat.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # https://gist.github.com/SomeRandomiOSDev/798406a4a15f6b5d78b010599865c04f # diff --git a/scripts/resolvepath.sh b/scripts/resolvepath.sh index 7b78b33..5597341 100755 --- a/scripts/resolvepath.sh +++ b/scripts/resolvepath.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # resolvepath.sh # Usage example: ./resolvepath.sh "./some/random/path/../../" diff --git a/scripts/versions.sh b/scripts/versions.sh index 31eb795..27b18ea 100755 --- a/scripts/versions.sh +++ b/scripts/versions.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # versions.sh # Usage example: ./versions.sh "1.4.15" "1.7.0" diff --git a/scripts/workflowtests.sh b/scripts/workflowtests.sh index 3a6ed0a..0b58a63 100755 --- a/scripts/workflowtests.sh +++ b/scripts/workflowtests.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # workflowtests.sh # Usage example: ./workflowtests.sh --no-clean @@ -261,9 +261,9 @@ if which carthage >/dev/null; then CARTHAGE_VERSION="$(carthage version)" echo "Carthage: $CARTHAGE_VERSION" - "$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0" + comparison=$("$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0"; echo $?) - if [ $? -lt 0 ]; then + if [ $comparison -lt 0 ]; then "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Carthage version of at least 0.37.0 is recommended for running these unit tests" fi else @@ -274,9 +274,9 @@ fi if which pod >/dev/null; then PODS_VERSION="$(pod --version)" - "$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3" + comparison=$("$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3"; echo $?) - if [ $? -ge 0 ]; then + if [ $comparison -ge 0 ]; then echo "CocoaPods: $PODS_VERSION" else checkresult -1 "These unit tests require version 1.7.3 or later of CocoaPods: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods")" diff --git a/scripts/xcframework.sh b/scripts/xcframework.sh index dbe5625..ba208e5 100755 --- a/scripts/xcframework.sh +++ b/scripts/xcframework.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash -e -o pipefail # # xcframework.sh # Usage example: ./xcframework.sh --output /.xcframework From d868f2bac332e2ba0020f56d03eeb3e89e25d09c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 13 Nov 2023 10:02:16 -0800 Subject: [PATCH 2/3] Make codacy static analysis happy. --- scripts/carthage.sh | 2 +- scripts/workflowtests.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/carthage.sh b/scripts/carthage.sh index 37ac844..bd22a3e 100755 --- a/scripts/carthage.sh +++ b/scripts/carthage.sh @@ -8,7 +8,7 @@ VERSION="$(carthage version)" comparison=$("$(dirname "$0")/versions.sh" "$VERSION" "0.37.0"; echo $?) -if [ $comparison -ge 0 ]; then +if [ "$comparison" -ge 0 ]; then # Carthage version is greater than or equal to 0.37.0 meaning we can use the --use-xcframeworks flag carthage "$@" --use-xcframeworks else diff --git a/scripts/workflowtests.sh b/scripts/workflowtests.sh index 0b58a63..fd065e6 100755 --- a/scripts/workflowtests.sh +++ b/scripts/workflowtests.sh @@ -263,7 +263,7 @@ if which carthage >/dev/null; then comparison=$("$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0"; echo $?) - if [ $comparison -lt 0 ]; then + if [ "$comparison" -lt 0 ]; then "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Carthage version of at least 0.37.0 is recommended for running these unit tests" fi else @@ -276,7 +276,7 @@ if which pod >/dev/null; then PODS_VERSION="$(pod --version)" comparison=$("$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3"; echo $?) - if [ $comparison -ge 0 ]; then + if [ "$comparison" -ge 0 ]; then echo "CocoaPods: $PODS_VERSION" else checkresult -1 "These unit tests require version 1.7.3 or later of CocoaPods: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods")" From 040acdfe6ff778a3deebcbcdde2123b3bdaef470 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 13 Nov 2023 11:57:09 -0800 Subject: [PATCH 3/3] Revert changes to workflowtests.sh Its structure sort of depended on continuing in the face of errors, even though the way it works is buggy. That needs to be resolved by @SomeRandomiOSDev. --- scripts/workflowtests.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/workflowtests.sh b/scripts/workflowtests.sh index fd065e6..3a6ed0a 100755 --- a/scripts/workflowtests.sh +++ b/scripts/workflowtests.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash -e -o pipefail +#!/usr/bin/env bash # # workflowtests.sh # Usage example: ./workflowtests.sh --no-clean @@ -261,9 +261,9 @@ if which carthage >/dev/null; then CARTHAGE_VERSION="$(carthage version)" echo "Carthage: $CARTHAGE_VERSION" - comparison=$("$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0"; echo $?) + "$SCRIPTS_DIR/versions.sh" "$CARTHAGE_VERSION" "0.37.0" - if [ "$comparison" -lt 0 ]; then + if [ $? -lt 0 ]; then "$SCRIPTS_DIR/printformat.sh" "foreground:yellow" "Carthage version of at least 0.37.0 is recommended for running these unit tests" fi else @@ -274,9 +274,9 @@ fi if which pod >/dev/null; then PODS_VERSION="$(pod --version)" - comparison=$("$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3"; echo $?) + "$SCRIPTS_DIR/versions.sh" "$PODS_VERSION" "1.7.3" - if [ "$comparison" -ge 0 ]; then + if [ $? -ge 0 ]; then echo "CocoaPods: $PODS_VERSION" else checkresult -1 "These unit tests require version 1.7.3 or later of CocoaPods: $("$SCRIPTS_DIR/printformat.sh" "foreground:blue;underline" "https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods")"