Repository navigation
632 lines (599 loc) · 27.5 KB
/
Copy pathci.yml
File metadata and controls
632 lines (599 loc) · 27.5 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
name: CI
on:
push:
branches: [main]
pull_request:
schedule:
# Weekly full cross-platform sweep. See the `test` matrix comment for why the
# per-PR matrix is Linux-only.
- cron: "17 4 * * 6"
workflow_dispatch:
inputs:
post_release_bump:
description: Validate an automated post-release version PR; use normal CI for any other diff
required: false
default: false
type: boolean
post_release_pr_number:
description: PR number for the branch-SHA-bound post-release checks
required: false
type: string
# A PR needs results only for its latest head. Each main push gets a unique group because it
# owns a post-merge slow-suite run that must survive later merges.
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
version_only: ${{ steps.classify.outputs.version_only }}
coverage_mode: ${{ steps.classify.outputs.coverage_mode }}
head: ${{ steps.classify.outputs.head }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Classify the complete diff using the base commit's verifier
id: classify
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
POST_RELEASE: ${{ inputs.post_release_bump }}
FULL_MATRIX: ${{ contains(github.event.pull_request.labels.*.name, 'full-matrix') }}
FULL_COVERAGE: ${{ contains(github.event.pull_request.labels.*.name, 'full-coverage') }}
PR_NUMBER: ${{ inputs.post_release_pr_number }}
run: |
version_only=false
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$POST_RELEASE" == "true" \
&& "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
# A dispatch input is a request, not proof. Bind it to an open, same-repo
# PR against main and the immutable SHA this workflow checked out.
if gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" > "$RUNNER_TEMP/bump-pr.json"; then
BASE_SHA=$(jq -r --arg sha "$GITHUB_SHA" --arg repo "$GITHUB_REPOSITORY" \
'select(.state == "open" and .head.sha == $sha and .base.ref == "main"
and .head.repo.full_name == $repo) | .base.sha' "$RUNNER_TEMP/bump-pr.json") || BASE_SHA=""
if [[ "$BASE_SHA" =~ ^[0-9a-f]{40}$ ]]; then
git fetch --no-tags origin "$BASE_SHA" || BASE_SHA=""
fi
fi
fi
if [[ "$EVENT_NAME" == "pull_request" || "$EVENT_NAME" == "push" \
|| ( "$EVENT_NAME" == "workflow_dispatch" && "$POST_RELEASE" == "true" ) ]]; then
if [[ "$BASE_SHA" =~ ^[0-9a-f]{40}$ && "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]] \
&& git show "$BASE_SHA:scripts/check-version-bump" > "$RUNNER_TEMP/check-version-bump.py"; then
version_only=$(python3 "$RUNNER_TEMP/check-version-bump.py" "$BASE_SHA" "$HEAD_SHA")
fi
fi
if [[ "$FULL_MATRIX" == "true" ]]; then
version_only=false
fi
coverage_mode=skip
if [[ "$EVENT_NAME" == "pull_request" && "$version_only" != "true" ]]; then
if [[ "$FULL_MATRIX" == "true" || "$FULL_COVERAGE" == "true" ]]; then
coverage_mode=$(python3 scripts/coverage-mode "$BASE_SHA" "$HEAD_SHA" \
--force-full)
else
coverage_mode=$(python3 scripts/coverage-mode "$BASE_SHA" "$HEAD_SHA")
fi
elif [[ "$EVENT_NAME" == "schedule" \
|| ( "$EVENT_NAME" == "workflow_dispatch" && "$POST_RELEASE" != "true" ) ]]; then
coverage_mode=full
fi
echo "version_only=$version_only" >> "$GITHUB_OUTPUT"
echo "coverage_mode=$coverage_mode" >> "$GITHUB_OUTPUT"
echo "head=$HEAD_SHA" >> "$GITHUB_OUTPUT"
echo "version-only=$version_only"
echo "coverage-mode=$coverage_mode"
version-only:
needs: changes
if: needs.changes.outputs.version_only == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
id-token: write # Codecov's explicit no-code-change status; no fabricated coverage.
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
ref: ${{ needs.changes.outputs.head }}
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.12"
- name: Validate the lockfile and build package metadata without installing CAD dependencies
run: |
uv lock --check
uv build
- name: Report the proven version-only change to Codecov
if: github.event_name != 'push'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f
with:
run_command: empty-upload
fail_ci_if_error: true
override_commit: ${{ needs.changes.outputs.head }}
override_pr: ${{ inputs.post_release_pr_number || github.event.pull_request.number }}
use_oidc: true
lint:
needs: changes
if: needs.changes.outputs.version_only != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.12"
- name: Install dependencies
run: uv sync --group dev
- name: Static preflight
run: scripts/pr-check --static
test:
# The PR is the compatibility gate. A merge to protected main has already passed these
# exact checks, so main keeps lint + the slow post-merge safety net without repeating them.
needs: changes
if: github.event_name != 'push' && needs.changes.outputs.version_only != 'true'
permissions:
contents: read
strategy:
fail-fast: false
matrix:
# 3.10-3.12 resolve build123d 0.10 (cadquery-ocp + VTK); 3.13/3.14 resolve build123d
# 0.11 (cadquery-ocp-novtk — VTK dropped, and the only kernel with 3.13/3.14 wheels).
# Linux covers every supported Python (3.14 is the coverage job below).
#
# Non-Linux runners meter far above their wall clock — macOS at 10x, Windows at 2x.
# Measured on run 31570091735, the four non-Linux jobs were 43 of 100 wall-clock
# minutes but 236 of 294 billed minutes: 80% of the cost. At the observed rate of
# roughly 234 pull-request CI runs a month that is ~55,000 billed minutes, and it
# exhausted the account's Actions allowance.
#
# So pull requests run their changed-area tier on Linux only, plus the smoke+unit
# `test-platform-canary` legs below (one macOS, one Windows — full tier was
# tried on 2026-08-19 and rolled back the same day on cost/latency). The full
# cross-platform surface runs in the weekly sweep, on `workflow_dispatch`, or
# on any PR carrying the `full-matrix` label — the one to use for a branch
# touching packaging or kernel resolution. The sweep costs ~1,265 billed
# minutes a month against the ~55,000 the trim saves.
#
# One matrix widened by expression rather than a second job: a duplicate job would
# repeat every step below and the two copies would drift.
# PR (Linux-only) jobs are additionally split in two shards via pytest-split
# (#656): each shard runs half the suite (balanced by the committed
# .test_durations), roughly halving the PR wall-clock at ~1x metering. The
# full-matrix sweep entries carry no `shard` key and run unsharded — sharding
# the 10x-metered macOS jobs would double their setup cost for no billed gain.
include: ${{ fromJSON(
(github.event_name == 'pull_request'
&& !contains(github.event.pull_request.labels.*.name, 'full-matrix'))
&& '[{"os":"ubuntu-latest","python-version":"3.10","shard":1},
{"os":"ubuntu-latest","python-version":"3.10","shard":2},
{"os":"ubuntu-latest","python-version":"3.11","shard":1},
{"os":"ubuntu-latest","python-version":"3.11","shard":2},
{"os":"ubuntu-latest","python-version":"3.12","shard":1},
{"os":"ubuntu-latest","python-version":"3.12","shard":2},
{"os":"ubuntu-latest","python-version":"3.13","shard":1},
{"os":"ubuntu-latest","python-version":"3.13","shard":2}]'
|| '[{"os":"ubuntu-latest","python-version":"3.10"},
{"os":"ubuntu-latest","python-version":"3.11"},
{"os":"ubuntu-latest","python-version":"3.12"},
{"os":"ubuntu-latest","python-version":"3.14"},
{"os":"macos-latest","python-version":"3.12"},
{"os":"macos-latest","python-version":"3.14"},
{"os":"windows-latest","python-version":"3.12"},
{"os":"windows-latest","python-version":"3.14"}]' ) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group dev
- name: Run tests
# Ordinary PRs run the changed-area manifest; full-matrix PRs, scheduled
# sweeps, and manual runs execute the complete supported-behaviour tier.
# Checkout retains history so the selector can resolve the immutable PR base.
# No --timeout here: it would override the 300 s set in
# [tool.pytest.ini_options]. The heaviest test (full specimen-sheet SVG
# export) can exceed 120 s on the slower macOS runners.
# Coverage is measured only by the Ubuntu/Python 3.14 `coverage` shards below.
# Instrumenting all fourteen compatibility jobs adds ~13% runtime without
# producing another retained or uploaded report.
# `--splits/--group` (pytest-split) apply only when the matrix entry carries a
# shard; balance comes from the committed .test_durations (regenerate with
# `--store-durations` when it drifts far from reality — stale entries only
# unbalance the halves, never drop tests).
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_TIER: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') }}
shell: bash
run: |
tier=full
if [[ "$PR_TIER" == "true" ]]; then
tier=pr
fi
uv run python scripts/test-tier "$tier" --base "$BASE_SHA" --workers auto \
--durations=25 \
${{ matrix.shard && format('--splits 2 --group {0}', matrix.shard) || '' }}
coverage:
needs: changes
if: needs.changes.outputs.coverage_mode != 'skip' && needs.changes.outputs.version_only != 'true'
# The Python 3.14 compatibility entry, which also carries coverage. Unsharded it
# was the pull request's critical path: measured on run 34078991086 it took 63
# minutes while the slowest sharded compatibility leg took 42, so every PR waited
# on this one job well after the rest of the matrix had gone green.
# Sharded the same way as the `test` matrix, it costs the same billed minutes and
# halves that wait. Source PRs measure the affected test tier and enforce changed-line
# coverage; deliberate full runs measure the complete suite and enforce the global floor.
# Reports are combined across both shards by `coverage-report`.
name: test (ubuntu-latest, 3.14, ${{ matrix.shard }})
strategy:
fail-fast: false
matrix:
shard: [1, 2]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.14"
- name: Install dependencies
run: uv sync --group dev
- name: Measure coverage for this shard
env:
# A name without the leading dot: `actions/upload-artifact` skips hidden files
# unless told otherwise, and `coverage combine` takes explicit paths anyway.
COVERAGE_FILE: coverage-data-${{ matrix.shard }}
COVERAGE_CORE: sysmon
COVERAGE_MODE: ${{ needs.changes.outputs.coverage_mode }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
EVENT_NAME: ${{ github.event_name }}
# `--cov-report=` renders nothing here and `--cov-fail-under=0` disables the
# pyproject floor for the shard: half the suite legitimately covers less than
# 90%, and the real gate runs on the combined data in `coverage-report`.
run: |
tier=full
if [[ "$COVERAGE_MODE" == "changed" ]]; then
tier=pr
fi
burden_args=()
if [[ "$EVENT_NAME" == "schedule" ]]; then
burden_args+=(--burden-report "burden-report-${{ matrix.shard }}.json")
fi
uv run scripts/test-tier "$tier" --base "$BASE_SHA" --workers auto \
--splits 2 --group ${{ matrix.shard }} \
--cov=src/draftwright \
--cov-report= \
--cov-fail-under=0 \
--durations=25 \
"${burden_args[@]}"
- name: Upload this shard's coverage data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage-data-${{ matrix.shard }}
path: coverage-data-${{ matrix.shard }}
if-no-files-found: error
retention-days: 1
- name: Upload this shard's test burden report
if: github.event_name == 'schedule'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: burden-report-${{ matrix.shard }}
path: burden-report-${{ matrix.shard }}.json
if-no-files-found: error
retention-days: 14
coverage-report:
# Combine both shards and apply the gate selected above. Full runs produce HTML and
# one Codecov upload; changed runs use diff-cover locally against the PR base.
if: needs.changes.outputs.coverage_mode != 'skip' && needs.changes.outputs.version_only != 'true'
needs: [changes, coverage]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Authenticate the single canonical Codecov upload without a secret.
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.14"
- name: Install dependencies
run: uv sync --group dev
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: coverage-data-*
merge-multiple: true
- name: Combine the shards and render the canonical reports
# `relative_files = true` (pyproject) anchors both shards' paths at the repository
# root, so the data files combine without runner-specific rewriting.
#
# `coverage-data-*` rather than naming the shards: the shard count already lives in
# the matrix and in `--splits`, and a third place to update silently combines a
# subset — which `coverage report` would then measure against `fail_under`.
#
# XML and HTML are data artefacts, not gates, so explicitly suppress the configured
# global floor there. Full mode applies that floor once through `coverage report`;
# changed mode applies its own line gate through diff-cover below.
run: |
uv run coverage combine coverage-data-*
uv run coverage xml --fail-under=0
if [[ "${{ needs.changes.outputs.coverage_mode }}" == "full" ]]; then
uv run coverage html -d htmlcov --fail-under=0
uv run coverage report --show-missing
fi
- name: Require changed production lines to remain covered
if: needs.changes.outputs.coverage_mode == 'changed'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: >-
uv run --with diff-cover==9.7.2 python scripts/diff-cover-moves coverage.xml
--compare-branch "$BASE_SHA"
--fail-under=90
- name: Upload coverage to Codecov
if: needs.changes.outputs.coverage_mode == 'full'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6
with:
files: coverage.xml
# A deliberate full run must publish its canonical external report successfully.
fail_ci_if_error: true
override_pr: ${{ inputs.post_release_pr_number || github.event.pull_request.number }}
use_oidc: true
- name: Upload coverage report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage-linux-py3.14
path: |
coverage.xml
htmlcov/
if-no-files-found: warn
retention-days: 14
test-real-part-canary:
# Bounded real STEP builds check fixed occurrence/measurement expectations and exports
# before merge (#827, #1544, #1716). Linux/Python 3.12 matches the post-merge slow-suite kernel;
# the compatibility matrix covers the other supported Python/kernel resolutions.
# Run once, outside that matrix. The test has a 120 s execution budget; this
# job limit also bounds installation and a native-kernel hang.
needs: changes
if: github.event_name == 'pull_request' && needs.changes.outputs.version_only != 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.12"
- name: Install dependencies
run: uv sync --group dev
- name: Check real-part semantics and production exports
run: >-
uv run pytest
tests/test_issue_827_real_part_canary.py
tests/test_issue_1544_frame_document_canary.py
tests/test_agent_improvement_canary_issue_1716.py
tests/test_pareto_loop_canary_issue_1753.py
-m real_part_canary -v -s --durations=3
test-slow:
# Heavy end-to-end CTC builds and the scheduled compatibility corpus run once,
# not across the full OS/Python matrix.
#
# POST-MERGE OR EXPLICIT MANUAL VALIDATION — runs on push to main or a
# workflow dispatch, never automatically on pull_request, so it does not
# normally gate PR merge (#153). Rationale: since #149 pinned the fonts,
# generated layout is deterministic, so these heavy real-part standards builds
# rarely catch anything the PR fast tier misses. They stay as a safety net on
# main; a regression here is caught right after merge.
needs: changes
if: >-
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
&& needs.changes.outputs.version_only != 'true'
strategy:
fail-fast: false
matrix:
include:
- lane: ctc04
workers: 0
selection: ctc04
timeout_seconds: 900
keyword: ""
split_args: ""
- lane: view-selection
workers: 0
selection: not ctc04
keyword: test_adr0018_view_selection
split_args: ""
- lane: remaining-1
workers: 0
selection: not ctc04
keyword: not test_adr0018_view_selection
split_args: --splits 2 --group 1
- lane: remaining-2
workers: 0
selection: not ctc04
keyword: not test_adr0018_view_selection
split_args: --splits 2 --group 2
name: test-slow (${{ matrix.lane }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: "3.12"
- name: Install dependencies
run: uv sync --group dev
- name: Run scheduled tests
# CAD-kernel builds retain enough native state for even one dense module to exhaust a
# hosted runner. Give every selected test a fresh, non-xdist process, then split the
# overall selection across two jobs.
run: >-
uv run python scripts/test-tier scheduled
--isolate-tests
--workers "${{ matrix.workers }}"
--selection "${{ matrix.selection }}"
--scheduled-timeout "${{ matrix.timeout_seconds || 600 }}"
-k "${{ matrix.keyword }}"
${{ matrix.split_args }}
test-platform-canary:
# One macOS and one Windows leg on every PR, restored at smoke+unit scope: the
# curated build-light subset plus the pure-logic tier (~1 min of tests) surfaces
# packaging and kernel-resolution breaks off-Linux before merge. The pair covers
# both kernel resolutions (3.12 -> build123d 0.10, 3.14 -> 0.11). Deliberately NOT
# the full fast tier: non-Linux meters at 10x (macOS) / 2x (Windows), and full
# per-PR legs are what exhausted the Actions allowance (see the matrix comment
# above) — the full non-Linux surface stays on the weekly sweep and the
# `full-matrix` label.
needs: changes
if: github.event_name == 'pull_request' && needs.changes.outputs.version_only != 'true'
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
python-version: "3.14"
- os: windows-latest
python-version: "3.12"
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
# The C901 ratchet compares this PR with main; unit tests run in these canaries.
fetch-depth: 0
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group dev
- name: Run smoke + unit tiers
run: uv run pytest tests/ -m "smoke or unit" -n auto --dist loadscope
ci-ok:
# The required branch-protection check. This aggregate keeps protection independent
# of matrix shape while requiring the exact jobs selected by the verified diff.
#
# `if: always()` is load-bearing, not decoration. Without it a failing dependency
# skips this job, and GitHub counts a skipped required check as satisfied — so a
# broken test suite would report a green gate.
if: always()
needs:
- changes
- version-only
- lint
- test
- coverage
- coverage-report
- test-slow
- test-platform-canary
- test-real-part-canary
runs-on: ubuntu-latest
permissions:
statuses: write # Attach the dispatched post-release gate to its generated PR head.
steps:
- name: Require every gating job to have succeeded or been legitimately skipped
env:
EVENT_NAME: ${{ github.event_name }}
POST_RELEASE: ${{ inputs.post_release_bump }}
CHANGES: ${{ needs.changes.result }}
VERSION_ONLY: ${{ needs.changes.outputs.version_only }}
COVERAGE_MODE: ${{ needs.changes.outputs.coverage_mode }}
VERSION_CHECK: ${{ needs.version-only.result }}
LINT: ${{ needs.lint.result }}
TEST: ${{ needs.test.result }}
COVERAGE: ${{ needs.coverage.result }}
COVERAGE_REPORT: ${{ needs.coverage-report.result }}
SLOW: ${{ needs.test-slow.result }}
CANARY: ${{ needs.test-platform-canary.result }}
REAL_PART: ${{ needs.test-real-part-canary.result }}
run: |
if [[ "$CHANGES" != "success" || ! "$VERSION_ONLY" =~ ^(true|false)$ \
|| ! "$COVERAGE_MODE" =~ ^(skip|changed|full)$ ]]; then
echo "::error::change classification did not produce a valid result"
exit 1
fi
if [[ "$VERSION_ONLY" == "true" ]]; then
expected_version=success
expected_lint=skipped
expected_test=skipped
expected_coverage=skipped
expected_slow=skipped
expected_canary=skipped
else
expected_version=skipped
expected_lint=success
expected_test=success
expected_coverage=skipped
expected_slow=skipped
expected_canary=skipped
if [[ "$EVENT_NAME" == "push" ]]; then
expected_test=skipped
expected_slow=success
elif [[ "$EVENT_NAME" == "pull_request" ]]; then
if [[ "$COVERAGE_MODE" != "skip" ]]; then
expected_coverage=success
fi
expected_canary=success
elif [[ "$EVENT_NAME" == "schedule" || "$EVENT_NAME" == "workflow_dispatch" ]]; then
expected_coverage=success
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
expected_slow=success
fi
fi
fi
failed=0
for pair in "version:$VERSION_CHECK:$expected_version" "lint:$LINT:$expected_lint" \
"test:$TEST:$expected_test" "coverage:$COVERAGE:$expected_coverage" \
"coverage-report:$COVERAGE_REPORT:$expected_coverage" \
"slow:$SLOW:$expected_slow" "canary:$CANARY:$expected_canary" \
"real-part:$REAL_PART:$expected_canary"; do
IFS=: read -r name result expected <<< "$pair"
if [[ "$result" != "$expected" ]]; then
echo "::error::$name: expected $expected, got $result"
failed=1
fi
done
exit $failed
- name: Attach successful post-release gate to the generated PR head
if: inputs.post_release_bump
env:
GH_TOKEN: ${{ github.token }}
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: >-
gh api --method POST
"repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}"
-f state=success
-f context=ci-ok
-f description="Post-release CI passed"
-f target_url="$TARGET_URL"