Skip to content

Commit 9eb6036

Browse files
committed
[CI] add test to check libFoundation.so & co are not linked to the binary
1 parent 5ec9a90 commit 9eb6036

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

.github/workflows/integration_tests.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ on:
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."
@@ -95,8 +99,6 @@ jobs:
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

Comments
 (0)