2323 type : boolean
2424 description : " Boolean to enable the test of the archive plugin. Defaults to true."
2525 default : true
26+ check_foundation_enabled :
27+ type : boolean
28+ description : " Boolean to enable the check for Foundation dependency. Defaults to true."
29+ default : true
2630 matrix_linux_command :
2731 type : string
2832 description : " The command of the current Swift version linux matrix job to execute."
9599 name : Test archive plugin
96100 if : ${{ inputs.archive_plugin_enabled }}
97101 runs-on : ubuntu-latest
98- strategy :
99- fail-fast : false
100102 steps :
101103 - name : Checkout repository
102104 uses : actions/checkout@v4
@@ -128,3 +130,45 @@ jobs:
128130
129131 echo "✅ The archive plugin is OK"
130132 popd
133+
134+ check-foundation :
135+ name : Check if there is a dependency on Foundation
136+ if : ${{ inputs.check_foundation_enabled }}
137+ runs-on : ubuntu-latest
138+ # depends on test-archive-plugin to speedup the check (no need to rebuild the project)
139+ needs : test-archive-plugin
140+ steps :
141+ - name : Checkout repository
142+ uses : actions/checkout@v4
143+ with :
144+ persist-credentials : false
145+ - name : Mark the workspace as safe
146+ # https://github.com/actions/checkout/issues/766
147+ run : git config --global --add safe.directory ${GITHUB_WORKSPACE}
148+ - name : Check for Foundation or ICU dependency
149+ env :
150+ # we check the API Gateway example as it has a dependency on Swift AWS Lambda Events
151+ # this allows to test the two libraries at onece
152+ # TODO : add a similar test to Swift AWS Lambda Events
153+ EXAMPLE : APIGateway
154+ OUTPUT_DIR : .build/release
155+ OUTPUT_FILE : ${OUTPUT_DIR}/APIGatewayLambda
156+ LIBS_TO_CHECK : " libFoundation.so libFoundationInternationalization.so lib_FoundationICU.so"
157+ run : |
158+ pushd Examples/${EXAMPLE}
159+
160+ # recompile the example without the --static-swift-stdlib flag
161+ LAMBDA_USE_LOCAL_DEPS=../.. swift build -c release -Xlinker -s
162+
163+ for LIB in ${LIBS_TO_CHECK}; do
164+ # check if the binary has a dependency on Foundation or ICU
165+ ldd ${OUTPUT_FILE} | grep ${LIB} # return 1 if not found
166+ # 1 is success (grep failed to find the lib), 0 is failure (grep successly found the lib)
167+ SUCCESS=$?
168+ [ $SUCCESS -eq 0 ] && echo "${LIB} found" && break
169+ done
170+
171+ popd
172+
173+ # exit code is the opposite of the grep exit code
174+ [ $SUCCESS -eq 0 ] && exit 1 || exit 0
0 commit comments