Skip to content

Commit 1bc00d9

Browse files
rtibblesbotclaude
andcommitted
Run Android host tests in CI and exclude them from the APK
The host tests under platforms/android/app/src/main/python/tests had no CI coverage and, living under the Chaquopy source dir, would have been bundled into the shipped APK. Add an android_platform_tests job to the Python tests workflow that runs them from the repo root against the root pytest.ini (they need Kolibri's Django test settings and kolibri/dist pythonpath), and exclude tests/** from the Chaquopy python source set so they stay out of the built app. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bc55700 commit 1bc00d9

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/tox.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,35 @@ jobs:
385385
- name: Run tests
386386
working-directory: ${{ matrix.working-directory }}
387387
run: uv run python -O -m pytest
388+
# The Android host tests exercise the WorkManager task layer against real
389+
# Kolibri core (supervisor ownership, reconciliation), so they need Kolibri's
390+
# Django test settings and the kolibri/dist pythonpath. They live under the
391+
# Chaquopy source dir but can't use the member's own pytest config, so run
392+
# them from the repo root with the root pytest.ini. Pinned to Python 3.10 to
393+
# match Chaquopy's embedded runtime (app/build.gradle python { version }).
394+
android_platform_tests:
395+
name: Platform tests (kolibri-installer-android)
396+
needs: [pre_job, stage1_required_checks]
397+
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
398+
runs-on: ubuntu-latest
399+
steps:
400+
- uses: actions/checkout@v7.0.0
401+
with:
402+
fetch-depth: 0
403+
- name: Set up uv
404+
uses: astral-sh/setup-uv@v8.2.0
405+
with:
406+
enable-cache: true
407+
cache-python: true
408+
- name: Install Python 3.10
409+
run: uv python install 3.10
410+
- name: Install dependencies
411+
# --all-packages keeps root kolibri's runtime + test deps in the shared
412+
# venv alongside the kolibri-installer-android member; the tests import
413+
# kolibri.core.tasks and run real jobs through morango storage.
414+
run: uv sync --group test --python 3.10 --all-packages
415+
- name: Run tests
416+
run: uv run python -O -m pytest platforms/android/app/src/main/python/tests -c pytest.ini --color=no
388417
# Single stable check for branch protection. Skipped matrix jobs don't
389418
# produce per-version check runs, so matrix-suffixed required checks hang
390419
# as "Expected" on PRs that skip the tests; require these jobs instead.
@@ -414,6 +443,7 @@ jobs:
414443
- sync_extras_plugin_tests
415444
- opensearch_plugin_tests
416445
- platform_tests
446+
- android_platform_tests
417447
if: always()
418448
runs-on: ubuntu-latest
419449
steps:

platforms/android/app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ android {
299299
main {
300300
python {
301301
srcDir "src/main/python"
302+
// Host-only unit tests live alongside the runtime code but run
303+
// in CI via pytest against Kolibri core; they import pytest/mock
304+
// and must not be bundled into the shipped APK.
305+
exclude "tests/**"
302306
}
303307
}
304308
}

0 commit comments

Comments
 (0)