From 6265488edeecbe3fe7a04853ea91ff39b1e78a76 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 6 Aug 2025 13:09:25 -0700 Subject: [PATCH] Fix support for amazonlinux2 with the swift_package_test workflow 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. --- .github/workflows/pull_request.yml | 2 +- .github/workflows/swift_package_test.yml | 51 ++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a450674e..37e8d167 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -24,7 +24,7 @@ jobs: uses: ./.github/workflows/swift_package_test.yml with: # Linux - linux_os_versions: '["jammy", "rhel-ubi9"]' + linux_os_versions: '["jammy", "rhel-ubi9", "amazonlinux2"]' linux_build_command: | mkdir MyPackage cd MyPackage diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index d29b8355..11eb03d5 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -200,6 +200,10 @@ jobs: run: swift --version - name: Checkout repository uses: actions/checkout@v4 + if: ${{ matrix.os_version != 'amazonlinux2' }} + - name: Checkout repository + uses: actions/checkout@v1 + if: ${{ matrix.os_version == 'amazonlinux2' }} - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -232,6 +236,10 @@ jobs: run: swift --version - name: Checkout repository uses: actions/checkout@v4 + if: ${{ matrix.os_version != 'amazonlinux2' }} + - name: Checkout repository + uses: actions/checkout@v1 + if: ${{ matrix.os_version == 'amazonlinux2' }} - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -250,7 +258,18 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.linux_static_sdk_pre_build_command }} - which curl || (apt -q update && apt -yq install curl) + if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal + apt-get -q update && apt-get -yq install curl + elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 + dnf -y update + dnf -y install curl-minimal + elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum -y update + yum -y install curl + else + echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 + exit 1 + fi curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --static --flags="$BUILD_FLAGS" --build-command="${{ inputs.linux_static_sdk_build_command }}" ${{ matrix.swift_version }} @@ -272,6 +291,10 @@ jobs: run: swift --version - name: Checkout repository uses: actions/checkout@v4 + if: ${{ matrix.os_version != 'amazonlinux2' }} + - name: Checkout repository + uses: actions/checkout@v1 + if: ${{ matrix.os_version == 'amazonlinux2' }} - name: Provide token if: ${{ inputs.needs_token }} run: | @@ -290,7 +313,18 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.wasm_sdk_pre_build_command }} - which curl || (apt -q update && apt -yq install curl) + if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal + apt-get -q update && apt-get -yq install curl + elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 + dnf -y update + dnf -y install curl-minimal + elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum -y update + yum -y install curl + else + echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 + exit 1 + fi curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }} @@ -330,7 +364,18 @@ jobs: BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} run: | ${{ inputs.wasm_sdk_pre_build_command }} - which curl || (apt -q update && apt -yq install curl) + if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal + apt-get -q update && apt-get -yq install curl + elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9 + dnf -y update + dnf -y install curl-minimal + elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2 + yum -y update + yum -y install curl + else + echo "Unknown package manager (tried apt-get, dnf, yum)" >&2 + exit 1 + fi curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ bash -s -- --embedded-wasm --flags="$BUILD_FLAGS" ${{ matrix.swift_version }}