-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (226 loc) · 10.4 KB
/
ci.yml
File metadata and controls
271 lines (226 loc) · 10.4 KB
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
name: sdk-install-demo ci
on:
push:
branches: [ main ]
workflow_dispatch:
pull_request:
schedule:
- cron: '0 13 * * *'
jobs:
install-sdk:
strategy:
fail-fast: false
matrix:
include:
- name: 'macOS 15 X64 API 28'
os: 'macos-15-intel'
ANDROID_API: 28
NDK_VERSION: 'r27d'
EMULATOR_ARCH: 'x86_64'
EMULATOR_ARCH_TRIPLE: 'x86_64'
- name: 'Ubuntu X64 API 28'
os: 'ubuntu-latest'
ANDROID_API: 28
NDK_VERSION: 'r28c'
EMULATOR_ARCH: 'x86_64'
EMULATOR_ARCH_TRIPLE: 'x86_64'
- name: 'Ubuntu X64 API 35'
os: 'ubuntu-latest'
ANDROID_API: 35
NDK_VERSION: 'r29'
EMULATOR_ARCH: 'x86_64'
EMULATOR_ARCH_TRIPLE: 'x86_64'
- name: 'macOS 15 X64 API 36'
os: 'macos-15-intel'
ANDROID_API: 36
NDK_VERSION: 'r27d'
EMULATOR_ARCH: 'x86_64'
EMULATOR_ARCH_TRIPLE: 'x86_64'
# Android SDK for Linux is only x86_64
#- name: 'Ubuntu ARM API 28'
# os: 'ubuntu-24.04-arm'
# ANDROID_API: 28
# EMULATOR_ARCH: 'arm64-v8a'
# EMULATOR_ARCH_TRIPLE: 'aarch64'
# Cannot test on ARM macOS because Android emulator required nested
# virtualization
#- name: 'macOS 15 ARM'
# os: 'macos-15'
# ANDROID_API: 28
# EMULATOR_ARCH: 'arm64-v8a'
# EMULATOR_ARCH_TRIPLE: 'aarch64'
runs-on: ${{ matrix.os }}
env:
ANDROID_API: ${{ matrix.ANDROID_API }}
ANDROID_EMULATOR_ARCH: ${{ matrix.EMULATOR_ARCH }}
ANDROID_EMULATOR_ARCH_TRIPLE: ${{ matrix.EMULATOR_ARCH_TRIPLE }}
ANDROID_TARGET: 'default'
#ANDROID_BUILD_TOOLS_VERSION: 36.0.0
ANDROID_BUILD_TOOLS_VERSION: 'latest'
BUILD_TOOLS_VERSION: "35.0.0"
ANDROID_EMULATOR_NAME: 'demo'
ANDROID_PROFILE: "Nexus 10"
ANDROID_CHANNEL: "3"
ANDROID_NDK_VERSION: "${{ matrix.NDK_VERSION }}"
steps:
- name: Free Disk Space
if: runner.os == 'Linux'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Android Emulator - Create
run: |
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list_installed
EMULATOR_SPEC="system-images;android-${ANDROID_API};default;${ANDROID_EMULATOR_ARCH}"
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "${EMULATOR_SPEC}" --channel=3
yes | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n "${ANDROID_EMULATOR_NAME}" -k "${EMULATOR_SPEC}" --device "${ANDROID_PROFILE}"
$ANDROID_HOME/emulator/emulator -list-avds
nohup $ANDROID_HOME/emulator/emulator -memory 4096 -avd "${ANDROID_EMULATOR_NAME}" -wipe-data -no-window -no-snapshot -noaudio -no-boot-anim 2>&1 > emulator.log &
#- name: Android - Find AVDs
# run: find ~/ -type d -name '*.avd'
#- name: Android - List AVDs
# run: emulator -list-avds
#- name: Android - Boot
# run: nohup emulator -memory 4096 -avd "${ANDROID_EMULATOR_NAME}" -wipe-data -no-window -no-snapshot -noaudio -no-boot-anim 2>&1 > emulator.log &
- name: Install Prerequisites
run: |
if [[ "${RUNNER_OS}" == "Linux" ]]; then
# libcurl4-openssl-dev needed for host toolchain
sudo apt-get -y install libcurl4-openssl-dev
fi
# swiftly install instructions from https://www.swift.org/install/linux/
- name: Install Swiftly
run: |
if [[ "${RUNNER_OS}" == "macOS" ]]; then
curl -fsSL -O https://download.swift.org/swiftly/darwin/swiftly.pkg
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory
~/.swiftly/bin/swiftly init --quiet-shell-followup --skip-install
. "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh"
elif [[ "${RUNNER_OS}" == "Linux" ]]; then
curl -fsSL -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz
tar zxf swiftly-$(uname -m).tar.gz
./swiftly init --quiet-shell-followup --skip-install
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh"
else
echo "Error: unsupported OS: ${RUNNER_OS}"
exit 1
fi
hash -r
echo "${SWIFTLY_BIN_DIR}" >> "${GITHUB_PATH}"
- name: Get Latest Toolchain Info
run: |
sdk_json=$(curl -fsSL "https://www.swift.org/api/v1/install/dev/main/android-sdk.json") || fatal "Failed to fetch android-sdk development snapshots"
download=$(echo "$sdk_json" | jq -r '.[0].download')
snapshot_tag=$(echo "$sdk_json" | jq -r '.[0].dir')
checksum=$(echo "$sdk_json" | jq -r '.[0].checksum')
echo "SWIFT_TOOLCHAIN_VERSION=${snapshot_tag}" >> ${GITHUB_ENV}
echo "SWIFT_ANDROID_SDK_VERSION=${snapshot_tag}" >> ${GITHUB_ENV}
echo "SWIFT_ANDROID_SDK_DOWNLOAD=${download}" >> ${GITHUB_ENV}
echo "SWIFT_ANDROID_SDK_CHECKSUM=${checksum}" >> ${GITHUB_ENV}
- name: Install Swift Host Toolchain
run: swiftly install --use "${SWIFT_TOOLCHAIN_VERSION}"
- name: Install Swift SDK for Android
run: swiftly run swift sdk install https://download.swift.org/development/android-sdk/${SWIFT_ANDROID_SDK_VERSION}/${SWIFT_ANDROID_SDK_DOWNLOAD} --checksum ${SWIFT_ANDROID_SDK_CHECKSUM}
- name: List Swift SDKs
run: |
swiftly run swift sdk list
swiftly run swift --version
swiftly run swift --version +"${SWIFT_TOOLCHAIN_VERSION}"
- name: Setup Android NDK
run: |
# Only install the NDK if it is overridden
# Otherwise use the runner-installed NDK
if [[ ! -z "${ANDROID_NDK_VERSION}" ]]; then
mkdir ~/android-ndk
cd ~/android-ndk
curl -fsSLO https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-$(uname -s).zip
unzip -q android-ndk-${ANDROID_NDK_VERSION}-*.zip
echo "ANDROID_NDK_HOME=${PWD}/android-ndk-${ANDROID_NDK_VERSION}" >> $GITHUB_ENV
fi
# note that we must *not* have ANDROID_NDK_ROOT set!
# https://github.com/swiftlang/swift-driver/pull/1879
echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV
- name: Setup Swift SDK for Android
run: |
cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm
./swift-sdks/${SWIFT_ANDROID_SDK_VERSION}*.artifactbundle/swift-android/scripts/setup-android-sdk.sh
- name: Build Swift Executable for Android
run: |
mkdir hello
cd hello
swiftly run swift package init --type executable
swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --static-swift-stdlib
file .build/debug/hello
- name: Enable KVM
if: runner.os == 'Linux'
run: |
if [[ "${RUNNER_ARCH}" == "X64" ]]; then
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
fi
- name: ADB Wait For Device
run: adb wait-for-any-device
timeout-minutes: 5
- name: Check Android Emulator
run: |
adb shell 'echo Hello Android!'
- name: Run Swift Executable on Android Emulator
run: |
cd hello
adb push .build/debug/hello /data/local/tmp
adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so /data/local/tmp/
adb shell /data/local/tmp/hello
- name: Create run-tests script
run: |
cat > run-tests.sh << "EOF"
#!/bin/bash -ex
ORG=$(echo "${1}" | cut -d '/' -f 1)
PACKAGE=$(echo "${1}" | cut -d '/' -f 2)
git clone https://github.com/${ORG}/${PACKAGE}
cd ${PACKAGE}
swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --build-tests +"${SWIFT_TOOLCHAIN_VERSION}"
adb push .build/debug/${PACKAGE}PackageTests.xctest /data/local/tmp/
# copy up any test resources
adb push .build/debug/*.resources /data/local/tmp/ || true
# push potential dependent libraries
adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so /data/local/tmp/
# Since we are building with --static-swift-stdlib, we don't
# need to copy any of the other libraries
cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm
adb push swift-sdks/${SWIFT_ANDROID_SDK_VERSION}*.artifactbundle/swift-android/swift-resources/usr/lib/swift-${ANDROID_EMULATOR_ARCH_TRIPLE}/android/*.so /data/local/tmp/
cd -
adb shell ls /data/local/tmp/
adb shell /data/local/tmp/${PACKAGE}PackageTests.xctest
EOF
chmod +x run-tests.sh
cat run-tests.sh
- name: Run swift-collections tests
# too slow
if: false
run: ./run-tests.sh apple/swift-collections
- name: Run swift-numerics tests
run: ./run-tests.sh apple/swift-numerics
- name: Run swift-algorithms tests
run: ./run-tests.sh apple/swift-algorithms
- name: Run swift-atomics tests
run: ./run-tests.sh apple/swift-atomics
- name: Run swift-system tests
run: ./run-tests.sh apple/swift-system
- name: Run swift-crypto tests
# needs: Tests/CryptoExtrasVectors/rfc-7914-scrypt.txt
if: false
run: ./run-tests.sh apple/swift-crypto
- name: Run swift-nio tests
if: false
run: ./run-tests.sh apple/swift-nio
- name: Run swift-argument-parser tests
# needs local files:
# error: MathExampleTests.testMath_AddHelp : failed - No executable at '/data/local/tmp/math'.
if: false
run: ./run-tests.sh apple/swift-argument-parser
- name: Android - Show Emulator Log
if: always()
run: cat emulator.log || true