diff --git a/.github/workflows/android_sdk.yml b/.github/workflows/android_sdk.yml new file mode 100644 index 0000000000..e970a7b908 --- /dev/null +++ b/.github/workflows/android_sdk.yml @@ -0,0 +1,40 @@ +name: Android SDK + +permissions: + contents: read + +on: + workflow_call: + inputs: + env_vars: + type: string + description: "Environment variables for jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')." + default: "{}" + additional_command_arguments: + type: string + description: "Additional arguments passed to swift build (the Android SDK will be specified). Defaults to empty." + default: "" + +jobs: + android-sdk: + name: Android Swift SDK + # Workaround https://github.com/nektos/act/issues/1875 + uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main + with: + name: "Android Swift SDK" + matrix_string: >- + { + "config":[ + { + "name":"main Jammy", + "swift_version":"main", + "platform":"Linux", + "runner":"ubuntu-latest", + "image":"ubuntu:jammy", + "setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_sdk.sh | INSTALL_SWIFT_BRANCH=main INSTALL_SWIFT_ARCH=x86_64 INSTALL_SWIFT_SDK=android-sdk bash && hash -r", + "command":"curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/swift-build-with-android-sdk.sh | bash -s --", + "command_arguments":"${{ inputs.additional_command_arguments }}", + "env":'"$env_vars_json"' + } + ] + } diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe482be693..1c63e64146 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,6 +71,13 @@ jobs: with: additional_command_arguments: "--target NIOCore" + android-sdk: + name: Android Swift SDK + # Workaround https://github.com/nektos/act/issues/1875 + uses: apple/swift-nio/.github/workflows/android_sdk.yml@main + with: + additional_command_arguments: "--target NIOCore" + macos-tests: name: macOS tests # Workaround https://github.com/nektos/act/issues/1875 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 527e4efb76..5b1e590eca 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -105,6 +105,13 @@ jobs: with: additional_command_arguments: "--target NIOCore" + android-sdk: + name: Android Swift SDK + # Workaround https://github.com/nektos/act/issues/1875 + uses: apple/swift-nio/.github/workflows/android_sdk.yml@main + with: + additional_command_arguments: "--target NIOCore" + release-builds: name: Release builds uses: apple/swift-nio/.github/workflows/release_builds.yml@main diff --git a/scripts/install_swift_sdk.sh b/scripts/install_swift_sdk.sh index af26da75f2..31a2205dfa 100755 --- a/scripts/install_swift_sdk.sh +++ b/scripts/install_swift_sdk.sh @@ -53,6 +53,10 @@ case "$sdk" in sdk_dir="wasm-sdk" sdk_suffix="_wasm" ;; + "android-sdk") + sdk_dir="android-sdk" + sdk_suffix="_android-0.1" + ;; *) fatal "Unexpected Swift SDK: $sdk" ;; diff --git a/scripts/swift-build-with-android-sdk.sh b/scripts/swift-build-with-android-sdk.sh new file mode 100755 index 0000000000..7dcfa44db2 --- /dev/null +++ b/scripts/swift-build-with-android-sdk.sh @@ -0,0 +1,26 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftNIO open source project +## +## Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +set -uo pipefail + +# Select the Swift SDK for Android +SWIFT_SDK="$(swift sdk list | grep android | head -n1)" +if [[ -z "$SWIFT_SDK" ]]; then + echo "No Android Swift SDK found. Please ensure you have the Android Swift SDK installed." + exit 1 +fi + +echo "Using Swift SDK: $SWIFT_SDK" +swift build --swift-sdk "$SWIFT_SDK" "${@}"