Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ jobs:
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
Expand Down
5 changes: 5 additions & 0 deletions Sources/NIOPerformanceTester/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ import NIOCore
import NIOEmbedded
import NIOFoundationCompat
import NIOHTTP1
#if os(Android)
// workaround for error: reference to var 'stdout' is not concurrency-safe because it involves shared mutable state
@preconcurrency import NIOPosix
#else
import NIOPosix
#endif
import NIOWebSocket

// Use unbuffered stdout to help detect exactly which test was running in the event of a crash.
Expand Down
18 changes: 18 additions & 0 deletions scripts/install_swift_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ version="${INSTALL_SWIFT_VERSION:=""}"
arch="${INSTALL_SWIFT_ARCH:="aarch64"}"
os_image="${INSTALL_SWIFT_OS_IMAGE:="ubuntu22.04"}"
sdk="${INSTALL_SWIFT_SDK:="static-sdk"}"
android_ndk_version="${INSTALL_ANDROID_NDK:="r27d"}"

if [[ ! ( -n "$branch" && -z "$version" ) && ! ( -z "$branch" && -n "$version") ]]; then
fatal "Exactly one of build or version must be defined."
Expand Down Expand Up @@ -127,3 +128,20 @@ swift --version

log "Installing Swift SDK"
swift sdk install "$sdk_path"

log "Swift SDK Post-install"
if [[ "$sdk" == "android-sdk" ]]; then
# guess some common places where the swift-sdks folder lives
cd ~/Library/org.swift.swiftpm || cd ~/.config/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm || cd /root/.swiftpm || exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way we can know this ahead of time? We control the whole system here from a blank VM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do need to exit here can we use fatal and explain what the issue is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need the cd here can we just refer to things using longer paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We change directories so that the NDK is downloaded adjacent to the artifactbundle, otherwise it is in the current folder, which seems like it might cause confusion and clutter.

The path search is unfortunately because the swiftpm configuration folder varies based on OS and configuration. I observed that for the swift-nio test run that it was /root/.swiftpm/swift-sdks, but I'm not sure if that will always be the case.

Note that we could do this and it would just work, plus it would allow us to avoid needing to change directories:

cd $(swift sdk configure --show-configuration swift-DEVELOPMENT-SNAPSHOT-2025-10-17-a-android-0.1 | grep 'sdkRootPath: ' | head -n 1 | cut -f 2- -d ':')/../../../..

That's pretty gnarly, but let me know if you think it is preferable and I will implement it.


# download and link the NDK
android_ndk_url="https://dl.google.com/android/repository/android-ndk-${android_ndk_version}-$(uname -s).zip"
log "Android Native Development Kit URL: ${android_ndk_url}"
"$CURL_BIN" -fsSL -o ndk.zip --retry 3 "${android_ndk_url}"
unzip -q ndk.zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we parametrize this like we do with e.g. curl?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose also the use of curl above to CURL_BIN 😄

rm ndk.zip
export ANDROID_NDK_HOME="${PWD}/android-ndk-${android_ndk_version}"
bundledir=$(find . -type d -maxdepth 2 -name '*android*.artifactbundle' | head -n 1)
"${bundledir}"/swift-android/scripts/setup-android-sdk.sh
cd - || exit
fi