Skip to content

Commit 45bdff6

Browse files
committed
Update emulator testing
1 parent 95a19e7 commit 45bdff6

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ jobs:
104104
sdkmanager --install "${EMULATOR_SPEC}" "emulator" "platform-tools" "platforms;android-${ANDROID_API}"
105105
avdmanager create avd -n "${EMULATOR_NAME}" -k "${EMULATOR_SPEC}" --device "${ANDROID_PROFILE}"
106106
emulator -list-avds
107-
# launch the emulator in the background; we will cat the log at the end
107+
# launch the emulator in the background; we will cat the logs at the end
108108
nohup emulator -memory 4096 -avd "${EMULATOR_NAME}" -wipe-data -no-window -no-snapshot -noaudio -no-boot-anim 2>&1 > emulator.log &
109+
adb logcat 2>&1 > logcat.log &
109110
110111
- name: Install Prerequisites
111112
run: |
@@ -178,6 +179,8 @@ jobs:
178179
run: |
179180
cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm
180181
./swift-sdks/${SWIFT_ANDROID_SDK_VERSION}*.artifactbundle/swift-android/scripts/setup-android-sdk.sh
182+
cd ./swift-sdks/${SWIFT_ANDROID_SDK_VERSION}*.artifactbundle
183+
echo "SWIFT_ANDROID_SDK_HOME=${PWD}" >> $GITHUB_ENV
181184
182185
- name: Build Swift Executable for Android
183186
run: |
@@ -211,24 +214,27 @@ jobs:
211214
git clone https://github.com/${ORG}/${PACKAGE}
212215
cd ${PACKAGE}
213216
214-
swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --build-tests +"${SWIFT_TOOLCHAIN_VERSION}"
217+
TRIPLE="${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}"
218+
swiftly run swift build --swift-sdk "${TRIPLE}" --build-tests +"${SWIFT_TOOLCHAIN_VERSION}"
215219
216-
adb push .build/debug/${PACKAGE}PackageTests.xctest /data/local/tmp/
217-
# copy up any test resources
218-
adb push .build/debug/*.resources /data/local/tmp/ || true
220+
STAGING=".build/android-test-${PACKAGE}/"
221+
rm -rf "${STAGING}"
222+
mkdir "${STAGING}"
219223
220-
# push potential dependent libraries
221-
adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so /data/local/tmp/
222-
223-
# Since we are building with --static-swift-stdlib, we don't
224-
# need to copy any of the other libraries
225-
cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm
226-
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/
227-
cd -
224+
cp -a .build/"${TRIPLE}"/"${PACKAGE}"PackageTests.xctest "${STAGING}"
225+
cp -a .build/"${TRIPLE}"/*.resources "${STAGING}"
226+
# for the common case of tests referencing their own resources
227+
cp -a Tests "${STAGING}"
228+
cp -a $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so "${STAGING}"
229+
cp -a "${SWIFT_ANDROID_SDK_HOME}"/swift-android/swift-resources/usr/lib/swift-${ANDROID_EMULATOR_ARCH_TRIPLE}/android/*.so /data/local/tmp/
228230
229-
adb shell ls /data/local/tmp/
231+
cd .build/
232+
STAGING_BASE=$(basename "${STAGING}")
233+
zip -r "${STAGING_BASE}.zip" "${STAGING_BASE}"
230234
231-
adb shell /data/local/tmp/${PACKAGE}PackageTests.xctest
235+
adb push "${STAGING_BASE}.zip" /data/local/tmp/
236+
adb shell unzip -d /data/local/tmp/ /data/local/tmp/"${STAGING_BASE}.zip"
237+
adb shell /data/local/tmp/"${STAGING_BASE}"/"${PACKAGE}"PackageTests.xctest
232238
EOF
233239
234240
chmod +x run-tests.sh
@@ -252,8 +258,6 @@ jobs:
252258
run: ./run-tests.sh apple/swift-system
253259

254260
- name: Run swift-crypto tests
255-
# needs: Tests/CryptoExtrasVectors/rfc-7914-scrypt.txt
256-
if: false
257261
run: ./run-tests.sh apple/swift-crypto
258262

259263
- name: Run swift-nio tests
@@ -266,7 +270,11 @@ jobs:
266270
if: false
267271
run: ./run-tests.sh apple/swift-argument-parser
268272

269-
- name: Android - Show Emulator Log
273+
- name: Show Android Emulator Log
274+
if: always()
275+
run: cat emulator.log
276+
277+
- name: Show Android Logcat Output
270278
if: always()
271-
run: cat emulator.log || true
279+
run: cat logcat.log
272280

0 commit comments

Comments
 (0)