Skip to content

Commit

Permalink
add integration test to check the resources inside the package
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsto committed Jan 18, 2025
1 parent 5802656 commit 86149fd
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions .github/workflows/scripts/check-archive-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,40 @@
##
##===----------------------------------------------------------------------===##

EXAMPLE=HelloWorld
OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
OUTPUT_FILE=${OUTPUT_DIR}/MyLambda/bootstrap
ZIP_FILE=${OUTPUT_DIR}/MyLambda/MyLambda.zip
check_archive_plugin() {
local EXAMPLE=$1
OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
OUTPUT_FILE=${OUTPUT_DIR}/MyLambda/bootstrap
ZIP_FILE=${OUTPUT_DIR}/MyLambda/MyLambda.zip

pushd Examples/${EXAMPLE} || exit 1
pushd Examples/${EXAMPLE} || exit 1

# package the example (docker and swift toolchain are installed on the GH runner)
LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker || exit 1
# package the example (docker and swift toolchain are installed on the GH runner)
LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker || exit 1

# did the plugin generated a Linux binary?
[ -f "${OUTPUT_FILE}" ]
file "${OUTPUT_FILE}" | grep --silent ELF
# did the plugin generated a Linux binary?
[ -f "${OUTPUT_FILE}" ]
file "${OUTPUT_FILE}" | grep --silent ELF

# did the plugin created a ZIP file?
[ -f "${ZIP_FILE}" ]
# did the plugin created a ZIP file?
[ -f "${ZIP_FILE}" ]

# does the ZIP file contain the bootstrap?
unzip -l "${ZIP_FILE}" | grep --silent bootstrap
# does the ZIP file contain the bootstrap?
unzip -l "${ZIP_FILE}" | grep --silent bootstrap

echo "✅ The archive plugin is OK"
popd || exit 1
# if EXAMPLE is ResourcesPackaging, check if the ZIP file contains hello.txt
if [ "$EXAMPLE" == "ResourcesPackaging" ]; then
unzip -l "${ZIP_FILE}" | grep --silent hello.txt
fi

echo "✅ The archive plugin is OK with example ${EXAMPLE}"
popd || exit 1
}

# List of examples
EXAMPLES=("HelloWorld" "ResourcesPackaging")

# Iterate over each example and call check_archive_plugin
for EXAMPLE in "${EXAMPLES[@]}"; do
check_archive_plugin "$EXAMPLE"
done

0 comments on commit 86149fd

Please sign in to comment.