Skip to content

Commit 63266f2

Browse files
committed
TODO/WIP/draft 👷 Runtime test the app from the CI
Leverage `reactivecircus/android-emulator-runner` to run the testapps artifact on an emulator and check the ADB logs. We're currently checking for the following pattern from the logcat output: - "I python[ ]+: Initialized python" - "I python[ ]+: Ran 14 tests in" - "I python[ ]+: OK" Note that we're keeping things simple for the first iteration and we only run the `ubuntu-latest-sdl2-artifacts` artifact. In the future we may want to test the different bootstraps, build host and even updated recipes dynamically.
1 parent 5aa9732 commit 63266f2

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

.github/workflows/docker.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
jobs:
1313
docker:
1414
runs-on: ubuntu-latest
15+
# TODO: temporarily disabled for debugging purpose
16+
if: false
1517
steps:
1618
- uses: actions/checkout@v4
1719
- uses: docker/setup-buildx-action@v3

.github/workflows/push.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
name: Pytest [Python ${{ matrix.python-version }} | ${{ matrix.os }}]
3535
needs: flake8
3636
runs-on: ${{ matrix.os }}
37+
# TODO: temporarily disabled for debugging purpose
38+
if: false
3739
strategy:
3840
matrix:
3941
python-version: ['3.8', '3.9', '3.10', '3.11']
@@ -111,6 +113,8 @@ jobs:
111113
name: Build test APP [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
112114
needs: [flake8]
113115
runs-on: ${{ matrix.runs_on }}
116+
# TODO: temporarily disabled for debugging purpose
117+
if: false
114118
continue-on-error: true
115119
strategy:
116120
matrix:
@@ -162,10 +166,72 @@ jobs:
162166
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
163167
path: dist
164168

169+
test_on_emulator:
170+
name: Run App on Emulator
171+
# TODO: keep it simple and go with ubuntu_build for a start
172+
# needs: [ubuntu_build, macos_build]
173+
needs: [ubuntu_build]
174+
runs-on: ubuntu-latest
175+
176+
steps:
177+
- name: Download Artifacts
178+
uses: actions/download-artifact@v5
179+
with:
180+
# TODO: keep it simple for now, but we may iterate over more artifact in the future
181+
name: ubuntu-latest-sdl2-artifacts
182+
path: dist/
183+
184+
- name: Setup and start Android Emulator
185+
# This is the key action to run the emulator
186+
uses: reactivecircus/android-emulator-runner@v2
187+
with:
188+
api-level: 30
189+
arch: x86_64
190+
# TODO: maybe make it a dedicated `ci/` script
191+
script: |
192+
APK_FILE=$(find dist -name "*.apk" -print -quit)
193+
194+
if [ -z "$APK_FILE" ]; then
195+
echo "Error: No APK file found in dist/"
196+
exit 1
197+
fi
198+
199+
echo "Installing $APK_FILE..."
200+
adb install "$APK_FILE"
201+
202+
APP_PACKAGE=$(aapt dump badging ${APK_FILE} | awk -F"'" '/package: name=/{print $2}' | tee /dev/tty)
203+
APP_ACTIVITY=$(aapt dump badging ${APK_FILE} | awk -F"'" '/launchable-activity/ {print $2}' | tee /dev/tty)
204+
adb shell am start -n ${APP_PACKAGE}/${APP_ACTIVITY}
205+
206+
echo "Launching $APP_PACKAGE/$APP_ACTIVITY..."
207+
adb shell am start -n "$APP_PACKAGE/$APP_ACTIVITY" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
208+
209+
# Give the app time to start, run python, and log its status
210+
sleep 15
211+
212+
# Dump the logs and search for a success string
213+
adb logcat -d -s python:I *:S > app_logs.txt
214+
215+
echo "Checking app logs..."
216+
217+
if grep --extended-regexp --quiet "I python[ ]+: Initialized python" app_logs.txt && \
218+
grep --extended-regexp --quiet "I python[ ]+: Ran 14 tests in" app_logs.txt && \
219+
grep --extended-regexp --quiet "I python[ ]+: OK" app_logs.txt; then
220+
echo "✅ SUCCESS: App launched and all unit tests passed."
221+
else
222+
echo "❌ Failure: Python runtime initialization not detected or app crashed."
223+
echo "--- Full Logs ---"
224+
cat app_logs.txt
225+
echo "-----------------"
226+
exit 1
227+
fi
228+
165229
ubuntu_rebuild_updated_recipes:
166230
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ubuntu-latest ]
167231
needs: [flake8]
168232
runs-on: ubuntu-latest
233+
# TODO: temporarily disabled for debugging purpose
234+
if: false
169235
continue-on-error: true
170236
strategy:
171237
matrix:
@@ -197,6 +263,8 @@ jobs:
197263
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ${{ matrix.runs_on }} ]
198264
needs: [flake8]
199265
runs-on: ${{ matrix.runs_on }}
266+
# TODO: temporarily disabled for debugging purpose
267+
if: false
200268
continue-on-error: true
201269
strategy:
202270
matrix:

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ testapps-generic: virtualenv
4949

5050
testapps-with-numpy: testapps-with-numpy/debug/apk testapps-with-numpy/release/aab
5151

52+
# TODO: skipping some arch temporarily to save time while debugging
5253
# testapps-with-numpy/MODE/ARTIFACT
5354
testapps-with-numpy/%: virtualenv
5455
$(eval MODE := $(word 2, $(subst /, ,$@)))
@@ -57,7 +58,7 @@ testapps-with-numpy/%: virtualenv
5758
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
5859
python setup.py $(ARTIFACT) --$(MODE) --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
5960
--requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,urllib3,chardet,idna,sqlite3,setuptools,numpy \
60-
--arch=armeabi-v7a --arch=arm64-v8a --arch=x86_64 --arch=x86 \
61+
--arch=x86_64 \
6162
--permission "(name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)" --permission "(name=android.permission.INTERNET)"
6263

6364
testapps-with-scipy: testapps-with-scipy/debug/apk testapps-with-scipy/release/aab

0 commit comments

Comments
 (0)