Skip to content

Commit

Permalink
chore(build-test): Add exit-on-error to build test scripts (#5753)
Browse files Browse the repository at this point in the history
  • Loading branch information
esauerbo authored Sep 6, 2024
1 parent 535682d commit f1b607b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions build-system-tests/scripts/build-android.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Define the log file path
LOG_FILE=$1
Expand Down
1 change: 1 addition & 0 deletions build-system-tests/scripts/build-ios.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Define the log file path
LOG_FILE=$1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions build-system-tests/scripts/mega-app-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Default values
BUILD_TOOL="cra"
Expand Down
9 changes: 1 addition & 8 deletions build-system-tests/scripts/mega-app-copy-files.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Default values
BUILD_TOOL="cra"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build-system-tests/scripts/mega-app-create-app.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Default values
BUILD_TOOL="cra"
Expand Down
8 changes: 1 addition & 7 deletions build-system-tests/scripts/mega-app-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Default values
BUILD_TOOL="cra"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion build-system-tests/scripts/setup-mega-app.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

# Default values
BUILD_TOOL="cra"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f1b607b

Please sign in to comment.