-
Notifications
You must be signed in to change notification settings - Fork 109
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
[CI] add test to check libFoundation.so & co are not linked to the bi… #441
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,60 @@ | ||
#!/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=$? | ||
if [ "$SUCCESS" -eq 0 ]; then | ||
log "❌ ${LIB} found." && break | ||
else | ||
log "✅ ${LIB} not found." | ||
fi | ||
done | ||
|
||
popd || fatal "Failed to change directory back to the root directory." | ||
|
||
# exit code is the opposite of the grep exit code | ||
if [ "$SUCCESS" -eq 0 ]; then | ||
fatal "❌ At least one foundation lib was found, reporting the error." | ||
else | ||
log "✅ No foundation lib found, congrats!" && exit 0 | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GH is being really weird at the moment and diffs are broken - it's not showing this as a new file, like it's stuck diffing a particular commit or something. This file doesn't exist on main right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xTim I’m sorry I messed things up. It's not a problem with GitHub, it's me.
Now it's fixed, you should see the entire script as a new file in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh makes sense, thanks!