Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build-s3-dist.sh and run-unit-tests.sh to Handle Paths with Spaces #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ source_dir="$template_dir/../source"
echo "------------------------------------------------------------------------------"
echo "[Init] Clean old dist, node_modules and bower_components folders"
echo "------------------------------------------------------------------------------"
echo "rm -rf $template_dist_dir"
rm -rf $template_dist_dir
echo "mkdir -p $template_dist_dir"
mkdir -p $template_dist_dir
echo "rm -rf $build_dist_dir"
rm -rf $build_dist_dir
echo "mkdir -p $build_dist_dir"
mkdir -p $build_dist_dir
echo "rm -rf \"$template_dist_dir\""
rm -rf "$template_dist_dir"
echo "mkdir -p \"$template_dist_dir\""
mkdir -p "$template_dist_dir"
echo "rm -rf \"$build_dist_dir\""
rm -rf "$build_dist_dir"
echo "mkdir -p \"$build_dist_dir\""
mkdir -p "$build_dist_dir"

echo "------------------------------------------------------------------------------"
echo "[Packing] Templates"
Expand All @@ -48,18 +48,18 @@ SUB_BUCKET_NAME="s/BUCKET_NAME_PLACEHOLDER/$1/g"
SUB_SOLUTION_NAME="s/SOLUTION_NAME_PLACEHOLDER/$2/g"
SUB_VERSION="s/VERSION_PLACEHOLDER/$3/g"

for FULLNAME in ./*.yaml
for FULLNAME in "$template_dir"/*.yaml
do
TEMPLATE=`basename $FULLNAME .yaml`
TEMPLATE=`basename "$FULLNAME" .yaml`
echo "Template: $TEMPLATE"
sed -e $SUB_BUCKET_NAME -e $SUB_SOLUTION_NAME -e $SUB_VERSION $template_dir/$TEMPLATE.yaml > $template_dist_dir/$TEMPLATE.template
cp $template_dist_dir/$TEMPLATE.template $build_dist_dir/
sed -e "$SUB_BUCKET_NAME" -e "$SUB_SOLUTION_NAME" -e "$SUB_VERSION" "$template_dir/$TEMPLATE.yaml" > "$template_dist_dir/$TEMPLATE.template"
cp "$template_dist_dir/$TEMPLATE.template" "$build_dist_dir/"
done

echo "------------------------------------------------------------------------------"
echo "[Building] Utils"
echo "------------------------------------------------------------------------------"
cd $source_dir/utils
cd "$source_dir/utils"
npm run clean
npm install --production

Expand All @@ -75,7 +75,7 @@ do
echo "------------------------------------------------------------------------------"
echo "[Building] Lambda package: $lambda_package"
echo "------------------------------------------------------------------------------"
cd $source_dir/$lambda_package
cd "$source_dir/$lambda_package"
npm run package

# Check the result of the build and exit if a failure is identified
Expand All @@ -88,6 +88,6 @@ do
echo "------------------------------------------------------------------------------"
exit 1
fi
mv ./dist/package.zip $build_dist_dir/$lambda_package.zip
mv ./dist/package.zip "$build_dist_dir/$lambda_package.zip"
npm run clean
done
18 changes: 9 additions & 9 deletions deployment/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

prepare_jest_coverage_report() {
local component_name=$1
local component_name="$1"

if [ ! -d "coverage" ]; then
echo "ValidationError: Missing required directory coverage after running unit tests"
Expand All @@ -17,21 +17,21 @@ prepare_jest_coverage_report() {

# prepare coverage reports
rm -fr coverage/lcov-report
mkdir -p $coverage_reports_top_path/jest
coverage_report_path=$coverage_reports_top_path/jest/$component_name
rm -fr $coverage_report_path
mv coverage $coverage_report_path
mkdir -p "$coverage_reports_top_path/jest"
coverage_report_path="$coverage_reports_top_path/jest/$component_name"
rm -fr "$coverage_report_path"
mv coverage "$coverage_report_path"
}

# Get reference for all important folders
template_dir="$PWD"
source_dir="$template_dir/../source"
coverage_reports_top_path=$source_dir/test/coverage-reports
coverage_reports_top_path="$source_dir/test/coverage-reports"

echo "------------------------------------------------------------------------------"
echo "[Test] utils"
echo "------------------------------------------------------------------------------"
cd $source_dir/utils
cd "$source_dir/utils"
npm run clean
npm install
npm test
Expand Down Expand Up @@ -60,15 +60,15 @@ do
echo "------------------------------------------------------------------------------"
echo "[Test] Lambda package: $lambda_package"
echo "------------------------------------------------------------------------------"
cd $source_dir/$lambda_package
cd "$source_dir/$lambda_package"
npm run clean
npm install
npm test

# Check the result of the test and exit if a failure is identified
if [ $? -eq 0 ]
then
prepare_jest_coverage_report $lambda_package
prepare_jest_coverage_report "$lambda_package"
echo "Test for $lambda_package successful"
else
echo "------------------------------------------------------------------------------"
Expand Down