1313# #
1414# #===----------------------------------------------------------------------===##
1515
16- EXAMPLE=HelloWorld
17- OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
18- OUTPUT_FILE=${OUTPUT_DIR} /MyLambda/bootstrap
19- ZIP_FILE=${OUTPUT_DIR} /MyLambda/MyLambda.zip
16+ check_archive_plugin () {
17+ local EXAMPLE=$1
18+ OUTPUT_DIR=.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager
19+ OUTPUT_FILE=${OUTPUT_DIR} /MyLambda/bootstrap
20+ ZIP_FILE=${OUTPUT_DIR} /MyLambda/MyLambda.zip
2021
21- pushd Examples/${EXAMPLE} || exit 1
22+ pushd Examples/${EXAMPLE} || exit 1
2223
23- # package the example (docker and swift toolchain are installed on the GH runner)
24- LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker || exit 1
24+ # package the example (docker and swift toolchain are installed on the GH runner)
25+ LAMBDA_USE_LOCAL_DEPS=../.. swift package archive --allow-network-connections docker || exit 1
2526
26- # did the plugin generated a Linux binary?
27- [ -f " ${OUTPUT_FILE} " ]
28- file " ${OUTPUT_FILE} " | grep --silent ELF
27+ # did the plugin generated a Linux binary?
28+ [ -f " ${OUTPUT_FILE} " ]
29+ file " ${OUTPUT_FILE} " | grep --silent ELF
2930
30- # did the plugin created a ZIP file?
31- [ -f " ${ZIP_FILE} " ]
31+ # did the plugin created a ZIP file?
32+ [ -f " ${ZIP_FILE} " ]
3233
33- # does the ZIP file contain the bootstrap?
34- unzip -l " ${ZIP_FILE} " | grep --silent bootstrap
34+ # does the ZIP file contain the bootstrap?
35+ unzip -l " ${ZIP_FILE} " | grep --silent bootstrap
3536
36- echo " ✅ The archive plugin is OK"
37- popd || exit 1
37+ # if EXAMPLE is ResourcesPackaging, check if the ZIP file contains hello.txt
38+ if [ " $EXAMPLE " == " ResourcesPackaging" ]; then
39+ unzip -l " ${ZIP_FILE} " | grep --silent hello.txt
40+ fi
41+
42+ echo " ✅ The archive plugin is OK with example ${EXAMPLE} "
43+ popd || exit 1
44+ }
45+
46+ # List of examples
47+ EXAMPLES=(" HelloWorld" " ResourcesPackaging" )
48+
49+ # Iterate over each example and call check_archive_plugin
50+ for EXAMPLE in " ${EXAMPLES[@]} " ; do
51+ check_archive_plugin " $EXAMPLE "
52+ done
0 commit comments