-
Notifications
You must be signed in to change notification settings - Fork 16
340 lines (328 loc) · 18.6 KB
/
sdks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: SDKs
on:
pull_request:
schedule:
- cron: '0 9 * * *'
jobs:
get-latest-toolchain:
runs-on: ubuntu-latest
strategy:
matrix:
version: [release, devel, trunk]
outputs:
release-version: ${{ steps.check.outputs.release-tag }}
devel-version: ${{ steps.check.outputs.devel-tag }}
trunk-version: ${{ steps.check.outputs.trunk-tag }}
steps:
- name: Check for latest Swift ${{ matrix.version }} toolchain
id: check
run: |
if [ ${{ matrix.version }} = 'release' ]; then
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/releases | grep -m1 swift-5.9 | cut -d- -f2)
SWIFT_TAG="swift-${LATEST_TOOLCHAIN_VERSION}-RELEASE"
echo "release-tag=$SWIFT_TAG" >> $GITHUB_OUTPUT
elif [ ${{ matrix.version }} = 'devel' ]; then
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-5.10-DEV | cut -d- -f8-10)
SWIFT_TAG="swift-5.10-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
echo "devel-tag=$SWIFT_TAG" >> $GITHUB_OUTPUT
else
LATEST_TOOLCHAIN_VERSION=$(curl -sL https://github.com/apple/swift/tags | grep -m1 swift-DEV | cut -d- -f7-9)
SWIFT_TAG="swift-DEVELOPMENT-SNAPSHOT-${LATEST_TOOLCHAIN_VERSION}-a"
echo "trunk-tag=$SWIFT_TAG" >> $GITHUB_OUTPUT
fi
echo "latest-tag=$SWIFT_TAG" >> $GITHUB_OUTPUT
- name: Get cached toolchain
id: cache-toolchain
uses: actions/cache@v3
with:
path: ~/${{ steps.check.outputs.latest-tag }}-ubuntu22.04.tar.gz
key: ${{ steps.check.outputs.latest-tag }}-toolchain
- name: Get latest toolchain if not cached
if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }}
run: |
if [ ${{ matrix.version }} = 'release' ]; then
SWIFT_BRANCH="swift-$(echo ${{ steps.check.outputs.release-tag }} | cut -d- -f2)-release"
elif [ ${{ matrix.version }} = 'devel' ]; then
SWIFT_BRANCH="swift-5.10-branch"
else
SWIFT_BRANCH="development"
fi
cd
SWIFT_TAG="${{ steps.check.outputs.latest-tag }}"
wget -q https://download.swift.org/$SWIFT_BRANCH/ubuntu2204/$SWIFT_TAG/$SWIFT_TAG-ubuntu22.04.tar.gz
echo "got latest toolchain: ${SWIFT_TAG}"
build-sdk-and-tests:
runs-on: ubuntu-latest
needs: get-latest-toolchain
strategy:
fail-fast: false
matrix:
version: [release, devel, trunk]
arch: [aarch64, x86_64, armv7]
env:
ANDROID_API_LEVEL: 24
steps:
- name: Extract the latest version string
id: version
run: |
if [ ${{ matrix.version }} = 'release' ]; then
TAG="${{ needs.get-latest-toolchain.outputs.release-version }}"
echo "latest=$(echo $TAG | cut -d- -f2)" >> $GITHUB_OUTPUT
elif [ ${{ matrix.version }} = 'devel' ]; then
TAG="${{ needs.get-latest-toolchain.outputs.devel-version }}"
echo "latest=$(echo $TAG | cut -d- -f5-7)" >> $GITHUB_OUTPUT
else
TAG="${{ needs.get-latest-toolchain.outputs.trunk-version }}"
echo "latest=$(echo $TAG | cut -d- -f4-6)" >> $GITHUB_OUTPUT
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Get cached Swift ${{ matrix.version }} toolchain
id: cache-toolchain
uses: actions/cache@v3
with:
path: ~/${{ steps.version.outputs.tag }}-ubuntu22.04.tar.gz
key: ${{ steps.version.outputs.tag }}-toolchain
- name: Get cached SDK
id: cache-sdk
uses: actions/cache@v3
with:
path: ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}-*-sdk.tar.xz
key: ${{ matrix.version }}-${{ steps.version.outputs.latest }}-${{ matrix.arch }}-bump-sdk
- name: Clone
uses: actions/checkout@v3
with:
path: sdk-config
- name: Build Swift ${{ matrix.version }} Android SDK if not the latest
if: ${{ steps.cache-sdk.outputs.cache-hit != 'true' }}
env:
SWIFT_TAG: ${{ steps.version.outputs.tag }}
ANDROID_ARCH: ${{ matrix.arch }}
run: |
cd sdk-config
sudo apt install ninja-build
BUILD_SWIFT_PM=1 swift get-packages-and-swift-source.swift
SDK_NAME=$(ls | grep swift-${{ matrix.version }}-android-${{ matrix.arch }})
SDK=`pwd`/$SDK_NAME
tar xf ~/$SWIFT_TAG-ubuntu22.04.tar.gz
git apply swift-android.patch swift-android-ci.patch
sed -i "s%/data/data/com.termux/files%$SDK%" $SDK/usr/lib/pkgconfig/sqlite3.pc
sed -i "s%String(cString: getpass%\"fake\" //%" swiftpm/Sources/PackageRegistryTool/PackageRegistryTool+Auth.swift
sed -i "s%#include <unistd%#include <signal.h>\n#include <unistd%" swift-corelibs-libdispatch/dispatch/dispatch.h
sed -i "s%#include <unistd%#include <signal.h>\n#include <unistd%" llbuild/products/libllbuild/include/llbuild/buildsystem.h
sed -i "s%#include <time%#include <signal.h>\n#include <time%" swift-tools-support-core/Sources/TSCclibc/include/indexstore_functions.h
sed -i "s%#include <time%#include <signal.h>\n#include <time%" swift-crypto/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h
if [ ${{ matrix.version }} == 'devel' ]; then
sed -i "s%, \"llbuild\"\]%\]%" llbuild/Package.swift
fi
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android --android-ndk $ANDROID_NDK --android-arch ${{ matrix.arch }} --android-api-level $ANDROID_API_LEVEL --build-swift-tools=0 --native-swift-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --native-clang-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --cross-compile-hosts=android-${{ matrix.arch }} --cross-compile-deps-path=$SDK --skip-local-build --build-swift-static-stdlib --xctest --skip-early-swift-driver --install-swift --install-libdispatch --install-foundation --install-xctest --install-destdir=$SDK --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay' --cross-compile-append-host-target-to-destdir=False -b -p --install-llbuild --sourcekit-lsp --skip-early-swiftsyntax
cp $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$(echo ${{ matrix.arch }} | sed "s/v7//")-linux-android*/libc++_shared.so $SDK/usr/lib
patchelf --set-rpath \$ORIGIN $SDK/usr/lib/swift/android/libdispatch.so
patchelf --set-rpath \$ORIGIN/../..:\$ORIGIN $SDK/usr/lib/swift/android/lib[FXs]*.so
tar cJf ~/$SDK_NAME.tar.xz $SDK_NAME
rm -rf $SDK_NAME
- name: Unpack ${{ matrix.version }} toolchain and SDK
id: sdk-unpack
run: |
cd sdk-config
if [ ! -d ${{ steps.version.outputs.tag }}-ubuntu22.04 ]; then
tar xf ~/${{ steps.version.outputs.tag }}-ubuntu22.04.tar.gz
fi
tar xf ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-${ANDROID_API_LEVEL}-sdk.tar.xz
- name: Get Swift Argument Parser package
uses: actions/checkout@v3
with:
repository: apple/swift-argument-parser
path: swift-argument-parser
- name: Build Swift Argument Parser package
run: |
cd swift-argument-parser
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift crypto package
uses: actions/checkout@v3
with:
repository: apple/swift-crypto
path: swift-crypto
- name: Build Swift crypto package
run: |
cd swift-crypto
sed -i "s%#include <time%#include <signal.h>\n#include <time%" Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h
sed -i "s%\\\\(testsDirectory)/.*Vectors%/data/local/tmp/pack/crypto-vectors%" Tests/CryptoTests/Utils/RFCVector.swift Tests/CryptoTests/Utils/Wycheproof.swift Tests/_CryptoExtrasTests/Utils/Wycheproof.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift NIO package
uses: actions/checkout@v3
with:
repository: apple/swift-nio
path: swift-nio
- name: Build Swift NIO package
run: |
cd swift-nio
git apply ../sdk-config/swift-nio-disable-ecn-tests.patch
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift Numerics package
uses: actions/checkout@v3
with:
repository: apple/swift-numerics
path: swift-numerics
- name: Build Swift Numerics package
run: |
cd swift-numerics
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift System package
uses: actions/checkout@v3
with:
repository: apple/swift-system
path: ss
- name: Build Swift System package
run: |
cd ss
sed -i "s%/tmp%/data/local/tmp%" Tests/SystemTests/FileOperationsTest.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift Collections package
uses: actions/checkout@v3
with:
repository: apple/swift-collections
path: sco
- name: Build Swift Collections package
run: |
cd sco
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build -j 1 --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift Atomics package
uses: actions/checkout@v3
with:
repository: apple/swift-atomics
path: swift-atomics
ref: 1.1.0
- name: Get Swift NIO SSH package
uses: actions/checkout@v3
with:
repository: apple/swift-nio-ssh
path: sns
- name: Build Swift NIO SSH package
run: |
cd sns
sed -i "s%url: .*swift-\(\w\+\)\.git.*$%path: \"../swift-\1\"),%g" Package.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift NIO SSL package
uses: actions/checkout@v3
with:
repository: apple/swift-nio-ssl
path: snl
- name: Build Swift NIO SSL package
run: |
cd snl
sed -i "s%#include <time%#include <signal.h>\n#include <time%" Sources/CNIOBoringSSL/include/CNIOBoringSSL_asn1.h
SWIFTCI_USE_LOCAL_DEPS=1 ../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Yams package
uses: actions/checkout@v3
with:
repository: jpsim/Yams
path: yams
- name: Build Yams package
run: |
cd yams
sed -i "s% fixturesDirectory + \"/SourceKitten#289% \"/data/local/tmp/pack%" Tests/YamsTests/PerformanceTests.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift NIO HTTP/2 package
uses: actions/checkout@v3
with:
repository: apple/swift-nio-http2
path: snh
- name: Build Swift NIO HTTP/2 package
if: ${{ matrix.arch != 'armv7' }}
run: |
cd snh
sed -i "s%url: .*swift-\(\w\+\)\.git.*$%path: \"../swift-\1\"),%g" Package.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get Swift Algorithms package
uses: actions/checkout@v3
with:
repository: apple/swift-algorithms
path: sa
- name: Build Swift Algorithms package
run: |
cd sa
sed -i "s%url: .*$%path: \"../swift-numerics\"),%" Package.swift
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
- name: Get cached Termux debug app for NIO tests
if: ${{ matrix.arch == 'x86_64' }}
id: cache-termux
uses: actions/cache@v3
with:
path: ~/termux-debug.apk
key: termux-app
- name: Get Termux debug app if not cached
if: ${{ matrix.arch == 'x86_64' && steps.cache-termux.outputs.cache-hit != 'true'}}
run: wget -O ~/termux-debug.apk https://github.com/termux/termux-app/releases/download/v0.118.0/termux-app_v0.118.0+github-debug_x86_64.apk
- name: Put SDK and x86_64 tests in one directory to push to Android x86_64 emulator
run: |
mkdir pack
cp ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-${ANDROID_API_LEVEL}-sdk.tar.xz pack
if [ ${{ matrix.arch }} = 'x86_64' ]; then
mkdir -p pack/lib/swift/android
TARGET="x86_64-unknown-linux-android$ANDROID_API_LEVEL"
cp swift-argument-parser/.build/$TARGET/debug/{generate-manual,math,repeat,roll,swift-argument-parserPackageTests.xctest} pack
wget -q https://raw.githubusercontent.com/termux/termux-elf-cleaner/v1.10/termux-elf-cleaner.cpp
wget -q https://raw.githubusercontent.com/termux/termux-elf-cleaner/v1.10/elf.h
clang -D__ANDROID_API__=$ANDROID_API_LEVEL -o elf-cleaner termux-elf-cleaner.cpp
./elf-cleaner pack/{generate-manual,math,repeat,roll} || true
cp swift-crypto/.build/$TARGET/debug/swift-cryptoPackageTests.xctest pack
cp swift-nio/.build/$TARGET/debug/swift-nioPackageTests.xctest pack
cp swift-numerics/.build/$TARGET/debug/swift-numericsPackageTests.xctest pack
cp ss/.build/$TARGET/debug/swift-systemPackageTests.xctest pack
cp sco/.build/$TARGET/debug/swift-collectionsPackageTests.xctest pack
cp sns/.build/$TARGET/debug/swift-nio-sshPackageTests.xctest pack
cp snl/.build/$TARGET/debug/swift-nio-sslPackageTests.xctest pack
cp yams/.build/$TARGET/debug/YamsPackageTests.xctest pack
cp snh/.build/$TARGET/debug/swift-nio-http2PackageTests.xctest pack
cp sa/.build/$TARGET/debug/swift-algorithmsPackageTests.xctest pack
mkdir pack/crypto-vectors pack/swift-crypto_CryptoTests.resources
cp swift-crypto/Tests/Test\ Vectors/* swift-crypto/Tests/_CryptoExtrasVectors/* pack/crypto-vectors
cp swift-crypto/Tests/CryptoTests/HPKE/hpke-test-vectors.json pack/swift-crypto_CryptoTests.resources
cp yams/Tests/YamsTests/Fixtures/SourceKitten#289/debug.yaml pack
cp sdk-config/swift-${{ matrix.version }}*-android-x86_64-*${ANDROID_API_LEVEL}-sdk/usr/lib/lib*so pack/lib
cp sdk-config/swift-${{ matrix.version }}*-android-x86_64-*${ANDROID_API_LEVEL}-sdk/usr/lib/swift/android/lib*so pack/lib/swift/android
mv pack/lib/libc++_shared.so pack/lib/swift/android
cp ~/termux-debug.apk pack
fi
- name: Upload test directory
uses: actions/upload-artifact@v3
with:
name: sdk-tests-${{ matrix.version }}-${{ matrix.arch }}
path: pack/
run-tests-on-android-x86_64-emulator:
runs-on: macos-latest
needs: build-sdk-and-tests
strategy:
fail-fast: false
matrix:
version: [release, devel, trunk]
steps:
- name: Download test directory
uses: actions/download-artifact@v3
with:
name: sdk-tests-${{ matrix.version }}-x86_64
path: pack
- name: Run tests on Android x86_64 emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 24
arch: x86_64
script: |
rm pack/swift-${{ matrix.version }}-android-x86_64*-sdk.tar.xz
adb install pack/termux-debug.apk
chmod 755 pack/{generate-manual,math,repeat,roll,*.xctest}
adb push pack /data/local/tmp
adb shell /data/local/tmp/pack/swift-argument-parserPackageTests.xctest
adb shell /data/local/tmp/pack/swift-cryptoPackageTests.xctest
adb shell "run-as com.termux mkdir /data/data/com.termux/pack"
adb shell "run-as com.termux cp /data/local/tmp/pack/swift-nioPackageTests.xctest /data/data/com.termux/pack"
adb shell "run-as com.termux cp -r /data/local/tmp/pack/lib /data/data/com.termux/pack"
adb shell "run-as com.termux sh -c 'TMPDIR=/data/data/com.termux /data/data/com.termux/pack/swift-nioPackageTests.xctest'"
adb shell /data/local/tmp/pack/swift-numericsPackageTests.xctest
adb shell /data/local/tmp/pack/swift-systemPackageTests.xctest
adb shell /data/local/tmp/pack/swift-collectionsPackageTests.xctest
adb shell /data/local/tmp/pack/swift-nio-sshPackageTests.xctest
adb shell /data/local/tmp/pack/swift-nio-sslPackageTests.xctest
adb shell /data/local/tmp/pack/swift-nio-http2PackageTests.xctest
adb shell /data/local/tmp/pack/swift-algorithmsPackageTests.xctest
adb shell /data/local/tmp/pack/YamsPackageTests.xctest