Skip to content

Commit 3660b5c

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 3660b5c

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
flake8:
1818
name: Flake8 tests
1919
runs-on: ubuntu-latest
20+
# TODO: temporarily disabled for debugging purpose
21+
if: false
2022
steps:
2123
- name: Checkout python-for-android
2224
uses: actions/checkout@v4
@@ -34,6 +36,8 @@ jobs:
3436
name: Pytest [Python ${{ matrix.python-version }} | ${{ matrix.os }}]
3537
needs: flake8
3638
runs-on: ${{ matrix.os }}
39+
# TODO: temporarily disabled for debugging purpose
40+
if: false
3741
strategy:
3842
matrix:
3943
python-version: ['3.8', '3.9', '3.10', '3.11']
@@ -111,6 +115,8 @@ jobs:
111115
name: Build test APP [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
112116
needs: [flake8]
113117
runs-on: ${{ matrix.runs_on }}
118+
# TODO: temporarily disabled for debugging purpose
119+
if: false
114120
continue-on-error: true
115121
strategy:
116122
matrix:
@@ -162,10 +168,71 @@ jobs:
162168
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
163169
path: dist
164170

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

0 commit comments

Comments
 (0)