-
-
Notifications
You must be signed in to change notification settings - Fork 958
478 lines (478 loc) · 18.6 KB
/
Copy pathtox.yml
File metadata and controls
478 lines (478 loc) · 18.6 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
name: Python tests
on:
push:
branches:
- develop
- 'release-v**'
pull_request:
branches:
- develop
- 'release-v**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
actions: read
env:
# Skips setuptools_scm's `git archive` file listing; see Makefile.
SETUPTOOLS_SCM_IGNORE_VCS_ROOTS: ${{ github.workspace }}
jobs:
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["**.py", ".github/workflows/tox.yml", "pyproject.toml", "uv.lock", "python_packages/**"]'
unit_test_stage1:
name: Python unit tests (Python 3.10)
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
# Don't cache, only saves 1-2s per run.
enable-cache: false
- name: Install Python 3.10
run: uv python install 3.10
- name: Install dependencies
run: uv sync --group test --python 3.10
- name: Check migrations
run: uv run kolibri manage makemigrations --check
env:
KOLIBRI_HOME: ${{ runner.temp }}/.kolibri
- name: Run tests
run: |
uv run python -O -m pytest kolibri --color=no
uv run python -O -m pytest --color=no -p no:django test
unit_test_stage2:
name: Python unit tests for uv-supported Python versions
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group test --python ${{ matrix.python-version }}
- name: Check migrations
run: uv run kolibri manage makemigrations --check
env:
KOLIBRI_HOME: ${{ runner.temp }}/.kolibri
- name: Run tests
run: |
uv run python -O -m pytest kolibri --color=no
uv run python -O -m pytest --color=no -p no:django test
unit_test_no_uv:
name: Python unit tests for Python versions without uv support
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7]
container:
image: python:${{ matrix.python-version }}-buster
env:
PYTHONPATH: /home/runner/work/kolibri/kolibri
KOLIBRI_HOME: /tmp/.kolibri
DJANGO_SETTINGS_MODULE: kolibri.deployment.default.settings.test
KOLIBRI_RUN_MODE: test
SKIP_PY_CHECK: "1"
steps:
- name: Fix apt sources for archived Buster repos
run: |
echo "deb http://archive.debian.org/debian-archive/debian/ buster main" > /etc/apt/sources.list
echo "deb http://archive.debian.org/debian-archive/debian-security/ buster/updates main" >> /etc/apt/sources.list
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99archive
apt-get -y -qq update
apt-get install -y git git-lfs
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
# The buster container runs as root but the checkout is owned by the
# runner user, so git refuses to operate without this.
- name: Fix git safe directory
run: git config --global --add safe.directory /__w/kolibri/kolibri
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install dependencies
run: |
uv pip install --system --group base --group test
uv pip install --system -r requirements/cext.txt
make set-no-uv-python-version-for-tests
- name: Check migrations
run: python -m kolibri manage makemigrations --check
- name: Run tests
run: |
# test_version.py needs setuptools-scm (not available on 3.6/3.7)
# test_cli.py::test_list_plugins* needs installed entry points (not available via PYTHONPATH)
python -O -m pytest kolibri --color=no --ignore=kolibri/utils/tests/test_version.py -k "not test_list_plugins"
python -O -m pytest --color=no -p no:django test
postgres:
name: Python postgres unit tests
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:16
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
# This database is discarded when the job ends, so crash durability buys
# nothing, while every COMMIT costs an fsync. 3.2x on the content tests.
command: >-
-c fsync=off -c synchronous_commit=off -c full_page_writes=off
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python 3.9
run: uv python install 3.9
- name: Install dependencies
run: uv sync --group test --extra postgres --python 3.9
- name: Run tests
run: |
uv run python -O -m pytest kolibri --color=no
uv run python -O -m pytest --color=no -p no:django test
env:
KOLIBRI_DATABASE_ENGINE: postgres
KOLIBRI_DATABASE_USER: postgres
KOLIBRI_DATABASE_NAME: test
KOLIBRI_DATABASE_HOST: localhost
KOLIBRI_DATABASE_PASSWORD: postgres
KOLIBRI_DATABASE_PORT: "5432"
postgres_ssl:
name: Python postgres SSL smoke tests
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.14']
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
command: >-
-c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group test --extra postgres --python ${{ matrix.python-version }}
- name: Test with SSL enabled (require mode)
run: uv run python -O -m pytest kolibri/core/public/test/test_api.py -k SyncQueueViewSetDeletedUsersTestCase --color=no
env:
KOLIBRI_DATABASE_ENGINE: postgres
KOLIBRI_DATABASE_USER: postgres
KOLIBRI_DATABASE_NAME: test
KOLIBRI_DATABASE_HOST: localhost
KOLIBRI_DATABASE_PASSWORD: postgres
KOLIBRI_DATABASE_PORT: "5432"
KOLIBRI_DATABASE_SSL_MODE: require
macos:
name: Python unit tests on Mac OS
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: macos-14
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group test --python ${{ matrix.python-version }}
- name: Run tests
run: |
uv run python -O -m pytest kolibri --color=no
uv run python -O -m pytest --color=no -p no:django test
windows:
name: Python unit tests on Windows Server
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: windows-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
# github.workspace is backslashed here but git reports forward slashes,
# and setuptools_scm compares the two as strings, so take git's own form.
- name: Set the ignored VCS root from git
shell: bash
run: echo "SETUPTOOLS_SCM_IGNORE_VCS_ROOTS=$(git rev-parse --show-toplevel)" >> "$GITHUB_ENV"
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group test --python ${{ matrix.python-version }}
- name: Run tests
run: |
uv run python -O -m pytest kolibri --color=no
uv run python -O -m pytest --color=no -p no:django test
sync_extras_plugin_tests:
name: kolibri-sync-extras-plugin tests
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python 3.10
run: uv python install 3.10
- name: Install dependencies
# --all-packages is required: a plain `uv sync` scopes to this
# subproject alone and drops root kolibri's own runtime deps
# (Django, Click, etc.) from the shared venv.
working-directory: python_packages/kolibri-sync-extras-plugin
run: uv sync --group test --python 3.10 --all-packages
- name: Enable kolibri_sync_extras_plugin
working-directory: python_packages/kolibri-sync-extras-plugin
env:
KOLIBRI_HOME: .kolibri
run: uv run kolibri plugin enable kolibri_sync_extras_plugin
- name: Run tests
working-directory: python_packages/kolibri-sync-extras-plugin
env:
KOLIBRI_HOME: .kolibri
run: uv run python -O -m pytest --reuse-db
opensearch_plugin_tests:
name: kolibri-opensearch-plugin tests
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python 3.10
run: uv python install 3.10
- name: Install dependencies
# --all-packages is required: a plain `uv sync` scopes to this
# subproject alone and drops root kolibri's own runtime deps
# (Django, Click, etc.) from the shared venv.
working-directory: python_packages/kolibri-opensearch-plugin
run: uv sync --group test --python 3.10 --all-packages
- name: Enable kolibri_opensearch_plugin
working-directory: python_packages/kolibri-opensearch-plugin
env:
KOLIBRI_HOME: .kolibri
run: uv run kolibri plugin enable kolibri_opensearch_plugin
- name: Run tests
working-directory: python_packages/kolibri-opensearch-plugin
env:
KOLIBRI_HOME: .kolibri
run: uv run python -O -m pytest --reuse-db
# Tests for platforms/ members with their own suites, each pinned to Python
# 3.10. debian-server needs the distro-info system package; android's
# websockets test dep requires >= 3.10.
platform_tests:
name: Platform tests (${{ matrix.name }})
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: debian-server
working-directory: platforms/debian-server
python-version: "3.10"
system-packages: distro-info
- name: desktop-app
working-directory: platforms/desktop-app
python-version: "3.10"
- name: android
working-directory: platforms/android
python-version: "3.10"
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install system dependencies
if: ${{ matrix.system-packages }}
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.system-packages }}
- name: Install dependencies
# --all-packages keeps root kolibri's runtime deps in the shared venv;
# see the sync_extras_plugin_tests note above.
working-directory: ${{ matrix.working-directory }}
run: uv sync --group test --python ${{ matrix.python-version }} --all-packages
- name: Run tests
working-directory: ${{ matrix.working-directory }}
run: uv run python -O -m pytest
# Android host tests: the WorkManager task layer against real Kolibri core
# (supervisor ownership, reconciliation). Needs Kolibri's Django test settings
# and the kolibri/dist pythonpath, so runs from repo root with root pytest.ini,
# not the member's config. Python 3.10 matches Chaquopy's embedded runtime.
android_platform_tests:
name: Android host tests
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
- name: Install Python 3.10
run: uv python install 3.10
- name: Install dependencies
# --all-packages keeps root kolibri's runtime + test deps in the shared
# venv alongside the kolibri-installer-android member; the tests import
# kolibri.core.tasks and run real jobs through morango storage.
run: uv sync --group test --python 3.10 --all-packages
- name: Run tests
run: uv run python -O -m pytest platforms/android/app/src/main/python/tests -c pytest.ini --color=no
# Android JVM (Robolectric) unit tests. Need a JVM/Android toolchain (JDK 21,
# Android SDK, Chaquopy buildPython 3.10), so kept separate from platform_tests.
# Runs `gradle test` with no tar staged, proving it's decoupled from the dist.
android_jvm_tests:
name: Android JVM unit tests
needs: [pre_job, stage1_required_checks]
if: ${{ needs.pre_job.outputs.should_skip != 'true' && needs.stage1_required_checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- name: Set up JDK 21
uses: actions/setup-java@v5.6.0
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
- name: Set up uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: false
# Chaquopy's buildPython (the workspace .venv) must match its embedded 3.10.
- name: Provision Chaquopy buildPython (3.10)
run: uv sync --package kolibri-installer-android --python 3.10
- name: Run JVM unit tests
working-directory: platforms/android
run: ./gradlew test
# Single stable check for branch protection. Skipped matrix jobs don't
# produce per-version check runs, so matrix-suffixed required checks hang
# as "Expected" on PRs that skip the tests; require these jobs instead.
# Stage 1: fast, blocking feedback.
stage1_required_checks:
name: Python tests (stage 1)
needs:
- pre_job
- unit_test_stage1
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if any needed job failed or was cancelled
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
# Stage 2: rest of the Python version matrix plus per-member-package tests.
# `postgres` gates here, not stage 1: it runs ~3x longer than the sqlite suite,
# so gating stage 1 on it held every stage 2 job back by its own runtime. It
# still starts off `pre_job`, so it now runs alongside stage 2 rather than
# before it.
stage2_required_checks:
name: Python tests
needs:
- stage1_required_checks
- postgres
- unit_test_stage2
- unit_test_no_uv
- postgres_ssl
- macos
- windows
- sync_extras_plugin_tests
- opensearch_plugin_tests
- platform_tests
- android_platform_tests
- android_jvm_tests
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if any needed job failed or was cancelled
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1