|
| 1 | +# This source file is part of the Swift.org open source project |
| 2 | +# |
| 3 | +# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors |
| 4 | +# Licensed under Apache License v2.0 with Runtime Library Exception |
| 5 | + |
| 6 | +# See http://swift.org/LICENSE.txt for license information |
| 7 | +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors |
| 8 | + |
| 9 | +name: Android Tests |
| 10 | + |
| 11 | +on: [push, pull_request] |
| 12 | + |
| 13 | +jobs: |
| 14 | + Android: |
| 15 | + runs-on: ubuntu-18.04 |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v1 |
| 18 | + - name: Validate |
| 19 | + run: | |
| 20 | + echo 'Fetching Swift...' |
| 21 | + repository_directory=$(pwd) |
| 22 | + mkdir -p .build/Android/Swift |
| 23 | + cd .build/Android/Swift |
| 24 | + curl -o Swift.tar.gz 'https://swift.org/builds/development/ubuntu1804/swift-DEVELOPMENT-SNAPSHOT-2020-02-11-a/swift-DEVELOPMENT-SNAPSHOT-2020-02-11-a-ubuntu18.04.tar.gz' |
| 25 | + tar --extract --file Swift.tar.gz |
| 26 | + sudo cp -R swift-DEVELOPMENT-SNAPSHOT-2020-02-11-a-ubuntu18.04/usr/* /usr/ |
| 27 | + cd "${repository_directory}" |
| 28 | + swift --version |
| 29 | +
|
| 30 | + echo 'Fetching Swift cross‐compilation toolchain...' |
| 31 | + mkdir -p .build/Android/Experimental_Swift |
| 32 | + cd .build/Android/Experimental_Swift |
| 33 | + curl -L -o toolchain-linux-x64.zip 'https://github.com/SDGGiesbrecht/Workspace/releases/download/experimental%E2%80%90swift%E2%80%90pre%E2%80%905.2%E2%80%902020%E2%80%9002%E2%80%9005/toolchain-linux-x64.zip' |
| 34 | + unzip toolchain-linux-x64.zip |
| 35 | + sudo mv toolchain-linux-x64/Library /Library |
| 36 | + chmod -R a+rwx /Library |
| 37 | + cd "${repository_directory}" |
| 38 | + /Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swift --version |
| 39 | +
|
| 40 | + echo 'Fetching Swift Android SDK...' |
| 41 | + cd .build/Android/Experimental_Swift |
| 42 | + curl -L -o sdk-android-x64.zip 'https://github.com/SDGGiesbrecht/Workspace/releases/download/experimental%E2%80%90swift%E2%80%90pre%E2%80%905.2%E2%80%902020%E2%80%9002%E2%80%9005/sdk-android-x64.zip' |
| 43 | + unzip sdk-android-x64.zip |
| 44 | + mv sdk-android-x64/Library/Developer/Platforms /Library/Developer/Platforms |
| 45 | + sed -i -e s~C:/Microsoft/AndroidNDK64/android-ndk-r16b~${ANDROID_HOME}/ndk-bundle~g /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk/usr/lib/swift/android/x86_64/glibc.modulemap |
| 46 | + sudo apt-get update --yes |
| 47 | + sudo apt-get install --yes patchelf |
| 48 | + patchelf --replace-needed lib/swift/android/x86_64/libswiftCore.so libswiftCore.so /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk/usr/lib/swift/android/libswiftSwiftOnoneSupport.so |
| 49 | + patchelf --replace-needed lib/swift/android/x86_64/libswiftCore.so libswiftCore.so /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk/usr/lib/swift/android/libswiftGlibc.so |
| 50 | + cp -R "${ANDROID_HOME}/ndk-bundle/platforms/android-29/arch-x86_64/"* /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk |
| 51 | + cd "${repository_directory}" |
| 52 | +
|
| 53 | + echo 'Fetching ICU...' |
| 54 | + cd .build/Android/Experimental_Swift |
| 55 | + curl -L -o icu-android-x64.zip 'https://github.com/SDGGiesbrecht/Workspace/releases/download/experimental%E2%80%90swift%E2%80%90pre%E2%80%905.2%E2%80%902020%E2%80%9002%E2%80%9005/icu-android-x64.zip' |
| 56 | + unzip icu-android-x64.zip |
| 57 | + mv icu-android-x64/Library/icu-64 /Library/icu-64 |
| 58 | + curl -L -o libicudt64.so 'https://github.com/SDGGiesbrecht/Workspace/releases/download/experimental%E2%80%90swift%E2%80%90pre%E2%80%905.2%E2%80%902020%E2%80%9002%E2%80%9005/libicudt64.so' |
| 59 | + mv libicudt64.so /Library/icu-64/usr/lib/libicudt64.so |
| 60 | + cd "${repository_directory}" |
| 61 | +
|
| 62 | + echo 'Fetching dependencies...' |
| 63 | + sudo apt-get update --yes |
| 64 | + sudo apt-get install --yes libsqlite3-dev libncurses-dev |
| 65 | +
|
| 66 | + echo 'Building SwiftPM...' |
| 67 | + swift build |
| 68 | +
|
| 69 | + echo 'Building package...' |
| 70 | + swift run swift-build --package-path Fixtures/Miscellaneous/CrossPlatform \ |
| 71 | + --build-tests --enable-test-discovery \ |
| 72 | + --triple x86_64-unknown-linux-android \ |
| 73 | + --sdk /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk \ |
| 74 | + --toolchain /Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain \ |
| 75 | + -Xswiftc -sdk -Xswiftc /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk \ |
| 76 | + -Xswiftc -resource-dir -Xswiftc /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk/usr/lib/swift \ |
| 77 | + -Xswiftc -tools-directory -Xswiftc ${ANDROID_HOME}/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin \ |
| 78 | + -Xswiftc -Xclang-linker -Xswiftc --gcc-toolchain=${ANDROID_HOME}/ndk-bundle/toolchains/x86_64-4.9/prebuilt/linux-x86_64 \ |
| 79 | + -Xcc -I${ANDROID_HOME}/ndk-bundle/sysroot/usr/include \ |
| 80 | + -Xcc -I${ANDROID_HOME}/ndk-bundle/sysroot/usr/include/x86_64-linux-android \ |
| 81 | + -Xswiftc -I -Xswiftc /Library/Developer/Platforms/Android.platform/Developer/Library/XCTest-development/usr/lib/swift/android/x86_64 \ |
| 82 | + -Xswiftc -L -Xswiftc /Library/Developer/Platforms/Android.platform/Developer/Library/XCTest-development/usr/lib/swift/android |
| 83 | +
|
| 84 | + echo 'Copying libraries...' |
| 85 | + cp -R "${ANDROID_HOME}/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86_64/"* Fixtures/Miscellaneous/CrossPlatform/.build/x86_64-unknown-linux-android/debug |
| 86 | + cp -R /Library/icu-64/usr/lib/* Fixtures/Miscellaneous/CrossPlatform/.build/x86_64-unknown-linux-android/debug |
| 87 | + cp -R /Library/Developer/Platforms/Android.platform/Developer/SDKs/Android.sdk/usr/lib/swift/android/* Fixtures/Miscellaneous/CrossPlatform/.build/x86_64-unknown-linux-android/debug |
| 88 | + cp -R /Library/Developer/Platforms/Android.platform/Developer/Library/XCTest-development/usr/lib/swift/android/* Fixtures/Miscellaneous/CrossPlatform/.build/x86_64-unknown-linux-android/debug |
| 89 | + - uses: actions/upload-artifact@v1 |
| 90 | + with: |
| 91 | + name: products |
| 92 | + path: Fixtures/Miscellaneous/CrossPlatform/.build/x86_64-unknown-linux-android/debug |
| 93 | + AndroidII: |
| 94 | + runs-on: macos-latest |
| 95 | + needs: Android |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v1 |
| 98 | + - uses: actions/download-artifact@v1 |
| 99 | + with: |
| 100 | + name: products |
| 101 | + path: .build/x86_64-unknown-linux-android/debug |
| 102 | + - run: | |
| 103 | + mkdir -p .build/Android |
| 104 | + echo ' |
| 105 | + set -e |
| 106 | + adb -e push .build/x86_64-unknown-linux-android/debug /data/local/tmp/Android/.build/x86_64-unknown-linux-android/debug |
| 107 | + adb -e shell chmod -R +x /data/local/tmp/Android/.build/x86_64-unknown-linux-android/debug |
| 108 | + adb -e shell LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/data/local/tmp/Android/.build/x86_64-unknown-linux-android/debug /data/local/tmp/Android/.build/x86_64-unknown-linux-android/debug/CrossPlatformPackageTests.xctest |
| 109 | + ' > .build/Android/Emulator.sh |
| 110 | + chmod +x .build/Android/Emulator.sh |
| 111 | + - uses: malinskiy/action-android/install-sdk@release/0.0.5 |
| 112 | + - uses: malinskiy/action-android/emulator-run-cmd@release/0.0.5 |
| 113 | + with: |
| 114 | + abi: x86_64 |
| 115 | + cmd: .build/Android/Emulator.sh |
0 commit comments