@@ -16,20 +16,23 @@ jobs:
1616 - name : ' macOS 15 X64 API 28'
1717 os : ' macos-15-intel'
1818 ANDROID_API : 28
19+ NDK_VERSION : ' r27d'
1920 EMULATOR_ARCH : ' x86_64'
2021 EMULATOR_ARCH_TRIPLE : ' x86_64'
2122 EMULATOR_GPU : ' swiftshader_indirect'
2223
2324 - name : ' Ubuntu X64 API 28'
2425 os : ' ubuntu-latest'
2526 ANDROID_API : 28
27+ NDK_VERSION : ' r28c'
2628 EMULATOR_ARCH : ' x86_64'
2729 EMULATOR_ARCH_TRIPLE : ' x86_64'
2830 EMULATOR_GPU : ' swiftshader_indirect'
2931
3032 - name : ' Ubuntu X64 API 35'
3133 os : ' ubuntu-latest'
3234 ANDROID_API : 35
35+ NDK_VERSION : ' r29'
3336 EMULATOR_ARCH : ' x86_64'
3437 EMULATOR_ARCH_TRIPLE : ' x86_64'
3538 EMULATOR_GPU : ' swiftshader_indirect'
6467 ANDROID_EMULATOR_NAME : ' demo'
6568 ANDROID_PROFILE : " Nexus 10"
6669 ANDROID_CHANNEL : " 3"
67- ANDROID_NDK_VERSION : " r27d "
70+ ANDROID_NDK_VERSION : " ${{ matrix.NDK_VERSION }} "
6871 steps :
6972 - name : Free Disk Space
7073 if : runner.os == 'Linux'
@@ -122,11 +125,15 @@ jobs:
122125
123126 - name : Install Android NDK
124127 run : |
125- mkdir ~/android-ndk
126- cd ~/android-ndk
127- curl -fsSLO https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-$(uname -s).zip
128- unzip -q android-ndk-${ANDROID_NDK_VERSION}-*.zip
129- echo "ANDROID_NDK_HOME=${PWD}/android-ndk-${ANDROID_NDK_VERSION}" >> $GITHUB_ENV
128+ # Only install the NDK if it is overridden
129+ # Otherwise use the runner-installed NDK
130+ if [[ ! -z "${ANDROID_NDK_VERSION}" ]]; then
131+ mkdir ~/android-ndk
132+ cd ~/android-ndk
133+ curl -fsSLO https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-$(uname -s).zip
134+ unzip -q android-ndk-${ANDROID_NDK_VERSION}-*.zip
135+ echo "ANDROID_NDK_HOME=${PWD}/android-ndk-${ANDROID_NDK_VERSION}" >> $GITHUB_ENV
136+ fi
130137
131138 - name : Setup Android Environment
132139 run : |
@@ -148,21 +155,23 @@ jobs:
148155 cd hello
149156 swiftly run swift package init --type executable
150157
151- # make the contents a bit more interesting
152- cat > Sources/hello/hello.swift << "EOF"
153- import Foundation
154- import FoundationNetworking
155- import FoundationXML
156-
157- @main
158- struct hello {
159- static func main() async throws {
160- print("Hello, world!")
161- let (data, _) = try await URLSession.shared.data(from: URL(fileURLWithPath: "/etc/hosts"))
162- print(String(data: data, encoding: .utf8) ?? "")
163- }
164- }
165- EOF
158+ if [[ "0" == "1" ]]; then
159+ # make the contents a bit more interesting
160+ cat > Sources/hello/hello.swift << "EOF"
161+ import Foundation
162+ import FoundationNetworking
163+ import FoundationXML
164+
165+ @main
166+ struct hello {
167+ static func main() async throws {
168+ print("Hello, world!")
169+ let (data, _) = try await URLSession.shared.data(from : URL(fileURLWithPath: "/etc/hosts"))
170+ print(String(data : data, encoding: .utf8) ?? "")
171+ }
172+ }
173+ EOF
174+ fi
166175
167176 swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --static-swift-stdlib
168177 file .build/debug/hello
@@ -214,13 +223,25 @@ jobs:
214223 run : |
215224 adb shell 'echo Hello Android!'
216225
217- - name : Push Swift Executable to Android Emulator
226+ - name : Run Swift Executable on Android Emulator
218227 run : |
219228 cd hello
220229 adb push .build/debug/hello /data/local/tmp
221230 adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so /data/local/tmp/
231+ adb shell /data/local/tmp/hello
222232
223- - name : Run Swift Executable on Android Emulator
233+ - name : Run Swift Package tests Android Emulator
224234 run : |
225- adb shell /data/local/tmp/hello
235+ git clone https://github.com/apple/swift-algorithms
236+ cd swift-algorithms
237+ swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --build-tests
238+
239+ adb push .build/debug/swift-algorithmsPackageTests.xctest /data/local/tmp
240+
241+ cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm
242+ # add necessary dependencies
243+ adb push swift-sdks/${SWIFT_ANDROID_SDK_VERSION}*.artifactbundle/swift-resources/usr/lib/swift-${ANDROID_EMULATOR_ARCH_TRIPLE}/android/*.so /data/local/tmp/
244+ cd -
245+
246+ adb shell /data/local/tmp/swift-algorithmsPackageTests.xctest
226247
0 commit comments