Skip to content

Commit 412a870

Browse files
authored
Android SDK Workflow (#3418)
### Motivation: Android SDKs now exist and testing is good. ### Modifications: Add an Android GitHub Actions workflow using the latest nightly image and enable it in NIO targetting NIOCore (matching WASM testing). ### Result: More reusable workflows and more test coverage for NIO See this in action here (the CI job works but NIOCore fails to build): https://github.com/apple/swift-nio/actions/runs/18718487605/job/53384086329?pr=3418
1 parent e46b29f commit 412a870

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

.github/workflows/android_sdk.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Android SDK
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
env_vars:
10+
type: string
11+
description: "Environment variables for jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
12+
default: "{}"
13+
additional_command_arguments:
14+
type: string
15+
description: "Additional arguments passed to swift build (the Android SDK will be specified). Defaults to empty."
16+
default: ""
17+
18+
jobs:
19+
android-sdk:
20+
name: Android Swift SDK
21+
# Workaround https://github.com/nektos/act/issues/1875
22+
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
23+
with:
24+
name: "Android Swift SDK"
25+
matrix_string: >-
26+
{
27+
"config":[
28+
{
29+
"name":"main Jammy",
30+
"swift_version":"main",
31+
"platform":"Linux",
32+
"runner":"ubuntu-latest",
33+
"image":"ubuntu:jammy",
34+
"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",
35+
"command":"curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/swift-build-with-android-sdk.sh | bash -s --",
36+
"command_arguments":"${{ inputs.additional_command_arguments }}",
37+
"env":'"$env_vars_json"'
38+
}
39+
]
40+
}

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ jobs:
7171
with:
7272
additional_command_arguments: "--target NIOCore"
7373

74+
android-sdk:
75+
name: Android Swift SDK
76+
# Workaround https://github.com/nektos/act/issues/1875
77+
uses: apple/swift-nio/.github/workflows/android_sdk.yml@main
78+
with:
79+
additional_command_arguments: "--target NIOCore"
80+
7481
macos-tests:
7582
name: macOS tests
7683
# Workaround https://github.com/nektos/act/issues/1875

.github/workflows/pull_request.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ jobs:
105105
with:
106106
additional_command_arguments: "--target NIOCore"
107107

108+
android-sdk:
109+
name: Android Swift SDK
110+
# Workaround https://github.com/nektos/act/issues/1875
111+
uses: apple/swift-nio/.github/workflows/android_sdk.yml@main
112+
with:
113+
additional_command_arguments: "--target NIOCore"
114+
108115
release-builds:
109116
name: Release builds
110117
uses: apple/swift-nio/.github/workflows/release_builds.yml@main

scripts/install_swift_sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ case "$sdk" in
5353
sdk_dir="wasm-sdk"
5454
sdk_suffix="_wasm"
5555
;;
56+
"android-sdk")
57+
sdk_dir="android-sdk"
58+
sdk_suffix="_android-0.1"
59+
;;
5660
*)
5761
fatal "Unexpected Swift SDK: $sdk"
5862
;;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftNIO open source project
5+
##
6+
## Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -uo pipefail
17+
18+
# Select the Swift SDK for Android
19+
SWIFT_SDK="$(swift sdk list | grep android | head -n1)"
20+
if [[ -z "$SWIFT_SDK" ]]; then
21+
echo "No Android Swift SDK found. Please ensure you have the Android Swift SDK installed."
22+
exit 1
23+
fi
24+
25+
echo "Using Swift SDK: $SWIFT_SDK"
26+
swift build --swift-sdk "$SWIFT_SDK" "${@}"

0 commit comments

Comments
 (0)