-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sebsto/apigatewayresponse
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the SwiftAWSLambdaRuntime open source project | ||
## | ||
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors | ||
## Licensed under Apache License v2.0 | ||
## | ||
## See LICENSE.txt for license information | ||
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors | ||
## | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
EXAMPLE=HelloWorld | ||
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 | ||
|
||
# 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 created a ZIP file? | ||
[ -f "${ZIP_FILE}" ] | ||
|
||
# does the ZIP file contain the bootstrap? | ||
unzip -l "${ZIP_FILE}" | grep --silent bootstrap | ||
|
||
echo "✅ The archive plugin is OK" | ||
popd || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## This source file is part of the SwiftAWSLambdaRuntime open source project | ||
## | ||
## Copyright (c) 2017-2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors | ||
## Licensed under Apache License v2.0 | ||
## | ||
## See LICENSE.txt for license information | ||
## See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors | ||
## | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
log() { printf -- "** %s\n" "$*" >&2; } | ||
error() { printf -- "** ERROR: %s\n" "$*" >&2; } | ||
fatal() { error "$@"; exit 1; } | ||
|
||
EXAMPLE=APIGateway | ||
OUTPUT_DIR=.build/release | ||
OUTPUT_FILE=${OUTPUT_DIR}/APIGatewayLambda | ||
LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so" | ||
|
||
pushd Examples/${EXAMPLE} || fatal "Failed to change directory to Examples/${EXAMPLE}." | ||
|
||
# recompile the example without the --static-swift-stdlib flag | ||
LAMBDA_USE_LOCAL_DEPS=../.. swift build -c release -Xlinker -s || fatal "Failed to build the example." | ||
|
||
# check if the binary exists | ||
if [ ! -f "${OUTPUT_FILE}" ]; then | ||
error "❌ ${OUTPUT_FILE} does not exist." | ||
fi | ||
|
||
# Checking for Foundation or ICU dependencies | ||
echo "Checking for Foundation or ICU dependencies in ${OUTPUT_DIR}/${OUTPUT_FILE}." | ||
LIBRARIES=$(ldd ${OUTPUT_FILE} | awk '{print $1}') | ||
for LIB in ${LIBS_TO_CHECK}; do | ||
echo -n "Checking for ${LIB}... " | ||
|
||
# check if the binary has a dependency on Foundation or ICU | ||
echo "${LIBRARIES}" | grep "${LIB}" # return 1 if not found | ||
|
||
# 1 is success (grep failed to find the lib), 0 is failure (grep successly found the lib) | ||
SUCCESS=$? | ||
[ "$SUCCESS" -eq 0 ] && log "❌ ${LIB} found." && break || log "✅ ${LIB} not found." | ||
done | ||
|
||
popd || fatal "Failed to change directory back to the root directory." | ||
|
||
# exit code is the opposite of the grep exit code | ||
[ "$SUCCESS" -eq 0 ] && error "❌ At least one foundation lib was found, reporting the error." || log "✅ No foundation lib found, congrats!" && exit 0 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters