Repository navigation
801 lines (702 loc) · 30.5 KB
/
Copy pathpython-test.yml
File metadata and controls
801 lines (702 loc) · 30.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
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
name: Python test / linting
permissions:
contents: read
env:
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
PYTHONUTF8: 1
LLVM_VERSION: "21.1"
LLVM_RELEASE_VERSION: "21.1.8"
# Force the MWPF decoder feature on in CI so we exercise the cmake-dependent
# build path and catch regressions. GitHub-hosted runners ship cmake.
PECOS_BUILD_MWPF: "1"
CARGO_HTTP_MULTIPLEXING: "false"
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_NET_RETRY: "10"
on:
push:
tags: [ "py-*", "jl-*", "rs-*" ]
branches: [ "main", "master", "development", "dev" ]
paths:
- 'python/**'
- 'examples/**'
- 'crates/**'
- 'vendor/**'
- 'exp/zlup/**'
- 'exp/zluppy/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'pyproject.toml'
- 'uv.lock'
- 'Justfile'
- 'scripts/ci/**'
- 'scripts/win-msvc-bootstrap.ps1'
- 'scripts/check_python_workspace.py'
- '.github/uv.toml'
- '.github/workflows/python-test.yml'
pull_request:
branches: [ "main", "master", "development", "dev" ]
paths:
- 'python/**'
- 'examples/**'
- 'crates/**'
- 'vendor/**'
- 'exp/zlup/**'
- 'exp/zluppy/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'pyproject.toml'
- 'uv.lock'
- 'Justfile'
- 'scripts/ci/**'
- 'scripts/win-msvc-bootstrap.ps1'
- 'scripts/check_python_workspace.py'
- '.github/uv.toml'
- '.github/workflows/python-test.yml'
workflow_dispatch:
concurrency:
# Pull requests cancel superseded runs. Every other event (a push to a main
# branch or a dispatch) gets its own group so no trunk commit loses
# its validation or cache save to a later merge.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
python-lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Harden the runner (egress audit)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup show
- name: Install just
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache Rust
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
# Restore-only: python-core (above) saves this key on dev pushes.
save-if: false
# The rslib crates are members of the root Cargo workspace and build
# into the top-level target/, so cache the root workspace (the default)
# and share the python-core key: same crates, same profile, same env.
shared-key: python-core
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: steps.cache-llvm.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
- name: Sync Python dependencies
run: just python-ci-sync-lint
- name: Verify Rust source distributions
run: uv run --frozen --no-sync python scripts/ci/check_rust_sdists.py
- name: Run linting
run: just python-ci-lint
python-core:
# Post-merge only. Pull requests get this suite from the required PR core gate
# and the lockfile checks from python-lint.
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
# The full post-merge core suite passed at ~40m in late June and has since
# grown past 45m (timing out at ~83% of the suite on every dev push since
# 2026-07-07). 75m restores the original ~35% headroom.
timeout-minutes: 75
steps:
- name: Harden the runner (egress audit)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.12"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup show
- name: Verify cmake is available (MWPF decoder build)
run: cmake --version
- name: Install just
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache Rust
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
save-if: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
# The cache saved here is what pr-core-python (pr-core-gate.yml)
# restores on every PR. The default (root) workspace is the right one:
# the rslib crates are members of the root Cargo workspace and build
# into the top-level target/.
shared-key: python-core
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: steps.cache-llvm.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
- name: Run core Python tests
if: github.event_name != 'pull_request'
run: just python-ci-core
python-compat-smoke-build:
runs-on: ${{ matrix.os }}
# The || guard keeps a future entry that forgets job-timeout at the
# historical 20 minutes instead of GitHub's 360-minute default.
timeout-minutes: ${{ matrix.job-timeout || 20 }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.12"
artifact-name: python-compat-smoke-ubuntu
build-llvm: true
build-quantum-pecos: true
job-timeout: 20
# 30 minutes: Windows runner preparation (disk cleanup) varies by
# several minutes and the pecos-rslib wheel compile alone takes
# 10-12, so 20 minutes cancelled a healthy build (issue #360).
- os: windows-2022
python-version: "3.12"
artifact-name: python-compat-smoke-windows
build-llvm: false
build-quantum-pecos: false
job-timeout: 30
- os: macOS-latest
python-version: "3.12"
artifact-name: python-compat-smoke-macos
build-llvm: true
build-quantum-pecos: false
# Include QIS executor tests so macOS runtime failures block PRs.
job-timeout: 30
steps:
- name: Harden the runner (egress audit)
if: runner.os == 'Linux'
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Free Disk Space (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Remove-Item -Path "C:\Android" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Program Files\dotnet" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\hostedtoolcache\CodeQL" -Recurse -Force -ErrorAction SilentlyContinue
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
rustup set default-host x86_64-pc-windows-msvc
rustup toolchain install stable --profile minimal
rustup default stable
"$HOME\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:Path += ";$HOME\.cargo\bin"
rustup show
- name: Set up Rust (Unix)
if: runner.os != 'Windows'
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup default stable
rustup show
- name: Install just
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache Rust
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
# Windows and macOS: this job is the only python-core writer. Linux:
# restore-only, because python-core builds a superset (mwpf feature,
# experimental bindings) and the first save to a key is final.
save-if: ${{ runner.os != 'Linux' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
# The rslib crates are members of the root Cargo workspace and build
# into the top-level target/, so cache the root workspace (the default)
# and share the python-core key: same crates, same profile, same env.
shared-key: python-core
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: steps.cache-llvm.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
# Keep this after ci-env: its GITHUB_ENV exports take effect in this step.
# Exercise latest stable with the actual build environment (#566).
- name: Check stable Rust in the PECOS build environment
if: runner.os == 'macOS'
run: bash scripts/ci/check-rust-build-env.sh
- name: Install Python build tooling
run: uv pip install --system maturin
# Build one artifact the way an isolated PEP 517 frontend does: outside the
# checkout and without Cargo exporting the workspace's LLVM prefix. The
# installed-wheel smoke test below then exercises Guppy -> QIS -> Selene,
# catching both LLVM toolchain fallback and native-library ABI mismatches.
- name: Build pecos-rslib wheel from an isolated frontend
if: runner.os == 'Linux'
env:
RUSTUP_TOOLCHAIN: stable
run: |
mkdir -p "$GITHUB_WORKSPACE/dist/pecos-rslib"
cd "$RUNNER_TEMP"
env -u LLVM_SYS_211_PREFIX uv build --wheel \
"$GITHUB_WORKSPACE/python/pecos-rslib" \
--config-setting 'build-args=--locked --profile dev' \
--out-dir "$GITHUB_WORKSPACE/dist/pecos-rslib"
- name: Build pecos-rslib wheel
if: runner.os != 'Linux'
env:
RUSTUP_TOOLCHAIN: stable
run: |
mkdir -p dist/pecos-rslib
uv build --wheel python/pecos-rslib \
--config-setting 'build-args=--locked --profile dev' --out-dir dist/pecos-rslib
- name: Build pecos-rslib-llvm wheel
if: matrix.build-llvm
env:
RUSTUP_TOOLCHAIN: stable
run: |
mkdir -p dist/pecos-rslib-llvm
maturin build --locked --manifest-path python/pecos-rslib-llvm/Cargo.toml --out dist/pecos-rslib-llvm
- name: Test QIS executor recovery and runtime symbol binding
if: runner.os == 'macOS' || runner.os == 'Windows'
run: |
cargo +stable test --locked -p pecos-qis-ffi --lib
cargo +stable test --locked -p pecos-qis --lib executor::tests
- name: Test StabVec numerical reference contract
run: cargo +stable test --locked -p pecos-simulators --test stab_vec_correctness
- name: Test canonical stabilizer amplitudes
run: cargo +stable test --locked -p pecos-stab-tn --lib stab_mps::canonical_ket::tests
- name: Build quantum-pecos wheel
if: matrix.build-quantum-pecos
run: |
mkdir -p dist/quantum-pecos
cd python/quantum-pecos
uv build --wheel --out-dir ../../dist/quantum-pecos
- name: Upload Python compatibility smoke artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ matrix.artifact-name }}
path: |
dist/pecos-rslib/*.whl
dist/pecos-rslib-llvm/*.whl
dist/quantum-pecos/*.whl
if-no-files-found: error
python-compat-smoke:
needs: python-compat-smoke-build
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact-name: python-compat-smoke-ubuntu
python-version: "3.12"
include-llvm: true
include-pecos: true
- os: ubuntu-latest
artifact-name: python-compat-smoke-ubuntu
python-version: "3.14"
include-llvm: true
include-pecos: true
- os: windows-2022
artifact-name: python-compat-smoke-windows
python-version: "3.12"
include-llvm: false
include-pecos: false
- os: windows-2022
artifact-name: python-compat-smoke-windows
python-version: "3.14"
include-llvm: false
include-pecos: false
- os: macOS-latest
artifact-name: python-compat-smoke-macos
python-version: "3.12"
include-llvm: true
include-pecos: false
- os: macOS-latest
artifact-name: python-compat-smoke-macos
python-version: "3.14"
include-llvm: true
include-pecos: false
steps:
- name: Harden the runner (egress audit)
if: runner.os == 'Linux'
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust (Windows)
if: runner.os == 'Windows' && matrix.include-llvm
shell: pwsh
run: |
rustup set default-host x86_64-pc-windows-msvc
rustup toolchain install stable --profile minimal
rustup default stable
"$HOME\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:Path += ";$HOME\.cargo\bin"
rustup show
- name: Set up Rust (Unix)
if: runner.os != 'Windows' && matrix.include-llvm
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup show
- name: Install just
if: matrix.include-llvm
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm
if: matrix.include-llvm
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
if: matrix.include-llvm
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: matrix.include-llvm && steps.cache-llvm.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
- name: Download Python compatibility smoke artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: ${{ matrix.artifact-name }}
path: ./python-compat-smoke-artifacts
- name: Install Python compatibility smoke artifacts
run: |
uv pip install --system --force-reinstall ./python-compat-smoke-artifacts/pecos-rslib/pecos_rslib-*.whl
if [ "${{ matrix.include-llvm }}" = "true" ]; then
shopt -s nullglob
llvm_wheels=(./python-compat-smoke-artifacts/pecos-rslib-llvm/pecos_rslib_llvm-*.whl)
if [ "${#llvm_wheels[@]}" -eq 0 ]; then
echo "Expected pecos-rslib-llvm wheel for include-llvm matrix entry, but none was found."
exit 1
fi
uv pip install --system --force-reinstall "${llvm_wheels[0]}"
fi
if [ "${{ matrix.include-pecos }}" = "true" ]; then
# One resolver invocation: the freshly built quantum-pecos wheel plus
# the already-installed local native wheels (re-passed so they satisfy
# its exact pecos-rslib/-llvm pins, which do not exist on PyPI for
# unreleased versions). All other dependencies resolve from the
# wheel's own Requires-Dist -- no hand-maintained pin list that can
# drift from the package metadata.
uv pip install --system --force-reinstall \
./python-compat-smoke-artifacts/pecos-rslib/pecos_rslib-*.whl \
./python-compat-smoke-artifacts/pecos-rslib-llvm/pecos_rslib_llvm-*.whl \
./python-compat-smoke-artifacts/quantum-pecos/quantum_pecos-*.whl
uv pip check --system
fi
- name: Run Python compatibility smoke test
# Each module's __version__ is injected from its own pyproject.toml at build time, so
# this is where that wiring is checked against a real installation's metadata.
run: |
if [ "${{ matrix.include-pecos }}" = "true" ]; then
python scripts/ci/check_module_versions.py pecos pecos_rslib pecos_rslib_llvm
else
# Exercise the LLVM extension itself: package metadata cannot detect
# loading the wrong LLVM library or a broken runtime search path.
if [ "$(uname)" = "Darwin" ] && [ "${{ matrix.include-llvm }}" = "true" ]; then
python scripts/ci/check_module_versions.py pecos_rslib pecos_rslib_llvm
python -c 'from pecos_rslib_llvm import ir, binding; module = ir.Module("ci_smoke"); parsed = binding.parse_assembly(str(module)); assert parsed.as_bitcode()[:2] == b"BC"'
else
python scripts/ci/check_module_versions.py pecos_rslib
fi
fi
- name: Execute installed-wheel Guppy QIS smoke test
if: matrix.include-pecos
run: |
python_bin="$(command -v python)"
isolated_home="$RUNNER_TEMP/qis-smoke-home"
llvm_shadow="$RUNNER_TEMP/qis-smoke-path"
mkdir -p "$isolated_home" "$llvm_shadow"
printf '#!/usr/bin/env sh\nexit 86\n' > "$llvm_shadow/llvm-as"
chmod +x "$llvm_shadow/llvm-as"
cp scripts/ci/smoke_guppy_qis.py "$RUNNER_TEMP/smoke_guppy_qis.py"
cd "$RUNNER_TEMP"
env -u LLVM_SYS_211_PREFIX \
HOME="$isolated_home" \
PATH="$llvm_shadow:$PATH" \
"$python_bin" -I smoke_guppy_qis.py
- name: Execute WASM compatibility smoke test
run: python scripts/ci/smoke_wasm_foreign_object.py
# Post-merge lane excluded from the PR fast path: the slow integration tests.
python-slow-postmerge:
# All admitted non-PR events validate the slow suite. Dispatch also lets a
# branch get a signal before landing; PRs keep their fast checks.
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 90
env:
PECOS_BUILD_MWPF: "1"
steps:
- name: Harden the runner (egress audit)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup show
- name: Verify cmake is available (MWPF decoder build)
run: cmake --version
- name: Install just
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache Rust
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
# Restore-only: python-core (above) saves this key on dev pushes.
save-if: false
# The rslib crates are members of the root Cargo workspace and build
# into the top-level target/, so cache the root workspace (the default)
# and share the python-core key: same crates, same profile, same env.
shared-key: python-core
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: steps.cache-llvm.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
- name: Build core Python packages
# python-ci-build-test, not python-ci-build: its uv sync also selects
# pecos-rslib-exp, so the environment is resolved for every package the
# lane imports. pytest COLLECTION imports every module under tests/, and
# tests/qec imports pecos_rslib_exp at module level.
run: just python-ci-build-test
- name: Run slow Python tests
run: just pytest-slow
zluppy-postmerge:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 90
env:
PECOS_BUILD_MWPF: "1"
steps:
- name: Harden the runner (egress audit)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: "3.14"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: ".github/uv.toml"
enable-cache: true
save-cache: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
- name: Set up Rust
run: |
bash scripts/ci/ensure-rust.sh stable minimal
export PATH="$HOME/.cargo/bin:$PATH"
rustup show
- name: Verify cmake is available (MWPF decoder build)
run: cmake --version
- name: Install just
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: just@1.59.0
fallback: none
- name: Cache Rust
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
cache-bin: false
prefix-key: v1-rust-no-bin
save-if: ${{ github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name) }}
# zluppy is built by uv sync through PEP 517, which is a release build,
# so it cannot share the debug python-core cache. Own key; the crate is
# a root-workspace member and builds into the top-level target/, so the
# default (root) workspace is the right one.
- name: Cache LLVM ${{ env.LLVM_VERSION }}
id: cache-llvm-zluppy
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: llvm-${{ env.LLVM_RELEASE_VERSION }}-${{ runner.os }}-${{ runner.arch }}-v3
- name: Ensure LLVM ${{ env.LLVM_VERSION }}
run: just ci-env
- name: Save LLVM ${{ env.LLVM_VERSION }} cache
if: steps.cache-llvm-zluppy.outputs.cache-hit != 'true' && github.event_name == 'push' && contains(fromJSON('["main", "master", "development", "dev"]'), github.ref_name)
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.pecos/deps/llvm-21.1
key: ${{ steps.cache-llvm-zluppy.outputs.cache-primary-key }}
- name: Run zluppy Python tests
run: just pytest-zluppy
windows-vanilla-cargo:
name: Windows vanilla cargo (crates.io consumer contract)
runs-on: windows-2022
timeout-minutes: 45
steps:
- name: Harden the runner (egress audit)
if: runner.os == 'Linux'
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Rust (MSVC)
shell: pwsh
run: |
rustup set default-host x86_64-pc-windows-msvc
rustup toolchain install stable --profile minimal
rustup default stable
"$HOME\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rustup show
- name: Assert no generated .cargo/config.toml (fail closed)
shell: pwsh
run: |
if (Test-Path .cargo/config.toml) {
Write-Error "repo .cargo/config.toml exists; the crates.io contract must hold WITHOUT it"
exit 1
}
# pecos-build (where the toml_edit work lives) and pecos-core are
# publishable and need no LLVM/FFI/external toolchain -- the right
# minimal canary. LLVM-needing crates additionally require the upstream
# llvm-sys LLVM_SYS_211_PREFIX (a universal llvm-sys requirement, not a
# PECOS workaround) and are out of scope for this contract lane.
- name: Vanilla cargo check (publishable crates, no just/bootstrap)
shell: pwsh
run: |
$maxAttempts = 3
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
cargo check --locked -p pecos-build -p pecos-core
if ($LASTEXITCODE -eq 0) {
break
}
if ($attempt -eq $maxAttempts) {
throw "Vanilla cargo check failed after $maxAttempts attempts"
}
Start-Sleep -Seconds (5 * $attempt)
Write-Host "Retrying vanilla cargo check (attempt $($attempt + 1)/$maxAttempts)..."
}