-
-
Notifications
You must be signed in to change notification settings - Fork 161
2296 lines (2113 loc) · 108 KB
/
Copy pathtest.yml
File metadata and controls
2296 lines (2113 loc) · 108 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
name: Tests
on:
# Run on version tags so `release-packages.yml` can gate publish on a green
# Tests workflow for the exact commit being released. Direct pushes to main
# do NOT trigger tests — the gates that matter are PRs (pre-merge) and tags
# (pre-release).
push:
tags: ['v*']
pull_request:
branches: [main]
# `labeled` is here so the optional opt-in jobs (parity, compile-smoke,
# doc-tests) re-fire when a maintainer or the PR author applies the
# `run-extended-tests` label. Without it, applying the label on an
# existing PR wouldn't re-trigger the workflow.
types: [opened, synchronize, reopened, labeled]
paths-ignore:
- 'docs/src/**'
- '*.md'
- '!CLAUDE.md'
- '!CHANGELOG.md'
schedule:
# Nightly full-workspace cargo-test safety net (04:00 UTC). The per-PR
# cargo-test gate only exercises crates affected by the diff
# (scripts/ci_test_scope.py); a cross-crate regression that slips a scoped
# PR is caught here within a day. `schedule` is not `pull_request`, so the
# cargo-test job runs the full workspace.
- cron: '0 4 * * *'
# Manual escape hatch for the opt-in jobs. Maintainers (write access)
# can dispatch the workflow against any ref with `run_extended_tests=true`
# to run parity / compile-smoke / package smokes / doc-tests on demand
# without tagging a release.
workflow_dispatch:
inputs:
run_extended_tests:
description: 'Run extended tests (parity, compile-smoke, package smokes, doc-tests)'
type: boolean
default: false
# Superseded PR pushes cancel their in-flight run (the real minute saver); the
# nightly cron and release-tag runs never do (#5960). Keying the group on the
# event as well as the ref means a manual `workflow_dispatch` on `main` — the
# only other run that shares `refs/heads/main` with the cron, since pushes to
# main don't trigger this workflow — can't cancel a nightly mid-flight, and
# `cancel-in-progress` is off for those events regardless. The nightly is the
# only backstop for integration-suite regressions a scoped PR run can't see, so
# it must always reach a conclusion.
concurrency:
group: test-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
MACOSX_DEPLOYMENT_TARGET: "13.0"
jobs:
# ---------------------------------------------------------------------------
# Changeset gate: PRs touching crates/ must ship changelog.d/<PR>-<slug>.md
# (see changelog.d/README.md; fragments fold into GitHub Release notes at
# tag time via scripts/cut_release_notes.sh — CHANGELOG.md is frozen).
# Standalone job, NOT a step inside `lint`, so it can be its own required
# status check: lint carries unrelated red debt that gets admin-bypassed,
# and this gate must not ride along with that. The `skip-changelog` label
# skips it (the `labeled` trigger above refires the workflow, and a skipped
# required check counts as satisfied).
# ---------------------------------------------------------------------------
changeset-gate:
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-changelog')
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require a changelog.d/ fragment for crates/ changes
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --paginate > files.json
jq -r '.[].filename' files.json | grep -q '^crates/' || { echo "No crates/ changes — gate not applicable."; exit 0; }
# The fragment must be ADDED in this PR (editing a leftover file
# doesn't count) and match the root-level <digits>-<slug>.md shape
# cut_release_notes.sh folds at release time.
jq -r '.[] | select(.status == "added") | .filename' files.json | grep -qE '^changelog\.d/[0-9]+-[^/]+\.md$' && exit 0
echo "::error::This PR changes crates/ but adds no changelog.d/ fragment. Add changelog.d/<PR>-<slug>.md (see changelog.d/README.md) or apply the 'skip-changelog' label."
exit 1
# ---------------------------------------------------------------------------
# Lint: cargo fmt --check (formatting gate for every PR)
# ---------------------------------------------------------------------------
lint:
# Was macos-14 — moved to ubuntu-latest in v0.5.428 since `cargo fmt
# --check` is portable. The 6 multiplier-min cut is small in absolute
# terms (lint runs in ~30s) but it's free.
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
- name: Setup Node.js for benchmark harness tests
uses: actions/setup-node@v7
with:
# Kept in lockstep with benchmark.yml's peer-comparison Node via the
# shared .node-version pin — these harness tests exercise the same
# comparison scripts that job runs.
node-version-file: .node-version
- name: Validate benchmark artifact and fallback gates
run: |
python3 -m unittest discover -s tests -p 'test_benchmark_gate.py' -v
./tests/test_benchmark_peer_fallback.sh
./tests/test_benchmark_output_verifier.sh
bash -n benchmarks/compare.sh benchmarks/honest_bench/run.sh \
benchmarks/honest_bench/harness/run_http_bench.sh \
tests/test_benchmark_peer_fallback.sh
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
# PRs read from cache; only main writes new entries.
# Avoids cache thrash from short-lived branches.
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Audit workspace architecture
run: |
python3 scripts/workspace_architecture.py --self-test
python3 scripts/workspace_architecture.py --check --print-summary
- name: Public benchmark evidence freshness
run: |
PYTHONPATH=. python3 tests/test_public_baseline.py
# README embedded table is optional since #6736 (marketing landing
# page); this wrapper still enforces artifact freshness + RESULTS.md
# drift. Kept out of public_baseline.py to preserve harness_fingerprint.
python3 benchmarks/ci_public_baseline_check.py
# File-size gate (v0.5.1019): fails the PR if any tracked source
# file exceeds the LOC threshold (5000 initially; eventual target
# is 2000). Big single-file modules are hard to read, slow IDE +
# cargo-check incrementality, and hide regressions in code review.
# Allowlist + exclusions live in the script.
- name: File size limit
run: ./scripts/check_file_size.sh
# GC write-barrier store-site inventory: every raw heap-slot store in
# perry-codegen / perry-runtime / perry-stdlib must be barriered or
# carry a justified GC_STORE_AUDIT(...) marker (or a justified entry
# in scripts/gc_store_site_allowlist.txt). Catches new unbarriered
# old->young store paths before they become nondeterministic segfaults.
- name: GC store-site inventory
run: |
python3 scripts/gc_store_site_inventory.py --self-test
python3 scripts/gc_store_site_inventory.py
# Handle-vs-pointer address classification audit: POINTER_TAG payloads
# can be heap pointers OR small registry handles (fetch/zlib/proxy/...),
# and code must classify by magnitude through value/addr_class.rs before
# dereferencing. Catches new hand-typed band literals (0x100000 etc.)
# and new `as *const GcHeader` casts outside addr_class.rs / gc/ before
# they become Linux-only segfaults (#1843, #4004, #4665, #4800 class).
# Allowlist: scripts/addr_class_allowlist.txt.
- name: Address-classification audit
run: |
python3 scripts/addr_class_inventory.py --self-test
python3 scripts/addr_class_inventory.py
# The gap-suite ratchet decides whether conformance-smoke goes red, so
# its own logic is unit-checked on the cheap job rather than only being
# exercised 8 shards deep.
- name: Gap snapshot checker self-test
run: python3 scripts/gap_snapshot.py --self-test
# ---------------------------------------------------------------------------
# Clippy — enforces the deny-level lints in [workspace.lints] (root
# Cargo.toml). `cargo clippy` exits nonzero only on `deny` lints, so
# warn-level output is informational and never blocks a PR. The product leg
# gives fast feedback for the CLI; the host-compatible leg names every Linux
# package explicitly. Neither scope depends on Cargo default-members.
# ---------------------------------------------------------------------------
clippy:
name: Clippy (${{ matrix.scope }})
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
scope: [product, host-compatible]
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
# Same tarball'd-disk-cache pattern as api-docs-drift (see the comment
# there for why SCCACHE_GHA_ENABLED is off).
- name: Cache sccache objects
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run clippy for explicit scope
run: |
if [[ "${{ matrix.scope }}" == "product" ]]; then
cargo clippy -p perry --bins
else
mapfile -t excluded < <(python3 scripts/workspace_architecture.py \
--print-excluded-scope host-compatible)
cargo_args=(--workspace)
for package in "${excluded[@]}"; do
cargo_args+=(--exclude "$package")
done
cargo clippy "${cargo_args[@]}"
fi
# ---------------------------------------------------------------------------
# rustc warnings gate
#
# `cargo check` with `-D warnings`, so a PR cannot add a rustc warning. This
# is deliberately separate from the clippy job above: clippy's own warn-level
# lints are informational here, while rustc's are not.
#
# Both legs are needed because they compile different code. `perry` depends on
# perry-runtime with `default-features = false`, so the product leg sees a
# runtime with regex-engine, diagnostics and temporal off, where items the
# workspace leg finds live are dead. The workspace leg passes `--all-targets`
# so test and bench targets count too — without it, test-only code drifts.
#
# perry-ui-macos is in the excluded scope (this runs on ubuntu), so its
# warnings are not gated here.
# ---------------------------------------------------------------------------
rustc-warnings:
name: Warnings (${{ matrix.scope }})
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
scope: [product, host-compatible]
env:
RUSTFLAGS: -D warnings
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
- name: Cache sccache objects
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check for rustc warnings
run: |
if [[ "${{ matrix.scope }}" == "product" ]]; then
cargo check -p perry --bins
else
mapfile -t excluded < <(python3 scripts/workspace_architecture.py \
--print-excluded-scope host-compatible)
cargo_args=(--workspace --all-targets)
for package in "${excluded[@]}"; do
cargo_args+=(--exclude "$package")
done
cargo check "${cargo_args[@]}"
fi
# ---------------------------------------------------------------------------
# API docs drift gate (#465)
#
# Regenerates `docs/src/api/reference.md` and `docs/api/perry.d.ts` from
# the compile-time manifest in `crates/perry-api-manifest/src/entries.rs`,
# then `git diff --exit-code`s the result. Fails when a code change updated
# the manifest without re-committing the artifacts. Closes the "Release
# workflow regenerates docs automatically (no drift from code)" criterion
# — committing the diff is the easiest way to keep the docs in sync,
# since the diff is reviewable in the PR that introduces it.
# ---------------------------------------------------------------------------
api-docs-drift:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
RUSTC_WRAPPER: sccache
# sccache on a LOCAL DISK cache, persisted as a single tarball via
# actions/cache (see the "Cache sccache objects" step) — NOT the GitHub
# Actions cache backend (SCCACHE_GHA_ENABLED). The GHA backend stores one
# cache object per compilation unit; GitHub's cache service throttled /
# LRU-evicted the thousands of tiny entries, so a full build wrote ~3.3k
# objects (≈35 min of write time) yet the next run got ~0% Rust hits
# (measured: 3 hits / 3209 misses, 613 write errors) — i.e. every run
# recompiled the dependency graph cold. A single tarball'd disk cache
# restores in one step and gives real cross-run hit rates. Note
# SCCACHE_CACHE_SIZE is honoured by the disk backend (it was a silent
# no-op under the GHA backend, which is why the old "2G" never mattered).
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
# Persist the sccache disk cache across runs. The github.job +
# github.run_id key makes every run (including PRs) save its own fresh
# entry — distinct per job so the three sccache jobs don't collide on
# save — while the shared prefix restore-keys pull the most recent prior
# cache from ANY of them. The object cache therefore warms continuously
# and cross-pollinates instead of starting cold each run.
- name: Cache sccache objects
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Regenerate API docs
run: ./scripts/regen_api_docs.sh
- name: Check for drift
run: |
if ! git diff --quiet -- docs/src/api/reference.md docs/api/perry.d.ts; then
echo ""
echo "::error::API docs drift detected. The compile-time manifest in"
echo "::error::crates/perry-api-manifest/src/entries.rs changed but the"
echo "::error::generated artifacts under docs/ weren't regenerated."
echo ""
echo "Fix by running:"
echo " ./scripts/regen_api_docs.sh"
echo " git add docs/src/api/reference.md docs/api/perry.d.ts"
echo " git commit -m 'docs: regenerate API reference + .d.ts'"
echo ""
echo "Diff:"
git --no-pager diff --stat -- docs/src/api/reference.md docs/api/perry.d.ts
echo ""
git --no-pager diff -- docs/src/api/reference.md docs/api/perry.d.ts | head -200
exit 1
fi
echo "✅ API docs match the manifest."
# ---------------------------------------------------------------------------
# Rust unit tests (266+ tests across all crates)
# ---------------------------------------------------------------------------
# Note: a separate `build` job that produced runtime/stdlib/compiler
# artifacts USED to live here. It only fed `binary-size` (which now does
# its own quick build) — every other job did `cargo build --release`
# itself anyway, so `needs: build` was a serializing barrier with no
# cache benefit. Removed in v0.5.387 along with the `actions/cache@v4`
# blocks (replaced by `Swatinem/rust-cache@v2`, which handles target/
# pruning intelligently and avoids the disk-pressure issue that
# required the manual simulator-runtime wipe + cache=registry-only
# workaround). Each downstream job below builds in parallel directly.
cargo-test:
# Was macos-14 — moved to ubuntu-latest in v0.5.392 to drop the 10×
# billing weight. The centralized Linux test scope already filters out
# platform-specific UI crates, so
# the platform-independent test set runs identically on Linux. The
# macOS-host coverage we lose here is negligible — these tests
# don't exercise any platform behavior; they're pure logic +
# codegen.
runs-on: ubuntu-latest
# The per-package serial build+prune loop below (plus the big stdlib links)
# takes ~50-60 min with a WARM sccache disk cache. A fully cold cache
# (recompiling the whole dependency graph) measured ~90-103 min, and PRs
# that invalidate perry-runtime/perry-codegen previously exceeded the old
# 120-min bound entirely. The bound is 180 to (a) leave headroom while the
# disk cache warms after the sccache-backend fix, and (b) still cut a true
# hang (e.g. a flaky link SIGBUS retry storm). Once warm hit rates are
# confirmed in CI this can come back down. NOTE: the old "~45-50 min" figure
# predated the sccache GHA-backend rot — it was never accurate once that
# cache stopped delivering Rust hits.
timeout-minutes: 180
# sccache (compiler-level cache, shared across ALL branches/jobs via the
# GitHub Actions cache backend) on top of Swatinem/rust-cache (target/ +
# registry). rust-cache only writes on main (save-if below), so PRs can't
# warm it — and any change to the constantly-churning perry-runtime
# invalidates the whole downstream target/, whereas sccache still reuses
# the unchanged compilation units. CARGO_INCREMENTAL=0 is required: sccache
# cannot cache incremental builds. SCCACHE_CACHE_SIZE bounds the on-runner
# cache so it doesn't compound this job's known disk pressure (the prune
# loop below).
env:
RUSTC_WRAPPER: sccache
# sccache on a LOCAL DISK cache, persisted as a single tarball via
# actions/cache (see the "Cache sccache objects" step) — NOT the GitHub
# Actions cache backend (SCCACHE_GHA_ENABLED). The GHA backend stores one
# cache object per compilation unit; GitHub's cache service throttled /
# LRU-evicted the thousands of tiny entries, so a full build wrote ~3.3k
# objects (≈35 min of write time) yet the next run got ~0% Rust hits
# (measured: 3 hits / 3209 misses, 613 write errors) — i.e. every run
# recompiled the dependency graph cold. A single tarball'd disk cache
# restores in one step and gives real cross-run hit rates. Note
# SCCACHE_CACHE_SIZE is honoured by the disk backend (it was a silent
# no-op under the GHA backend, which is why the old "2G" never mattered).
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
# Persist the sccache disk cache across runs. The github.job +
# github.run_id key makes every run (including PRs) save its own fresh
# entry — distinct per job so the three sccache jobs don't collide on
# save — while the shared prefix restore-keys pull the most recent prior
# cache from ANY of them. The object cache therefore warms continuously
# and cross-pollinates instead of starting cold each run.
- name: Cache sccache objects
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
# #5892 — the auto-opt archive cache (target/perry-auto-<hash>) keys on
# perry-runtime's source hash and does NOT account for ext-crate sources,
# so a rust-cache-restored stale dir keeps linking OUTDATED ext archives
# into test-compiled binaries even after the ext sources were fixed (this
# is how the #5911 shim fix failed to clear the issue_4903 hang: the
# restored cache still carried pre-fix optimized archives). Evict it so
# every run links archives built from the checked-out tree; costs one
# ~6-9 min rebuild on the first perry compile of the run.
- name: Evict stale auto-opt archives (#5892)
run: |
rm -rf target/perry-auto-* target/debug/libperry_ext_*.a 2>/dev/null || true
- name: Run cargo test
# The exclusions below are maintained once in
# workspace-architecture.json and consumed by ci_test_scope.py:
# - perry-ui-macos / perry-ui-ios / perry-ui-tvos / perry-ui-watchos
# / perry-ui-visionos: depend on `objc2` which only compiles on
# Apple platforms (`compile_error!` in objc2/src/lib.rs:219).
# - perry-ui-gtk4: needs system pango/gtk via pkg-config; runner
# image doesn't have libgtk-4-dev installed by default.
# - perry-ui-android: needs Android NDK.
# - perry-ui-windows: needs win32 headers.
# - perry-ui-windows-winui: re-exports perry-ui-windows, so it inherits
# the same win32 / webview2-com dependency that won't build on Linux.
env:
# Rust's Ubuntu target can drive `cc` with `-fuse-ld=lld`; on the
# shared runner this has repeatedly terminated large test links with
# SIGBUS. Use the system linker for the cargo-test gate.
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C linker-features=-lld"
# Keep test artifacts small enough for the shared runner disk. The
# cargo-test job does not need line tables, and debug info was enough
# to make later package archives hit ENOSPC after several package
# test builds accumulated in target/debug.
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_PROFILE_DEV_DEBUG: "0"
# For `gh pr view` (PR changed-file list → affected-crate scope).
GH_TOKEN: ${{ github.token }}
run: |
(
while sleep 60; do
echo "cargo-test still running at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
done
) &
cargo_test_heartbeat_pid=$!
trap 'kill "$cargo_test_heartbeat_pid" 2>/dev/null || true' EXIT
# Test scope: a per-PR run only exercises the crates the diff can
# affect (changed crates + their reverse-dependency closure, plus a
# `perry` edge for runtime-linked stdlib/ext archives) instead of the
# whole workspace (~90 min). Release tags, the nightly cron, and
# workflow_dispatch run the FULL workspace as the safety net. See
# scripts/ci_test_scope.py for the rules.
if [ "${{ github.event_name }}" = "pull_request" ]; then
changed_files="$(gh pr view "${{ github.event.pull_request.number }}" \
--json files --jq '.files[].path')"
echo "Changed files in PR:"; printf '%s\n' "$changed_files"
scope="$(printf '%s\n' "$changed_files" | python3 scripts/ci_test_scope.py)"
else
scope="$(python3 scripts/ci_test_scope.py --full </dev/null)"
fi
echo "Packages in test scope:"; printf '%s\n' "$scope"
if [ -z "$scope" ]; then
echo "No crates affected by this diff — nothing to test."
exit 0
fi
# #1444: perry-runtime's tests share process-global state — the
# per-thread arena/GC, the timer queues, and the `NOTIFIED` flag are
# process singletons. Running them across the default test-harness
# thread pool lets one test's `js_notify_main_thread` / timer
# scheduling perturb another's wait budget (the event_pump timing
# flakes) and races the GC/threading tests into intermittent SIGSEGV.
# Run perry-runtime single-threaded so the tests can't interfere.
if [ "${{ github.event_name }}" != "pull_request" ]; then
# ---- FULL run: release tags / nightly cron / workflow_dispatch ----
# Every target, including the slow auto-optimize integration tests.
if printf '%s\n' "$scope" | grep -qx 'perry-runtime'; then
RUST_TEST_THREADS=1 cargo test -p perry-runtime
fi
# `cargo test` only builds lib/bin/test targets — NOT the `staticlib`
# crate-type — so libperry_runtime.a / libperry_stdlib.a are never
# produced by the steps above; they only exist if restored from the
# cache. Integration tests that compile with PERRY_NO_AUTO_OPTIMIZE=1
# (e.g. functional_batch2_regressions) link the prebuilt archive
# directly and fail with "Could not find libperry_runtime.a" if the
# cached staticlib was invalidated. Build them explicitly.
if printf '%s\n' "$scope" | grep -qE '^(perry|perry-stdlib)$'; then
cargo build -p perry-runtime -p perry-stdlib -p perry-runtime-static -p perry-stdlib-static
fi
find target/debug/deps -maxdepth 1 -type f -perm -111 ! -name '*.so' -delete
# Large perry / perry-stdlib integration-test binaries: serialize
# builds and prune linked executables between packages so the runner
# disk doesn't exhaust mid-job.
export CARGO_BUILD_JOBS=1
for package in $(printf '%s\n' "$scope" | grep -vx 'perry-runtime'); do
echo "::group::cargo test -p $package"
cargo test -p "$package"
echo "::endgroup::"
cargo clean -p "$package" || true
find target/debug/deps -maxdepth 1 -type f -perm -111 ! -name '*.so' -delete
done
else
# ---- FAST per-PR run (<10 min target) ----
# Unit / lib / bin tests for the affected crates only. The slow
# auto-optimize *integration* tests (tests/*.rs — each shells out to
# `perry compile`, ~4–6 min apiece, 163 of them in crates/perry
# alone) are NOT run wholesale per-PR; they run in the nightly full
# job, on release tags, and on demand via the `run-extended-tests`
# label. No staticlib dependency to build here (no integration
# tests).
#
# #5960: the suites the DIFF NAMES — i.e. a PR's own new/edited
# acceptance suite — do run per-PR, in the separate `e2e-scoped`
# job below. Without it a PR's acceptance test could not fail its
# own CI (#5938).
#
# Run each crate in its OWN `cargo test` invocation — NOT one
# multi-package invocation. Building several crates together unifies
# perry-runtime's cargo features, which turns on optional impls (e.g.
# `fetch`) whose extern symbols (`js_fetch_with_options`) live in a
# separate crate the other test binaries don't link → `undefined
# reference` at link. Per-package builds keep each crate's
# perry-runtime feature set isolated. CARGO_BUILD_JOBS=1 also bounds
# the heavy per-binary runtime link so the runner doesn't OOM.
# `--with-tests` drops crates whose `src/` has no unit tests (their
# lib test binary would link the runtime for zero tests).
export CARGO_BUILD_JOBS=1
# perry-runtime first, single-threaded (process-global state); it is
# a lib-only crate, so filter to --lib.
if printf '%s\n' "$scope" | grep -qx 'perry-runtime'; then
RUST_TEST_THREADS=1 cargo test --lib -p perry-runtime
fi
rest="$(printf '%s\n' "$scope" | grep -vx 'perry-runtime' \
| python3 scripts/ci_test_scope.py --with-tests || true)"
echo "Crates with unit tests in scope:"; printf '%s\n' "$rest"
for package in $rest; do
# `cargo test --lib` errors on a bin-only crate (perry), so pick
# the target filter per package: --lib --bins when it has a lib
# (lenient if it has no bins), else --bins.
if printf '%s\n' "$package" | python3 scripts/ci_test_scope.py --has-lib; then
target_filter="--lib --bins"
else
target_filter="--bins"
fi
echo "::group::cargo test $target_filter -p $package"
cargo test $target_filter -p "$package"
echo "::endgroup::"
done
fi
# ---------------------------------------------------------------------------
# Scoped e2e: run the integration suites NAMED BY THE DIFF (#5960)
#
# The per-PR `cargo-test` gate is `--lib --bins` only, so *no* `tests/*.rs`
# integration suite runs on a PR — including the PR's own. That is how #5938
# landed with its acceptance suite (`capture_rereg_renamed_class.rs`) red
# through green required checks: the suite was in the diff, was compiled into
# the scope listing, and was never executed. Running every suite per-PR is not
# an option (163 in `crates/perry` alone, each shelling out to `perry
# compile`), so this tier runs exactly the ones the diff names:
#
# changed `crates/<pkg>/tests/<suite>.rs` -> cargo test -p <pkg> --test <suite>
#
# (plus suite module dirs and `common/` helper dirs — see
# scripts/ci_e2e_scope.py, capped at 12 suites).
#
# Cost: PRs that touch no integration suite — the large majority — finish in
# ~20-30s of checkout + scope computation and never install a toolchain or
# build anything (the scope step parses Cargo.toml directly, no `cargo
# metadata`). Only a PR that adds or edits a suite pays the build, and it pays
# it in PARALLEL with `cargo-test`, which is the longer pole anyway.
#
# NOT covered: a source change that regresses an *existing* suite the diff
# doesn't name (#6037 class). There is no coverage data to map that with, and
# a crate-level map (perry-codegen -> all of perry's suites) is precisely the
# full run we're avoiding. The nightly full `cargo test` remains the backstop
# for that class — hence the concurrency carve-out above.
# ---------------------------------------------------------------------------
e2e-scoped:
# PR-only: tags / nightly / workflow_dispatch already run every suite in the
# full `cargo-test` path.
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
# MUST cover the worst case the per-suite bound allows, or the job wall
# clock kills legitimately-running suites and we get an uninformative
# "cancelled" instead of the per-suite `::error::` — reintroducing, one
# level up, exactly what `timeout 1500` below exists to prevent.
# DEFAULT_CAP (ci_e2e_scope.py) = 12 suites
# per-suite bound below = timeout 1500s = 25 min
# 12 x 25 = 300, + 30 min for toolchain/cache/staticlib build = 330
# Keep these three in sync. This is a backstop, not a budget: each suite is
# independently bounded, and the common case selects zero suites and exits
# in ~20-30s.
timeout-minutes: 330
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
# Nothing here pushes back to the repo, and the job compiles third-party
# crates (build scripts run), so don't leave a git credential on disk.
- uses: actions/checkout@v7
with:
persist-credentials: false
# Cheap gate: no toolchain, no cargo, no cache restore. Every step below
# is skipped when the diff names no suite.
- name: Compute e2e suite scope
id: scope
env:
GH_TOKEN: ${{ github.token }}
run: |
python3 scripts/ci_e2e_scope.py --self-test
changed_files="$(gh pr view "${{ github.event.pull_request.number }}" \
--json files --jq '.files[].path')"
suites="$(printf '%s\n' "$changed_files" | python3 scripts/ci_e2e_scope.py)"
if [ -z "$suites" ]; then
echo "No integration suite named by this diff — nothing to run."
echo "suites=" >> "$GITHUB_OUTPUT"
else
echo "Integration suites in scope:"
printf '%s\n' "$suites"
{
echo 'suites<<PERRY_EOF'
printf '%s\n' "$suites"
echo 'PERRY_EOF'
} >> "$GITHUB_OUTPUT"
fi
- name: Install Rust toolchain
if: steps.scope.outputs.suites != ''
uses: dtolnay/rust-toolchain@stable
- name: Install sccache
if: steps.scope.outputs.suites != ''
uses: mozilla-actions/sccache-action@v0.0.10
- name: Cache sccache objects
if: steps.scope.outputs.suites != ''
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
if: steps.scope.outputs.suites != ''
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
# Same reasoning as cargo-test: a rust-cache-restored auto-opt archive dir
# keys only on perry-runtime's source hash and would link stale ext
# archives into the binaries these suites compile (#5892).
- name: Evict stale auto-opt archives (#5892)
if: steps.scope.outputs.suites != ''
run: rm -rf target/perry-auto-* target/debug/libperry_ext_*.a 2>/dev/null || true
- name: Run scoped integration suites
if: steps.scope.outputs.suites != ''
env:
# lld has repeatedly SIGBUS'd large test links on the shared runner.
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C linker-features=-lld"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_PROFILE_DEV_DEBUG: "0"
# Bound the heavy per-binary runtime link so the runner doesn't OOM.
CARGO_BUILD_JOBS: "1"
SUITES: ${{ steps.scope.outputs.suites }}
run: |
# `cargo test` never builds the `staticlib` crate-type, so
# libperry_{runtime,stdlib}.a don't exist unless built explicitly —
# and the suites that compile with PERRY_NO_AUTO_OPTIMIZE=1 link them
# directly ("Could not find libperry_runtime.a" otherwise).
if printf '%s\n' "$SUITES" | grep -qE '^(perry|perry-stdlib) '; then
cargo build -p perry-runtime -p perry-stdlib \
-p perry-runtime-static -p perry-stdlib-static
fi
status=0
while read -r package suite; do
[ -n "$package" ] || continue
echo "::group::cargo test -p $package --test $suite"
# Per-suite wall-clock bound: a hung compile must not eat the whole
# job budget and hide the other suites' results.
if ! timeout 1500 cargo test -p "$package" --test "$suite"; then
echo "::error::integration suite failed: $package --test $suite"
status=1
fi
echo "::endgroup::"
done <<< "$SUITES"
exit "$status"
# ---------------------------------------------------------------------------
# Windows build gate
#
# Exists because Windows-only compile/link breaks previously shipped to main
# unseen — every other job runs on ubuntu/macos. Two real examples that
# landed through green required checks: an MSVC-only rustc error (E0308 on
# the `ExitProcess` extern in crates/perry-runtime/src/process/env_misc.rs)
# and an MSVC-only link error (LNK2019: `js_crypto_ed25519_verify`
# unresolved when linking perry.exe — Unix linkers dead-strip the unused
# extern, link.exe errors). Building `perry` LINKS perry.exe, so the LNK2019
# class is caught here, not just rustc errors. The perry-dev profile
# (opt-level 1, no LTO) keeps a cold Windows build inside a PR-sized budget;
# --release would be far too slow for per-PR CI.
# ---------------------------------------------------------------------------
windows-build:
runs-on: windows-latest
# Cold Windows builds are slow, and this workflow never runs on pushes to
# main, so rust-cache only saves on the nightly cron (github.ref is
# refs/heads/main for `schedule`) — PR runs after a quiet night can be
# near-cold. 75 leaves headroom over a fully cold build while still
# bounding a true hang (same reasoning as conformance-smoke's bump: a
# timeout on a required-path job is a deterministic PR blocker).
timeout-minutes: 75
steps:
- uses: actions/checkout@v7
with:
# This job compiles PR-controlled build scripts / proc macros;
# don't leave the workflow token in .git/config for them to read
# (zizmor "artipacked", flagged by review on #6610).
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
# perry-dev (see Cargo.toml [profile.perry-dev]) trades peak optimization
# for build speed. The package set covers the compiler binary (link
# gate), the runtime/stdlib pair (the usual source of cfg(windows)
# externs), and both Windows UI crates — the ones cargo-test's ubuntu
# runner must exclude and therefore never compiles.
- name: Build compiler + runtime + Windows UI crates (perry-dev)
run: cargo build --profile perry-dev -p perry -p perry-runtime -p perry-stdlib -p perry-ui-windows -p perry-ui-windows-winui
# ---------------------------------------------------------------------------
# GC write-barrier stress (optional / non-blocking)
#
# `crates/perry/tests/gc_write_barrier_stress.rs` runs compiled binaries
# under the slowest GC configuration (PERRY_GC_FORCE_EVACUATE +
# PERRY_GC_VERIFY_EVACUATION) to hunt a *rare* corruption window (#5029).
# Those tests are ~200s each and nondeterministic by nature, so they are a
# poor fit for the blocking per-PR `cargo-test` gate (one flake blocked
# every unrelated PR). They are `#[ignore]`d there and run here instead.
#
# The write-barrier stress tests stay opt-in + informational
# (`continue-on-error` on THEIR step, so a flake never fails the workflow).
#
# The job itself is no longer informational. It also runs the GC x
# representation-selection stress matrix (`scripts/gc_repsel_matrix.sh`),
# which IS a gate: until it existed, a representation could regress GC
# correctness and no CI job would say a word. Three weaknesses were fixed
# deliberately, and re-introducing any of them re-opens that hole:
# 1. job-level `continue-on-error: true` is gone (a gate that cannot fail
# is not a gate); it now sits on the legacy write-barrier step only;
# 2. the `if:` no longer requires a `run-extended-tests` label, which is
# why this job "skipped" on the representation PRs (#6911, #6925);
# 3. it no longer runs write-barrier stress *only* — nothing about the
# representation corpus was covered before.
#
# Cost split: a PR runs the 4-arm subset, whose arms all share one
# compile-time environment, so the corpus is compiled ONCE and run four
# times. push / workflow_dispatch run the full arm list (19 arms, 9 compile
# groups) as the deeper net. NOTE: this job is not yet in branch protection's
# required contexts — adding it there is what makes the gate blocking.
# ---------------------------------------------------------------------------
gc-stress:
if: >-
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Setup Node.js
uses: actions/setup-node@v7
with:
# Single source of truth: .node-version at the repo root. Node is the
# matrix oracle (we byte-diff against it), so the version is a
# correctness input. scripts/gc_repsel_matrix.sh refuses to run when
# the running node disagrees with the pin — a test the oracle cannot
# run would drop out of the gate silently.
node-version-file: .node-version
- name: Build perry + runtime staticlibs (release)
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C linker-features=-lld"
run: |
cargo build --release \
-p perry -p perry-runtime -p perry-stdlib \
-p perry-runtime-static -p perry-stdlib-static
# GATING. Fails the job on any new untriaged red cell. Cells whose GC arm
# was measurably inert are reported UNVERIFIED, never green (#6942,
# #6946, #6950) — the script asserts liveness from the collector's own
# PERRY_GC_TRACE / PERRY_GC_DIAG output rather than trusting the env var.
- name: GC x representation-selection matrix (PR subset)
if: github.event_name == 'pull_request'
run: ./scripts/gc_repsel_matrix.sh --no-build --arms pr --json gc-repsel-matrix.json
- name: GC x representation-selection matrix (full)
if: github.event_name != 'pull_request'
run: ./scripts/gc_repsel_matrix.sh --no-build --arms all --json gc-repsel-matrix.json
- name: Run GC write-barrier stress tests
# Informational: these are ~200s nondeterministic corruption-window
# hunts (#5029). Kept out of the gate so a flake never blocks a PR.
continue-on-error: true
env:
# Match the cargo-test gate's linker workaround (lld SIGBUS on the
# shared runner during large test links).
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C linker-features=-lld"
run: cargo test -p perry --test gc_write_barrier_stress -- --ignored
- name: Upload matrix report
if: always()
uses: actions/upload-artifact@v7
with:
name: gc-repsel-matrix
path: gc-repsel-matrix.json
if-no-files-found: ignore
# ---------------------------------------------------------------------------
# Compiler-output regression gate
#
# Retains HIR, pre/post-opt LLVM IR, assembly, benchmark output, runtime
# counters, vectorization remarks, benchmark timing summaries, and FP
# contraction evidence for the primary CPU benchmark plus numeric fixtures.
# Fails when hot-loop structural contracts regress.
# ---------------------------------------------------------------------------
compiler-output-regression:
runs-on: ubuntu-latest
timeout-minutes: 45
env:
RUSTC_WRAPPER: sccache
# sccache on a LOCAL DISK cache, persisted as a single tarball via
# actions/cache (see the "Cache sccache objects" step) — NOT the GitHub
# Actions cache backend (SCCACHE_GHA_ENABLED). The GHA backend stores one
# cache object per compilation unit; GitHub's cache service throttled /
# LRU-evicted the thousands of tiny entries, so a full build wrote ~3.3k
# objects (≈35 min of write time) yet the next run got ~0% Rust hits
# (measured: 3 hits / 3209 misses, 613 write errors) — i.e. every run
# recompiled the dependency graph cold. A single tarball'd disk cache
# restores in one step and gives real cross-run hit rates. Note
# SCCACHE_CACHE_SIZE is honoured by the disk backend (it was a silent
# no-op under the GHA backend, which is why the old "2G" never mattered).
SCCACHE_GHA_ENABLED: "false"
SCCACHE_DIR: ${{ github.workspace }}/.sccache
SCCACHE_CACHE_SIZE: "12G"
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
# Persist the sccache disk cache across runs. The github.job +
# github.run_id key makes every run (including PRs) save its own fresh
# entry — distinct per job so the three sccache jobs don't collide on
# save — while the shared prefix restore-keys pull the most recent prior
# cache from ANY of them. The object cache therefore warms continuously
# and cross-pollinates instead of starting cold each run.
- name: Cache sccache objects
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/.sccache
key: sccache-${{ runner.os }}-perry-${{ github.job }}-${{ github.run_id }}
restore-keys: |
sccache-${{ runner.os }}-perry-
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-perry"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install clang
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Build compiler
run: cargo build -p perry
- name: Run harness unit tests
run: python3 -m unittest tests.test_compiler_output_regression
- name: Run native ABI evidence report unit tests
run: python3 -m unittest tests.test_native_abi_evidence_report
- name: Gate native-region proof compiler output
run: |
python3 scripts/compiler_output_regression.py suite \
--suite native-region-proof \
--perry target/debug/perry \
--benchmark-mode smoke \
--runs 1 \
--perf-counters off \
--gate \
--print-summary