Skip to content

Commit

Permalink
Merge pull request #374 from awslabs/fix/structure
Browse files Browse the repository at this point in the history
chore: updated the folders structure to match prod codecommit repo
  • Loading branch information
malachi-constant authored Nov 6, 2023
2 parents 0c39ceb + a63d5de commit 362a694
Show file tree
Hide file tree
Showing 12 changed files with 1,144 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/gh-sync-cc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
cp .viperlightignore scene-intelligence-with-rosbag-on-aws/
cp .bandit scene-intelligence-with-rosbag-on-aws/
cp scene-intelligence-with-rosbag-on-aws-create.template deployment/
cp scene-intelligence-with-rosbag-on-aws-delete.template deployment/
cd scene-intelligence-with-rosbag-on-aws/
git config --global user.email "${{github.actor}}@users.noreply.github.com"
Expand Down
76 changes: 76 additions & 0 deletions deployment/build-open-source-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
#
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
#
# This script should be run from the repo's deployment directory
# cd deployment
# ./build-open-source-dist.sh solution-name
#
# Parameters:
# - solution-name: name of the solution for consistency

# Check to see if input has been provided:
if [ -z "$1" ]; then
echo "Please provide the trademark approved solution name for the open source package."
echo "For example: ./build-open-source-dist.sh trademarked-solution-name"
exit 1
fi

# Get reference for all important folders
source_template_dir="$PWD"
dist_dir="$source_template_dir/open-source"
dist_template_dir="$dist_dir/deployment"
source_dir="$source_template_dir/../source"

echo "------------------------------------------------------------------------------"
echo "Building open-source folder"
echo "------------------------------------------------------------------------------"
[ -e $dist_dir ] && rm -rf $dist_dir
rm -rf $dist_dir
mkdir -p $dist_dir
mkdir -p $dist_template_dir

echo "------------------------------------------------------------------------------"
echo "Copying Deployment Folder"
echo "------------------------------------------------------------------------------"
cp $source_template_dir/build-s3-dist.sh $dist_template_dir
cp $source_template_dir/run-unit-tests.sh $dist_template_dir
cp -r $source_template_dir/ecr $dist_template_dir
find $dist_template_dir/ecr -type f -name '*.jar' -delete

echo "------------------------------------------------------------------------------"
echo "Copying Source Folder"
echo "------------------------------------------------------------------------------"
cp -r $source_dir $dist_dir
cp $source_template_dir/../architecture.png $dist_dir
cp $source_template_dir/../LICENSE.txt $dist_dir
cp $source_template_dir/../NOTICE.txt $dist_dir
cp $source_template_dir/../README.md $dist_dir
cp $source_template_dir/../CODE_OF_CONDUCT.md $dist_dir
cp $source_template_dir/../CONTRIBUTING.md $dist_dir
cp $source_template_dir/../CHANGELOG.md $dist_dir
cp $source_template_dir/../.gitignore $dist_dir
cp -r $source_template_dir/../.github $dist_dir

echo "------------------------------------------------------------------------------"
echo "Removing Build Files From Source"
echo "------------------------------------------------------------------------------"
find $dist_dir -iname "node_modules" -type d -exec rm -rf "{}" \; 2> /dev/null
find $dist_dir -iname "coverage" -type d -exec rm -rf "{}" \; 2> /dev/null
find $dist_dir -iname "build" -type d -exec rm -rf "{}" \; 2> /dev/null
find $dist_dir -type f -name 'package-lock.json' -delete
find $dist_dir -type f -name '.eslintcache' -delete
find $dist_dir/source/infrastructure -iname "cdk.out" -type d -exec rm -rf "{}" \; 2> /dev/null
rm -rf $dist_dir/source/test
rm -rf $dist_dir/deployment/manifest.yaml

echo "------------------------------------------------------------------------------"
echo "Creating GitHub zip file"
echo "------------------------------------------------------------------------------"
cd $dist_dir
echo "open source files::"
ls -alh
zip -q -r9 ../$1.zip * .github .gitignore
rm -rf * .github .gitignore
mv ../$1.zip .
echo "Completed building $1.zip"
67 changes: 67 additions & 0 deletions deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
#sudo yum-config-manager --enable epel
#sudo yum update -y
#sudo pip install --upgrade pip
#alias sudo='sudo env PATH=$PATH'
#sudo pip install --upgrade setuptools
#sudo pip install --upgrade virtualenv

# This script should be run from the repo's deployment directory
# cd deployment
# ./build-s3-dist.sh source-bucket-base-name
# source-bucket-base-name should be the base name for the S3 bucket location where the template will source the Lambda code from.
# The template will append '-[region_name]' to this bucket name.
# For example: ./build-s3-dist.sh solutions
# The template will then expect the source code to be located in the solutions-[region_name] bucket

# Check to see if input has been provided:
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]|| [ -z "$4" ] ; then
echo "Please provide the base source bucket name and version (subfolder) where the lambda code will eventually reside.\nFor example: ./build-s3-dist.sh solutions solutions-github trademarked-solution-name v1.0"
exit 1
fi

# Build source
echo "Staring to build distribution"
# export deployment_dir=`pwd`
# export dist_dir="$deployment_dir"
export dist_dir="deployment"
template_dist_dir="$dist_dir/global-s3-assets"
opensrc_dist_dir="$dist_dir/open-source"
build_dist_dir="$dist_dir/regional-s3-assets"

echo "------------------------------------------------------------------------------"
echo "[Init] Clean old dist folders"
echo "------------------------------------------------------------------------------"

echo "Creating distribution directory"
mkdir -p dist
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 $opensrc_dist_dir"
rm -rf $opensrc_dist_dir
echo "mkdir -p $opensrc_dist_dir"
mkdir -p $opensrc_dist_dir


echo "In deployment folder"
pwd

echo "Replacing solution bucket in the template"
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-create.template" $template_dist_dir
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-delete.template" $template_dist_dir

echo "Placeholder: Pushing single click CFN stack into build_dist_dir to make it non-empty. Empty dirs are being ignored in Codepipeline and failing to execute the deployAssets stage"
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-create.template" $build_dist_dir
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-delete.template" $build_dist_dir

echo "Placeholder: Pushing single click CFN stack into opensrc_dist_dir to make it non-empty. Empty dirs are being ignored in Codepipeline and failing to execute the deployAssets stage"
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-create.template" $opensrc_dist_dir
cp -f "deployment/scene-intelligence-with-rosbag-on-aws-delete.template" $opensrc_dist_dir
7 changes: 7 additions & 0 deletions deployment/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
id: SO0279 # Solution Id
name: scene-intelligence-with-rosbag-on-aws # hyphenated trademarked name
version: v1.0.0 # current version of the solution.
cloudformation_templates:
- template: deployment/scene-intelligence-with-rosbag-on-aws-create.template
main_template: true
- template: deployment/scene-intelligence-with-rosbag-on-aws-delete.template
Loading

0 comments on commit 362a694

Please sign in to comment.