Skip to content

Commit 818776f

Browse files
Fix support for amazonlinux2 with the swift_package_test workflow (#151)
checkout@v4 requires a version of node that requires a newer version of glibc than exists on this OS version, so downgrade it to v1 for AL2.
1 parent 1f5e7cd commit 818776f

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: ./.github/workflows/swift_package_test.yml
2525
with:
2626
# Linux
27-
linux_os_versions: '["jammy", "rhel-ubi9"]'
27+
linux_os_versions: '["jammy", "rhel-ubi9", "amazonlinux2"]'
2828
linux_build_command: |
2929
mkdir MyPackage
3030
cd MyPackage

.github/workflows/swift_package_test.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ jobs:
200200
run: swift --version
201201
- name: Checkout repository
202202
uses: actions/checkout@v4
203+
if: ${{ matrix.os_version != 'amazonlinux2' }}
204+
- name: Checkout repository
205+
uses: actions/checkout@v1
206+
if: ${{ matrix.os_version == 'amazonlinux2' }}
203207
- name: Provide token
204208
if: ${{ inputs.needs_token }}
205209
run: |
@@ -232,6 +236,10 @@ jobs:
232236
run: swift --version
233237
- name: Checkout repository
234238
uses: actions/checkout@v4
239+
if: ${{ matrix.os_version != 'amazonlinux2' }}
240+
- name: Checkout repository
241+
uses: actions/checkout@v1
242+
if: ${{ matrix.os_version == 'amazonlinux2' }}
235243
- name: Provide token
236244
if: ${{ inputs.needs_token }}
237245
run: |
@@ -250,7 +258,18 @@ jobs:
250258
BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
251259
run: |
252260
${{ inputs.linux_static_sdk_pre_build_command }}
253-
which curl || (apt -q update && apt -yq install curl)
261+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
262+
apt-get -q update && apt-get -yq install curl
263+
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
264+
dnf -y update
265+
dnf -y install curl-minimal
266+
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
267+
yum -y update
268+
yum -y install curl
269+
else
270+
echo "Unknown package manager (tried apt-get, dnf, yum)" >&2
271+
exit 1
272+
fi
254273
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
255274
bash -s -- --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }}
256275
@@ -272,6 +291,10 @@ jobs:
272291
run: swift --version
273292
- name: Checkout repository
274293
uses: actions/checkout@v4
294+
if: ${{ matrix.os_version != 'amazonlinux2' }}
295+
- name: Checkout repository
296+
uses: actions/checkout@v1
297+
if: ${{ matrix.os_version == 'amazonlinux2' }}
275298
- name: Provide token
276299
if: ${{ inputs.needs_token }}
277300
run: |
@@ -290,7 +313,18 @@ jobs:
290313
BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
291314
run: |
292315
${{ inputs.wasm_sdk_pre_build_command }}
293-
which curl || (apt -q update && apt -yq install curl)
316+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
317+
apt-get -q update && apt-get -yq install curl
318+
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
319+
dnf -y update
320+
dnf -y install curl-minimal
321+
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
322+
yum -y update
323+
yum -y install curl
324+
else
325+
echo "Unknown package manager (tried apt-get, dnf, yum)" >&2
326+
exit 1
327+
fi
294328
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
295329
bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }}
296330
@@ -330,7 +364,18 @@ jobs:
330364
BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
331365
run: |
332366
${{ inputs.wasm_sdk_pre_build_command }}
333-
which curl || (apt -q update && apt -yq install curl)
367+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
368+
apt-get -q update && apt-get -yq install curl
369+
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
370+
dnf -y update
371+
dnf -y install curl-minimal
372+
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
373+
yum -y update
374+
yum -y install curl
375+
else
376+
echo "Unknown package manager (tried apt-get, dnf, yum)" >&2
377+
exit 1
378+
fi
334379
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
335380
bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }}
336381

0 commit comments

Comments
 (0)