Repository navigation
1138 lines (1031 loc) · 49.4 KB
/
Copy pathpy--tests.yml
File metadata and controls
1138 lines (1031 loc) · 49.4 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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Run tests for all Python packages
name: Python tests
on:
push:
branches:
- "main"
- "dev"
# Run when an input to a Python, browser, or distribution-contract job changes.
paths:
- "packages/py/**"
- "packages/js/citry-client/**"
- "packages/protocol/**"
- "benchmarks/i18n.py"
- "benchmarks/native_build.py"
- "scripts/build_citry_core_pyodide_wheel.py"
- "scripts/build_constraints.py"
- "scripts/check_package_sizes.py"
- "scripts/citry_core_wheel.py"
- "scripts/release_links.py"
- "scripts/select_citry_core_qualification.py"
- "scripts/sync_protocol_python.py"
- "scripts/verify_citry_core_distribution.py"
- "scripts/verify_citry_distribution.py"
- "scripts/verify_citry_lsp_distribution.py"
- "scripts/verify_citry_ui_distribution.py"
- "scripts/verify_pygments_citry_distribution.py"
- "scripts/verify_wheel_size.py"
- "tools/pyodide-smoke/**"
- "docs_site/_internal/frontend/src/runtime_packages.js"
- "crates/**"
- "third_party/**"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- ".github/actions/install-rust/**"
- ".github/actions/citry-core-wheel/**"
- "pyproject.toml"
- "uv.lock"
- "package.json"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "README.md" # the citry wheel's metadata includes the root README
- ".github/workflows/py--tests.yml"
- ".github/workflows/py--citry-ui--publish.yml"
- ".github/workflows/py--pygments-citry--publish.yml"
- ".gitmodules"
pull_request:
# `closed` starts a run in this PR's concurrency group, which cancels the
# PR's queued or running checks once it merges or closes; every job
# skips on that event, so the cancelling run needs no runner.
types: [opened, synchronize, reopened, closed]
# Every pull request starts this workflow, and the `changes` job below
# decides which jobs run, so a required check here always reports. A
# workflow that never starts leaves a required check waiting forever.
workflow_dispatch:
# A newer run cancels an older one for the same pull request, or for the same
# branch when both come from a push. Any other run gets a group named after
# its own run ID, so no newer run cancels it.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref) || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'push' }}
# Every job except `changes` only reads the repository. Uploading artifacts and
# saving caches use a different token that the runner provides, so read access
# is enough. `changes` needs more and says why.
permissions:
contents: read
env:
# pip before 26.2.2 still trusts the eMudhra (emSign) certificate
# authorities, and the pip that setup-python provides can be older. pip checks
# the #sha256 fragment itself, so this download is safe even if an attacker
# controls the connection. pip 26.2.2 also adds the operating system's
# certificate list, which may still hold the affected emSign root, so the
# upgrade step then sets PIP_USE_DEPRECATED=legacy-certs for later steps and
# pip uses only its own list. Older pip rejects that value, so it is not set
# here.
PIP_WHEEL: "https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
jobs:
# This job checks whether a pull request changes any file that the jobs
# below test. It compares the pull request's files with the
# `on.push.paths` list above, and test_ci_workflows.py fails if the two
# lists differ. It runs only on a pull request: the push trigger already
# filters a push by that list, and a manual run tests everything.
changes:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
# Listing a pull request's files needs read access to pull requests.
permissions:
contents: read
pull-requests: read
outputs:
python: ${{ steps.match.outputs.python }}
steps:
- name: Match the changed files against the Python inputs
id: match
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
# The same paths as `on.push.paths`. A path ending in `/**` matches
# everything below that folder; any other path matches one file.
PYTHON_INPUTS: |
packages/py/**
packages/js/citry-client/**
packages/protocol/**
benchmarks/i18n.py
benchmarks/native_build.py
scripts/build_citry_core_pyodide_wheel.py
scripts/build_constraints.py
scripts/check_package_sizes.py
scripts/citry_core_wheel.py
scripts/release_links.py
scripts/select_citry_core_qualification.py
scripts/sync_protocol_python.py
scripts/verify_citry_core_distribution.py
scripts/verify_citry_distribution.py
scripts/verify_citry_lsp_distribution.py
scripts/verify_citry_ui_distribution.py
scripts/verify_pygments_citry_distribution.py
scripts/verify_wheel_size.py
tools/pyodide-smoke/**
docs_site/_internal/frontend/src/runtime_packages.js
crates/**
third_party/**
Cargo.toml
Cargo.lock
rust-toolchain.toml
.github/actions/install-rust/**
.github/actions/citry-core-wheel/**
pyproject.toml
uv.lock
package.json
pnpm-lock.yaml
pnpm-workspace.yaml
README.md
.github/workflows/py--tests.yml
.github/workflows/py--citry-ui--publish.yml
.github/workflows/py--pygments-citry--publish.yml
.gitmodules
run: |
set -euo pipefail
# gh returns raw JSON and jq reads it here, so the test in
# test_ci_workflows.py runs this exact parsing against a fake gh.
pull=$(gh api "repos/$REPOSITORY/pulls/$PR_NUMBER")
count=$(jq -r '.changed_files' <<< "$pull")
head=$(jq -r '.head.sha' <<< "$pull")
# A pull request that got a new commit after this run started runs
# everything, because the API would list the newer commit's files.
if [ "$head" != "$HEAD_SHA" ]; then
echo "The pull request has a newer commit; running every job."
echo "python=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Each page is one JSON array; `jq -s 'add'` joins them.
pages=$(gh api --paginate "repos/$REPOSITORY/pulls/$PR_NUMBER/files?per_page=100")
listed=$(jq -s 'add // [] | length' <<< "$pages")
# The API lists at most 3,000 of a pull request's files, and can
# briefly list fewer right after a push. A short list could hide a
# Python file, so it runs everything.
if [ "$listed" != "$count" ]; then
echo "The API listed $listed of $count files; running every job."
echo "python=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# A renamed file counts under its old path too, so moving a file
# out of a Python folder still runs the Python jobs.
files=$(jq -rs 'add // [] | .[] | .filename, (.previous_filename // empty)' <<< "$pages")
python=false
while IFS= read -r file; do
[ -n "$file" ] || continue
while IFS= read -r pattern; do
[ -n "$pattern" ] || continue
case "$pattern" in
*/\*\*) prefix="${pattern%\*\*}"; [[ "$file" == "$prefix"* ]] && python=true ;;
*) [[ "$file" == "$pattern" ]] && python=true ;;
esac
done <<< "$PYTHON_INPUTS"
# One match is enough to run every job.
if [ "$python" = true ]; then
break
fi
done <<< "$files"
echo "Python inputs changed: $python"
echo "python=$python" >> "$GITHUB_OUTPUT"
# Compiling the citry-core Rust extension takes about 5 minutes on Linux,
# 12 on Windows and 20 on macOS. These three jobs build its wheel once per
# OS, or restore it from the cache when no Rust input changed, and every job
# below installs that wheel rather than compiling the extension in
# `uv sync`. Each OS has its own wheel job and its own test job, so no test
# waits for a slower OS's build.
citry-core-wheel-linux:
# Skips only when `changes` reports that no Python input changed. When
# `changes` fails, or does not run (a push or a manual run), this job
# runs, so a broken `changes` cannot let a required check pass untested.
# The `closed` event still skips it.
needs: changes
if: ${{ !cancelled() && github.event.action != 'closed' && needs.changes.outputs.python != 'false' }}
runs-on: ubuntu-latest
# The Windows and macOS wheel jobs reuse these steps through the anchor.
steps: &core-wheel-steps
# Only a cache miss compiles anything, and the action fetches the Ruff
# submodule itself in that case.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
# The limited-API wheel runs on every supported CPython, so one
# interpreter builds it for all the test cells.
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.14"
- name: Restore or build the citry-core wheel
id: core
uses: ./.github/actions/citry-core-wheel
# The jobs below download the wheel from this run rather than the
# cache, so a cache eviction between jobs cannot fail them.
- name: Upload the citry-core wheel
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ steps.core.outputs.wheel-dir }}
if-no-files-found: error
retention-days: 7
citry-core-wheel-windows:
# Gated like `citry-core-wheel-linux`.
needs: changes
if: ${{ !cancelled() && github.event.action != 'closed' && needs.changes.outputs.python != 'false' }}
runs-on: windows-latest
steps: *core-wheel-steps
citry-core-wheel-macos:
# Gated like `citry-core-wheel-linux`.
needs: changes
if: ${{ !cancelled() && github.event.action != 'closed' && needs.changes.outputs.python != 'false' }}
runs-on: macos-latest
steps: *core-wheel-steps
i18n-release-qualification:
# Installs the Linux citry-core wheel built once above. It skips only when
# that build skipped. GitHub's default condition would skip it on every
# push, because `changes` is skipped there, and would also skip it when
# the build fails; a skipped check counts as passing, so a broken build
# could pass a required check. When the build failed, the download below
# fails, and so does this job.
needs: citry-core-wheel-linux
if: ${{ !cancelled() && needs.citry-core-wheel-linux.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.14"
- name: Download the citry-core wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ runner.temp }}/citry-core-wheel
# The wheel is built with the optimized `release-wheel` profile, which
# the benchmark's release-build check accepts.
- name: Install the workspace
shell: bash
run: python scripts/citry_core_wheel.py install --wheel-dir "$RUNNER_TEMP/citry-core-wheel" -- --all-packages
- name: Run server and large-catalog qualification
run: uv run --no-sync python benchmarks/i18n.py --json > i18n-qualification.json
- name: Check browser payload budgets
run: >-
uv run --no-sync pytest
packages/py/citry/tests/test_i18n_client.py::test_large_catalog_browser_payload_contains_only_the_requested_roots
packages/py/citry/tests/test_i18n_client.py::test_one_hundred_message_partition_stays_within_the_release_budget
- name: Upload i18n qualification evidence
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: i18n-release-qualification
path: i18n-qualification.json
if-no-files-found: error
# One test job per OS, each named `test`, so the cells keep their check
# names, such as `test (3.11, ubuntu-latest)`. Each needs only its own OS's
# wheel job. It skips only when that build skipped, for the reasons given
# on `i18n-release-qualification`.
test-linux:
name: test
needs: citry-core-wheel-linux
if: ${{ !cancelled() && needs.citry-core-wheel-linux.result != 'skipped' }}
runs-on: ${{ matrix.os }}
# The slowest cell takes about 30 minutes. A worker process that crashes
# can leave pytest-xdist waiting for good on Windows, so the job stops
# well before GitHub's six-hour limit.
timeout-minutes: 75
strategy:
# A failure on one interpreter must not hide portability results from
# the other supported versions.
fail-fast: false
# The three test jobs' matrices together decide which cells run. A pull
# request runs a trimmed set: Linux on every Python, Windows on the
# oldest and newest Python, and macOS on the newest. Every other event
# (a push to main or dev, or a manual run) runs the full set, so a
# failure that shows only on Windows 3.12 to 3.14 or on macOS 3.11 is
# caught right after merge. Linux 3.14 is left out of both: the Check
# workflow (repo--check.yml) runs this same suite there on every pull
# request (test_ci_workflows.py keeps this suite and the Check workflow
# in step and pins both sets).
matrix:
include: >-
${{ fromJSON(github.event_name == 'pull_request'
&& '[{"python-version":"3.11","os":"ubuntu-latest"},{"python-version":"3.12","os":"ubuntu-latest"},{"python-version":"3.13","os":"ubuntu-latest"},{"python-version":"3.15","os":"ubuntu-latest"}]'
|| '[{"python-version":"3.11","os":"ubuntu-latest"},{"python-version":"3.12","os":"ubuntu-latest"},{"python-version":"3.13","os":"ubuntu-latest"},{"python-version":"3.15","os":"ubuntu-latest"}]') }}
# The Windows and macOS test jobs reuse these steps through the anchor.
steps: &python-test-steps
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Some tests read files in the Ruff submodule.
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: ${{ matrix.python-version }}
- name: Download the citry-core wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ runner.temp }}/citry-core-wheel
# Syncs the locked workspace with every package's dev group, leaving out
# the editable citry-core, then installs the wheel built above in its
# place, so no Rust is compiled here.
- name: Install the workspace
shell: bash
run: python scripts/citry_core_wheel.py install --wheel-dir "$RUNNER_TEMP/citry-core-wheel" -- --all-packages
# The real-server reload tests start development servers, so they run
# once, in one process rather than across the four pytest workers, in
# check.py's "pytest reload servers" phase in the Check workflow.
#
# The Linux 3.11 cell renders with Citry's Python render path, the one
# PyPy, Pyodide and free-threaded builds use, because no job runs the
# suite on those interpreters. Every other cell keeps the native path.
# The option is added here rather than as a matrix key, so the cell's
# check name stays the same.
#
# The tests that render deep templates on a 128 KiB thread start an
# interpreter each, so one Linux cell runs them on CI; a local run
# always does (packages/py/citry/tests/test_native_render_depth.py).
- name: Run Python tests
env:
CITRY_NATIVE_DEPTH_PROBES: ${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13') && '1' || '' }}
run: >-
uv run --no-sync pytest
-m "not e2e"
--ignore packages/py/citry/tests/test_server_reload.py
-n 4
--dist loadfile
--durations 30
${{ (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11') && '--python-render-path' || '' }}
test-windows:
name: test
needs: citry-core-wheel-windows
if: ${{ !cancelled() && needs.citry-core-wheel-windows.result != 'skipped' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: >-
${{ fromJSON(github.event_name == 'pull_request'
&& '[{"python-version":"3.11","os":"windows-latest"},{"python-version":"3.15","os":"windows-latest"}]'
|| '[{"python-version":"3.11","os":"windows-latest"},{"python-version":"3.12","os":"windows-latest"},{"python-version":"3.13","os":"windows-latest"},{"python-version":"3.14","os":"windows-latest"},{"python-version":"3.15","os":"windows-latest"}]') }}
steps: *python-test-steps
test-macos:
name: test
needs: citry-core-wheel-macos
if: ${{ !cancelled() && needs.citry-core-wheel-macos.result != 'skipped' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: >-
${{ fromJSON(github.event_name == 'pull_request'
&& '[{"python-version":"3.15","os":"macos-latest"}]'
|| '[{"python-version":"3.11","os":"macos-latest"},{"python-version":"3.15","os":"macos-latest"}]') }}
steps: *python-test-steps
# The Compatibility page promises that Citry works with these framework
# versions, but every other job installs the versions uv.lock pins. This
# job installs the oldest supported versions and runs only the tests that
# use a web framework. It runs on pushes that start this workflow and on
# manual runs. By the maintainer's decision it skips pull requests, so a
# change that needs a newer framework shows up in the push run after the
# merge. To check a branch first, start Run workflow on it. Release step 5
# in docs/codebase.md asks the maintainer to confirm this workflow passed
# on the release commit.
framework-floors:
# Installs the Linux citry-core wheel, under the condition explained on
# `i18n-release-qualification`, and skips on pull requests.
needs: citry-core-wheel-linux
if: ${{ !cancelled() && needs.citry-core-wheel-linux.result != 'skipped' && github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 20
env:
# The oldest version of each framework the Compatibility page
# (docs_site/content/about/compatibility.md) lists, and the floors the
# starter projects in examples/starters declare. Starlette and Werkzeug
# are the oldest versions FastAPI 0.141.0 and Flask 3.1.0 accept.
# Starlette before 1.3.0 sends TestClient requests through httpx, which
# uv.lock does not install. test_ci_workflows.py checks these pins
# against the starters.
FRAMEWORK_FLOORS: >-
django==5.2.0
fastapi==0.141.0
starlette==0.46.0
flask==3.1.0
werkzeug==3.1.0
httpx==0.28.1
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
# The oldest supported Python, which every floor above supports. The
# locked dev group installs Django only on 3.12 and newer, so this is
# the only job that runs Citry's own Django tests on 3.11.
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.11"
- name: Download the citry-core wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ runner.temp }}/citry-core-wheel
# The same install as the `test` jobs, so every other dependency stays
# on its locked version and only the frameworks (plus httpx) move.
- name: Install the workspace
shell: bash
run: python scripts/citry_core_wheel.py install --wheel-dir "$RUNNER_TEMP/citry-core-wheel" -- --all-packages
# `==` makes uv install exactly these versions or fail, and it replaces
# the newer locked ones the sync just installed.
- name: Install the oldest supported framework versions
shell: bash
run: |
read -ra floors <<< "$FRAMEWORK_FLOORS"
uv pip install --python .venv "${floors[@]}"
# Most framework tests skip when their framework fails to import, so
# a floor that cannot even be imported would leave the job green. This
# step imports each one and fails if any is not on its pinned version.
- name: Check the installed framework versions
shell: bash
run: |
uv run --no-sync python - <<'EOF'
import importlib
import os
from importlib.metadata import version
from packaging.version import Version
for module in ("django", "fastapi", "starlette.testclient", "flask", "werkzeug", "httpx"):
importlib.import_module(module)
for pin in os.environ["FRAMEWORK_FLOORS"].split():
name, expected = pin.split("==")
installed = version(name)
print(f"{name} {installed}")
if Version(installed) != Version(expected):
raise SystemExit(f"{name} is {installed}, expected {expected}")
EOF
# Picks every test file that imports a framework, so a new framework
# test runs here without changing this step. The benchmark files
# compare against an exact Django release, the browser tests need
# Playwright, and the real-server reload tests run in the next step.
- name: Run the framework tests
shell: bash
run: |
set -euo pipefail
pattern='^\s*(from|import) (django|fastapi|starlette|flask|werkzeug)\b|importorskip\(\s*["'"'"'](django|fastapi|starlette|flask|werkzeug)'
mapfile -t tests < <(
grep -rlE --include='test_*.py' "$pattern" packages/py \
| grep -v -e '/e2e/' -e '/test_benchmark_' -e '/test_server_reload\.py$' \
| sort
)
if [[ ${#tests[@]} -eq 0 ]]; then
echo "No test file imports a web framework; the search pattern is out of date." >&2
exit 1
fi
printf '%s\n' "${tests[@]}"
uv run --no-sync pytest -m "not e2e" -n 4 --dist loadfile "${tests[@]}"
# The real-server reload tests start development servers, so they run
# in one process, as in check.py's "pytest reload servers" phase.
- name: Run the real-server reload tests
run: uv run --no-sync pytest packages/py/citry/tests/test_server_reload.py
# Browser end-to-end tests, including Citry UI's co-located component tests,
# run in Chromium for PR-time speed. The weekly cross-browser workflow runs
# the same paths on all three engines. The `test` job above excludes `e2e`
# explicitly and does not sync that dependency group.
e2e:
# Installs the Linux citry-core wheel, under the condition explained on
# `i18n-release-qualification`.
needs: citry-core-wheel-linux
if: ${{ !cancelled() && needs.citry-core-wheel-linux.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.14"
- name: Download the citry-core wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ runner.temp }}/citry-core-wheel
- name: Install the workspace with the e2e group
shell: bash
run: >-
python scripts/citry_core_wheel.py install --wheel-dir "$RUNNER_TEMP/citry-core-wheel"
-- --all-packages --group e2e
- name: Install the chromium browser
run: uv run --no-sync playwright install --with-deps chromium
- name: Set up pnpm for the pinned axe runtime
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: "22"
cache: "pnpm"
- name: Set up Java for the pinned Nu checker
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6
with:
distribution: "temurin"
java-version: "17"
- name: Install the root browser quality tools
run: pnpm install --frozen-lockfile --filter citry-dev-tooling
- name: Compile the pinned Tailwind coexistence fixture
run: pnpm run citry-ui:quality-css
- name: Verify checked-in Citry UI production assets
run: pnpm run citry-ui:check-assets
- name: Validate every shared Citry UI route with Nu
shell: bash
run: |
rendered_dir="$RUNNER_TEMP/citry-ui-html"
mkdir -p "$rendered_dir"
uv run --no-sync python - <<'PY' > "$rendered_dir/scenarios.txt"
from citry_ui.quality.scenarios import SCENARIOS, QualityTool
for scenario in SCENARIOS:
if QualityTool.HTML in scenario.tools:
print(scenario.id)
PY
while IFS= read -r scenario; do
rendered="$rendered_dir/${scenario//./-}.html"
uv run --no-sync python -m citry_ui.quality.routes "$scenario" --output "$rendered"
uv run --no-sync python -m citry_ui.quality.validate_html \
"$rendered" \
--scenario "$scenario" \
> "$rendered_dir/${scenario//./-}.nu.json"
done < "$rendered_dir/scenarios.txt"
- name: Run the browser e2e tests
run: >-
uv run --no-sync pytest
packages/py/citry/tests/e2e
packages/py/citry_ui/citry_ui/components
packages/py/citry_ui/citry_ui/quality/tests/e2e
packages/py/citry_ui/tests/e2e
-m "e2e and not weekly"
--browser chromium
-n 4
--dist loadfile
--durations 30
- name: Build the Citry UI qualification record
shell: bash
run: |
report_dir="$RUNNER_TEMP/citry-ui-quality"
mkdir -p "$report_dir"
cp -R "$RUNNER_TEMP/citry-ui-html" "$report_dir/html"
uv run --no-sync python -m citry_ui.quality.scenarios > "$report_dir/scenarios.json"
uv run --no-sync python -m citry_ui.quality.asset_report > "$report_dir/assets.json"
uv run --no-sync python -m citry_ui.quality.exit_record \
--inspect-browser \
--result scenario-catalog=passed \
--result chromium-accessibility=passed \
--result css-coexistence=passed \
--result nu-html=passed \
--result assets=passed \
--output "$report_dir/phase-7.5.json"
- name: Upload Citry UI qualification evidence
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: citry-ui-pr-quality
path: ${{ runner.temp }}/citry-ui-quality/
if-no-files-found: error
citry-ui-wheel-build:
# Installs the Linux citry-core wheel, under the condition explained on
# `i18n-release-qualification`.
needs: citry-core-wheel-linux
if: ${{ !cancelled() && needs.citry-core-wheel-linux.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.14"
- name: Build the Citry UI wheel and source distribution
run: uv build --package citry-ui --out-dir dist
- name: Build the matching local Citry wheel
run: uv build --package citry --wheel --out-dir dist
# The citry-core wheel built once above, with the same feature and
# profile as the published CPython wheel; only the wheel joins dist/,
# not its manifest.
- name: Download the matching local Citry Core wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-core-wheel-${{ runner.os }}
path: ${{ runner.temp }}/citry-core-wheel
- name: Add the Citry Core wheel to the distributions
shell: bash
run: |
core_wheels=("$RUNNER_TEMP"/citry-core-wheel/citry_core-[0-9]*.whl)
if [[ ${#core_wheels[@]} -ne 1 || ! -f ${core_wheels[0]} ]]; then
printf 'Expected exactly one Citry Core wheel, found: %s\n' "${core_wheels[*]}" >&2
exit 1
fi
cp "${core_wheels[0]}" dist/
# These two packages build in seconds, so the job builds them only for
# the checks below.
- name: Build the Citry LSP and Pygments distributions
run: |
uv build --package citry-lsp --out-dir dist-citry-lsp
uv build --package pygments-citry --out-dir dist-pygments-citry
# The release checks below each fail a file that is over its cap, and the
# first failure hides the sizes of every package after it. This step runs
# before them and prints the size of every built file. It warns about
# each file at 90 percent of its cap or more. It also fails if any file
# is over its cap, with one error per such file, so a pull request
# fails on a cap that needs raising before a release does. It reads the
# caps from the verifiers and only measures files, so it adds no build.
- name: Check each package file's size against its release cap
run: >-
python scripts/check_package_sizes.py
dist/citry-[0-9]*.whl
dist/citry_core-[0-9]*.whl
dist/citry_ui-[0-9]*.whl
dist/citry_ui-[0-9]*.tar.gz
dist-citry-lsp/citry_lsp-[0-9]*
dist-pygments-citry/pygments_citry-[0-9]*
# Release qualification runs this same wheel check, so a size or
# file-list problem shows up on the pull request instead of mid-release.
- name: Check the Citry wheel's size and file list against the release rules
run: python scripts/verify_citry_distribution.py --check-wheel dist/citry-[0-9]*.whl
- name: Check the Citry Core wheel against the release rules
run: python scripts/verify_citry_core_distribution.py check-wheel --wheel "dist/citry_core-[0-9]*.whl"
# This runs the release check on the LSP and Pygments wheels and
# sdists, including a wheel rebuilt from each sdist; only the install
# smoke test is left to release qualification.
- name: Check the Citry LSP and Pygments distributions against the release rules
run: |
python scripts/verify_citry_lsp_distribution.py --dist-dir dist-citry-lsp --skip-install-smoke
python scripts/verify_pygments_citry_distribution.py --dist-dir dist-pygments-citry --skip-install-smoke
- name: Check the exact wheel inventory
run: >-
python packages/py/citry_ui/citry_ui/quality/qualify_wheel.py
dist/citry_ui-*.whl
- name: Rebuild and check the wheel from the source distribution
shell: bash
run: |
# --no-config hides the root build pins, so pass them as a hashed constraints file.
python scripts/build_constraints.py export "$RUNNER_TEMP/build-constraints.txt"
uv build dist/citry_ui-*.tar.gz \
--wheel \
--out-dir dist-from-sdist \
--no-config \
--no-build-logs \
--build-constraints "$RUNNER_TEMP/build-constraints.txt" \
--require-hashes
python packages/py/citry_ui/citry_ui/quality/qualify_wheel.py \
dist-from-sdist/citry_ui-*.whl
- name: Upload the exact Citry UI wheel
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: citry-ui-wheel
path: |
dist/citry_ui-*.whl
dist/citry_ui-*.tar.gz
dist/citry-[0-9]*.whl
dist/citry_core-[0-9]*.whl
if-no-files-found: error
citry-ui-wheel-install:
needs: citry-ui-wheel-build
# GitHub's default condition skips a job when any job further up was
# skipped, and `changes` is skipped on every push and manual run, so this
# job checks only the wheel build it needs.
if: ${{ !cancelled() && needs.citry-ui-wheel-build.result == 'success' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.15"]
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-ui-wheel
path: dist
- name: Install uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
prune-cache: true
version: "0.13.5"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip to a release with the current certificate list
run: |
python -m pip install --disable-pip-version-check "$PIP_WHEEL"
echo "PIP_USE_DEPRECATED=legacy-certs" >> "$GITHUB_ENV"
- name: Prepare an offline wheelhouse
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/wheelhouse"
local_citry_wheels=(dist/citry-[0-9]*.whl)
local_citry_core_wheels=(dist/citry_core-[0-9]*.whl)
if [[ ${#local_citry_wheels[@]} -ne 1 || ! -f ${local_citry_wheels[0]} ]]; then
printf 'Expected exactly one local Citry wheel, found: %s\n' "${local_citry_wheels[*]}" >&2
exit 1
fi
if [[ ${#local_citry_core_wheels[@]} -ne 1 || ! -f ${local_citry_core_wheels[0]} ]]; then
printf 'Expected exactly one local Citry Core wheel, found: %s\n' "${local_citry_core_wheels[*]}" >&2
exit 1
fi
local_citry=${local_citry_wheels[0]}
local_citry_core=${local_citry_core_wheels[0]}
# Citry and Citry Core are released together with citry-ui, so
# resolve them from the wheels built from this commit. Naming the
# files makes pip use exactly these bytes for those two names, even
# when PyPI has the same version; other dependencies still come
# from PyPI.
python -m pip download \
--dest "$RUNNER_TEMP/wheelhouse" \
dist/citry_ui-*.whl "$local_citry" "$local_citry_core"
# The offline installs below rely on the wheelhouse holding the
# local bytes, so fail here rather than test a published build.
for wheel in "$local_citry" "$local_citry_core"; do
cmp "$wheel" "$RUNNER_TEMP/wheelhouse/$(basename "$wheel")"
done
- name: Install and exercise the wheel with pip outside the checkout
shell: bash
run: |
# This venv starts with the pip bundled in Python, which can predate the
# legacy-certs option and would reject it. Its installs are offline, so
# it never uses a certificate list.
unset PIP_USE_DEPRECATED
test_dir="$RUNNER_TEMP/citry-ui-pip-test"
python -m venv "$test_dir"
"$test_dir/bin/python" -m pip install \
--no-index \
--find-links "$RUNNER_TEMP/wheelhouse" \
dist/citry_ui-*.whl
cd "$RUNNER_TEMP"
"$test_dir/bin/python" - <<'PY'
import importlib.util
import json
import citry_ui
from citry import Citry, Component
from citry.ext.i18n import make_context
app = Citry(
mode="production",
autodiscover=False,
extensions_defaults={
"i18n": {
"source_locale": "en-US",
"locales": ("en-US",),
"catalogs": ("citry_ui_i18n",),
}
},
)
app.register_library(citry_ui)
class Page(Component):
citry = app
template = """
<c-CButton>
Installed wheel
</c-CButton>
<c-CPagination c-pages="2" c-page="1" />
"""
context = make_context(app, locale="en-US")
html = str(Page().render(provides={"citry_i18n": context}))
assert "Installed wheel" in html
assert "Pagination" in html
i18n = app.extensions.get_extension("i18n")
assert i18n.for_context(context).tr("citry-ui-pagination-label") == "Pagination"
artifact = json.loads(i18n._compiled_catalog.artifact_json())
assert artifact["stats"]["parsed_catalogs"] == 0
assert importlib.util.find_spec("citry_ui.quality") is None
assert importlib.util.find_spec("citry_ui.components.ctabs.tests") is None
PY
"$test_dir/bin/python" -m pip install \
--force-reinstall \
--no-index \
--find-links "$RUNNER_TEMP/wheelhouse" \
"$GITHUB_WORKSPACE"/dist/citry_ui-*.whl
"$test_dir/bin/python" -m pip uninstall --yes citry-ui
cd "$RUNNER_TEMP"
"$test_dir/bin/python" -c "import citry; import importlib.util; assert importlib.util.find_spec('citry_ui') is None"
- name: Add the wheel to a clean uv project offline
shell: bash
run: |
project_dir="$RUNNER_TEMP/citry-ui-uv-project"
mkdir -p "$project_dir"
cd "$project_dir"
uv init --bare --python "${{ matrix.python-version }}"
uv add \
--offline \
--find-links "$RUNNER_TEMP/wheelhouse" \
"$GITHUB_WORKSPACE"/dist/citry_ui-*.whl
uv run --offline python -c "import citry_ui; from citry import Citry; Citry(autodiscover=False).register_library(citry_ui)"
citry-ui-wheel-browser:
needs: citry-ui-wheel-build
# GitHub's default condition skips a job when any job further up was
# skipped, and `changes` is skipped on every push and manual run, so this
# job checks only the wheel build it needs.
if: ${{ !cancelled() && needs.citry-ui-wheel-build.result == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: citry-ui-wheel
path: dist
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.14"
- name: Upgrade pip to a release with the current certificate list
run: |
python -m pip install --disable-pip-version-check "$PIP_WHEEL"
echo "PIP_USE_DEPRECATED=legacy-certs" >> "$GITHUB_ENV"
- name: Prepare an offline wheelhouse with the matching local Citry
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/wheelhouse"
local_citry_wheels=(dist/citry-[0-9]*.whl)
local_citry_core_wheels=(dist/citry_core-[0-9]*.whl)
if [[ ${#local_citry_wheels[@]} -ne 1 || ! -f ${local_citry_wheels[0]} ]]; then
printf 'Expected exactly one local Citry wheel, found: %s\n' "${local_citry_wheels[*]}" >&2
exit 1
fi
if [[ ${#local_citry_core_wheels[@]} -ne 1 || ! -f ${local_citry_core_wheels[0]} ]]; then
printf 'Expected exactly one local Citry Core wheel, found: %s\n' "${local_citry_core_wheels[*]}" >&2
exit 1
fi
local_citry=${local_citry_wheels[0]}
local_citry_core=${local_citry_core_wheels[0]}
# Citry and Citry Core are released together with citry-ui, so
# resolve them from the wheels built from this commit. Naming the
# files makes pip use exactly these bytes for those two names, even
# when PyPI has the same version; other dependencies still come
# from PyPI.
python -m pip download \
--dest "$RUNNER_TEMP/wheelhouse" \
dist/citry_ui-*.whl "$local_citry" "$local_citry_core"
# The offline installs below rely on the wheelhouse holding the
# local bytes, so fail here rather than test a published build.
for wheel in "$local_citry" "$local_citry_core"; do
cmp "$wheel" "$RUNNER_TEMP/wheelhouse/$(basename "$wheel")"
done
- name: Install the exact wheel and matching local Citry
shell: bash
run: |
python -m pip install \
--no-index \
--find-links "$RUNNER_TEMP/wheelhouse" \
dist/citry_ui-*.whl
python -m pip install "playwright==1.65.0"
- name: Install Chromium
run: python -m playwright install --with-deps chromium
- name: Smoke-test the installed artifact in Chromium
shell: bash
run: |
cd "$RUNNER_TEMP"
python - <<'PY'
import citry_ui
from citry import Citry, Component
from playwright.sync_api import sync_playwright
app = Citry(autodiscover=False)
app.register_library(citry_ui)
class Page(Component):
citry = app
template = """
<!doctype html>
<html lang="en">