diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 7bf6fc926..4867270e6 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -136,8 +136,8 @@ jobs: - name: Cache SPM dependencies uses: actions/cache@v5 with: - path: Examples/APIGatewayV2/.build - key: spm-foundation-${{ runner.os }}-${{ hashFiles('Examples/APIGatewayV2/Package.swift') }} + path: Examples/HelloWorldNoTraits/.build + key: spm-foundation-${{ runner.os }}-${{ hashFiles('Examples/HelloWorldNoTraits/Package.swift') }} restore-keys: | spm-foundation-${{ runner.os }}- diff --git a/.github/workflows/scripts/check-link-foundation.sh b/.github/workflows/scripts/check-link-foundation.sh index 594781c9a..761f1acdb 100755 --- a/.github/workflows/scripts/check-link-foundation.sh +++ b/.github/workflows/scripts/check-link-foundation.sh @@ -17,12 +17,12 @@ log() { printf -- "** %s\n" "$*" >&2; } error() { printf -- "** ERROR: %s\n" "$*" >&2; } fatal() { error "$@"; exit 1; } -EXAMPLE=APIGatewayV2 +EXAMPLE=HelloWorldNoTraits OUTPUT_DIR=.build/release -OUTPUT_FILE=${OUTPUT_DIR}/APIGatewayLambda +OUTPUT_FILE=${OUTPUT_DIR}/MyLambda LIBS_TO_CHECK="libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so" -pushd Examples/${EXAMPLE} || fatal "Failed to change directory to Examples/${EXAMPLE}." +pushd Examples/${EXAMPLE} > /dev/null || fatal "Failed to change directory to Examples/${EXAMPLE}." # recompile the example without the --static-swift-stdlib flag swift build -c release || fatal "Failed to build the example." @@ -39,21 +39,20 @@ 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 + # grep -q suppresses output; returns 0 if found, 1 if not found + echo "${LIBRARIES}" | grep -q "${LIB}" + FOUND=$? + if [ "$FOUND" -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." +popd > /dev/null || 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 +# FOUND is 0 if grep matched (lib was found), 1 if not +if [ "$FOUND" -eq 0 ]; then fatal "❌ At least one foundation lib was found, reporting the error." else log "✅ No foundation lib found, congrats!" && exit 0 diff --git a/Examples/HelloWorldNoTraits/Package.swift b/Examples/HelloWorldNoTraits/Package.swift index 753c67c5f..da1ee8076 100644 --- a/Examples/HelloWorldNoTraits/Package.swift +++ b/Examples/HelloWorldNoTraits/Package.swift @@ -10,10 +10,11 @@ let package = Package( ], dependencies: [ // For local development (default) - .package(name: "swift-aws-lambda-runtime", path: "../..") + // No traits are enabled — this example deliberately avoids Foundation + .package(name: "swift-aws-lambda-runtime", path: "../..", traits: []) // For standalone usage, comment the line above and uncomment below: - // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0"), + // .package(url: "https://github.com/awslabs/swift-aws-lambda-runtime.git", from: "2.0.0", traits: []), ], targets: [ .executableTarget(