From f1b607b66c4b7943067a16bc596b677f7e91e03c Mon Sep 17 00:00:00 2001 From: Emma Sauerborn <70536670+esauerbo@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:07:58 -0700 Subject: [PATCH] chore(build-test): Add exit-on-error to build test scripts (#5753) --- build-system-tests/scripts/build-android.sh | 1 + build-system-tests/scripts/build-ios.sh | 1 + .../scripts/install-dependencies-with-retries.sh | 9 +++++++++ build-system-tests/scripts/mega-app-build.sh | 1 + build-system-tests/scripts/mega-app-copy-files.sh | 9 +-------- build-system-tests/scripts/mega-app-create-app.sh | 1 + build-system-tests/scripts/mega-app-install.sh | 8 +------- build-system-tests/scripts/setup-mega-app.sh | 3 ++- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build-system-tests/scripts/build-android.sh b/build-system-tests/scripts/build-android.sh index 9887f928458..244e1061c1a 100755 --- a/build-system-tests/scripts/build-android.sh +++ b/build-system-tests/scripts/build-android.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Define the log file path LOG_FILE=$1 diff --git a/build-system-tests/scripts/build-ios.sh b/build-system-tests/scripts/build-ios.sh index f7b26c543c9..be5541b72cc 100755 --- a/build-system-tests/scripts/build-ios.sh +++ b/build-system-tests/scripts/build-ios.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Define the log file path LOG_FILE=$1 diff --git a/build-system-tests/scripts/install-dependencies-with-retries.sh b/build-system-tests/scripts/install-dependencies-with-retries.sh index 46b402191d3..c80ca718c41 100644 --- a/build-system-tests/scripts/install-dependencies-with-retries.sh +++ b/build-system-tests/scripts/install-dependencies-with-retries.sh @@ -6,12 +6,18 @@ install_dependencies_with_retries() { local retries=3 local attempt=1 + echo "Disable exit-on-error temporarily" + echo "set +e" + set +e while [ $attempt -le $retries ]; do echo "Attempt $attempt/$retries" echo "$1 install $2" "$1" install $2 if [ $? -eq 0 ]; then echo "$1 install successful." + echo "Re-enable exit-on-error" + echo "set -e" + set -e break fi attempt=$((attempt + 1)) @@ -20,6 +26,9 @@ install_dependencies_with_retries() { sleep 5 else echo "$1 install failed after $retries attempts." + echo "Re-enable exit-on-error" + echo "set -e" + set -e exit 1 fi done diff --git a/build-system-tests/scripts/mega-app-build.sh b/build-system-tests/scripts/mega-app-build.sh index d98c2091aa0..b82c246b2d4 100755 --- a/build-system-tests/scripts/mega-app-build.sh +++ b/build-system-tests/scripts/mega-app-build.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Default values BUILD_TOOL="cra" diff --git a/build-system-tests/scripts/mega-app-copy-files.sh b/build-system-tests/scripts/mega-app-copy-files.sh index 89064070af0..1f5355da5ce 100755 --- a/build-system-tests/scripts/mega-app-copy-files.sh +++ b/build-system-tests/scripts/mega-app-copy-files.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Default values BUILD_TOOL="cra" @@ -100,14 +101,6 @@ if [ "$BUILD_TOOL" == 'next' ]; then cp $AWS_EXPORTS_FILE mega-apps/${MEGA_APP_NAME}/data/aws-exports.js echo "cp templates/components/react/next/App.js mega-apps/${MEGA_APP_NAME}/pages/index.tsx" cp templates/components/react/next/App.js mega-apps/${MEGA_APP_NAME}/pages/index.tsx - if [ "$BUILD_TOOL_VERSION" == '11' ]; then - # We have to customize the package.json and tsconfig.json for Next.js 11, - # because create-next-app only creates the app with the latest version - echo "cp templates/components/react/next/template-package-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/package.json" - cp templates/components/react/next/template-package-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/package.json - echo "cp templates/components/react/next/template-tsconfig-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.json" - cp templates/components/react/next/template-tsconfig-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.json - fi fi if [[ "$FRAMEWORK" == 'react' && "$BUILD_TOOL" == 'vite' ]]; then diff --git a/build-system-tests/scripts/mega-app-create-app.sh b/build-system-tests/scripts/mega-app-create-app.sh index 1bbcef22242..dc36f0da6c0 100755 --- a/build-system-tests/scripts/mega-app-create-app.sh +++ b/build-system-tests/scripts/mega-app-create-app.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Default values BUILD_TOOL="cra" diff --git a/build-system-tests/scripts/mega-app-install.sh b/build-system-tests/scripts/mega-app-install.sh index 4eefc58d9a7..010c9e56590 100755 --- a/build-system-tests/scripts/mega-app-install.sh +++ b/build-system-tests/scripts/mega-app-install.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Default values BUILD_TOOL="cra" @@ -128,13 +129,6 @@ else install_dependencies_with_retries npm "$DEP_TYPES" fi - if [[ "$BUILD_TOOL" == 'next' && "$BUILD_TOOL_VERSION" == '11' ]]; then - # We have to remove the initial downloaded node_modules for Next.js 11, - # because create-next-app only creates the app with the latest version - echo "rm -rf node_modules" - rm -rf node_modules - fi - if [[ "$FRAMEWORK" == "react-native" ]]; then DEPENDENCIES="$TAGGED_UI_FRAMEWORK @aws-amplify/react-native aws-amplify react-native-safe-area-context @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill" echo "npm install $DEPENDENCIES" diff --git a/build-system-tests/scripts/setup-mega-app.sh b/build-system-tests/scripts/setup-mega-app.sh index 52b0fab5c82..7fc9a88a7b2 100755 --- a/build-system-tests/scripts/setup-mega-app.sh +++ b/build-system-tests/scripts/setup-mega-app.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Default values BUILD_TOOL="cra" @@ -84,7 +85,7 @@ while [[ $# -gt 0 ]]; do shift done -# Check if MEGA_APP_NAME is provided +# Create MEGA_APP_NAME if none provided if [[ -z "$MEGA_APP_NAME" ]]; then MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE-ui-$TAG" fi