-
Notifications
You must be signed in to change notification settings - Fork 162
565 lines (489 loc) · 19.6 KB
/
Copy pathbase.yml
File metadata and controls
565 lines (489 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
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
on:
pull_request:
paths-ignore:
- '.github/**'
- 'docs/**'
name: Check, Build and Test
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
format:
name: compat-rustfmt
runs-on: [self-hosted]
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Install nightly toolchain
run: |
rustup toolchain install nightly --profile minimal
rustup component add rustfmt --toolchain nightly
- name: Run rustfmt
run: cargo +nightly fmt --all --check
clippy:
name: compat-clippy
strategy:
fail-fast: true
runs-on: [self-hosted]
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
LIBRA_SKIP_WEB_BUILD: "1"
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
web-check:
name: compat-web-check
runs-on: [self-hosted]
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
# The Rust crate's `build.rs` skips the web build whenever
# `LIBRA_SKIP_WEB_BUILD=1` (set on every other job for speed). This
# dedicated job re-asserts that the Next.js source still type-checks,
# lints, and produces a clean static export so `web/out/` cannot
# silently drift away from `WebAssets` in main. Per
# docs/improvement/web.md Phase 5 verification.
- name: Install web dependencies
run: pnpm --dir web install --frozen-lockfile
- name: Lint web
run: pnpm --dir web lint
- name: Test web
run: pnpm --dir web test
- name: Build web (static export → web/out/)
run: pnpm --dir web build
- name: Check web/out static export drift
shell: bash
run: |
status="$(git status --porcelain -- web/out)"
if [[ -n "$status" ]]; then
echo "web/out has untracked, staged, or unstaged files after the static export build." >&2
echo "Run 'pnpm --dir web build' locally and commit the updated web/out files." >&2
printf '%s\n' "$status" >&2
exit 1
fi
# plan-20260715 W3-15: Playwright real-browser main-chain against a
# deterministic --web-only fake-provider runtime. Soft-skip is refused via
# LIBRA_E2E_REQUIRE=1 (Checkpoint C completion evidence).
compat-web-e2e:
name: compat-web-e2e
runs-on: [self-hosted]
needs: []
env:
LIBRA_SKIP_WEB_BUILD: "1"
LIBRA_E2E_REQUIRE: "1"
LIBRA_E2E_PORT: "4410"
LIBRA_E2E_BASE_URL: "http://127.0.0.1:4410"
CARGO_TERM_COLOR: always
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
- name: Install web dependencies
run: pnpm --dir web install --frozen-lockfile
- name: Install Playwright Chromium
run: pnpm --dir web exec playwright install --with-deps chromium
- name: Build test-provider libra
run: cargo build --features test-provider
- name: Start deterministic Web runtime
shell: bash
run: |
LIBRA_E2E_BIN="${GITHUB_WORKSPACE}/target/debug/libra" \
./web/e2e/scripts/start-deterministic-runtime.sh \
>"${RUNNER_TEMP}/libra-e2e-runtime.log" 2>&1 &
echo $! >"${RUNNER_TEMP}/libra-e2e-runtime.pid"
for _ in $(seq 1 120); do
if curl -fsS "${LIBRA_E2E_BASE_URL}/api/health" 2>/dev/null | grep -qx 'ok'; then
echo "runtime ready"
exit 0
fi
if ! kill -0 "$(cat "${RUNNER_TEMP}/libra-e2e-runtime.pid")" 2>/dev/null; then
echo "runtime exited early:" >&2
cat "${RUNNER_TEMP}/libra-e2e-runtime.log" >&2 || true
exit 1
fi
sleep 1
done
echo "timed out waiting for /api/health" >&2
cat "${RUNNER_TEMP}/libra-e2e-runtime.log" >&2 || true
exit 1
- name: Run Playwright e2e
run: pnpm --dir web test:e2e
- name: Stop deterministic Web runtime
if: always()
shell: bash
run: |
if [[ -f "${RUNNER_TEMP}/libra-e2e-runtime.pid" ]]; then
kill "$(cat "${RUNNER_TEMP}/libra-e2e-runtime.pid")" 2>/dev/null || true
fi
- name: Upload Playwright artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: web-e2e-playwright
path: |
web/test-results/
web/playwright-report/
${{ runner.temp }}/libra-e2e-runtime.log
if-no-files-found: ignore
- name: Clean Playwright local artifacts
if: always()
shell: bash
run: rm -rf web/test-results web/playwright-report || true
owner-liveness-macos:
# plan-20260714 W1 (§C.9): the operation claim decides whether a control
# action's owner is dead by proving it — boot id + PID namespace on Linux,
# host UUID + boot time on macOS. The macOS branch has no other coverage,
# and a failure there does not make claims unsafe, it makes them
# unreclaimable: a killed command would hold its worktree's control slot
# until the row is cleared by hand. These five tests are the proof that the
# platform-specific reads work where they run.
name: compat-owner-liveness-macos
runs-on: macos-latest
env:
CARGO_TERM_COLOR: always
LIBRA_SKIP_WEB_BUILD: 1
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Run the claim-owner liveness tests
run: cargo test --lib -- claim_owner_tests --test-threads=1
redundancy:
name: compat-redundancy
runs-on: [self-hosted]
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Run redundancy check
run: |
if [ ! -d third-party/rust/crates ]; then
echo "✅ No third-party/rust/crates directory to check"
exit 0
fi
x=$(find third-party/rust/crates -mindepth 2 -maxdepth 2 -type d -exec bash -c '
n=$(find "$1" -maxdepth 1 -type f | wc -l)
[ $n -gt 1 ]
' _ {} \; -print -quit | wc -l)
if [ $x -gt 0 ]; then
echo "❌ Redundant directories found"
exit 1
else
echo "✅ All good"
exit 0
fi
test:
name: compat-offline-core
runs-on: [self-hosted]
# Below GitHub's 360-minute default so an overrun fails as a timeout with
# the log intact, rather than being reaped at the platform cap.
timeout-minutes: 350
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
LIBRA_SKIP_WEB_BUILD: "1"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_BUILD_JOBS: "1"
# libtest runs each test in a thread with a 2 MiB stack. An unoptimized
# async state machine — `switch::execute` and friends inline every
# awaited future into one frame — does not fit, and the test process
# ABORTS rather than failing. The real CLI runs those futures on the
# 8 MiB main thread, so this is a harness limit, not a product one.
RUST_MIN_STACK: "16777216"
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
- name: Ensure ripgrep is available
shell: bash
run: |
if command -v rg >/dev/null 2>&1; then
rg --version
exit 0
fi
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi
if command -v apt-get >/dev/null 2>&1; then
$SUDO apt-get update
$SUDO apt-get install -y ripgrep
elif command -v dnf >/dev/null 2>&1; then
$SUDO dnf install -y ripgrep
elif command -v yum >/dev/null 2>&1; then
$SUDO yum install -y ripgrep
elif command -v brew >/dev/null 2>&1; then
brew install ripgrep
else
cargo install ripgrep --locked
echo "${HOME}/.cargo/bin" >> "$GITHUB_PATH"
fi
command -v rg
rg --version
- name: Check compatibility matrix drift
run: cargo test --test compat_matrix_alignment compatibility_matrix_matches_cli_commands -- --exact
- name: Run tests (L1 + L2 + L3)
env:
LIBRA_TEST_GITHUB_TOKEN: ${{ secrets.LIBRA_TEST_GITHUB_TOKEN }}
LIBRA_TEST_GITHUB_NAMESPACE: ${{ secrets.LIBRA_TEST_GITHUB_NAMESPACE }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
LIBRA_D1_ACCOUNT_ID: ${{ secrets.LIBRA_D1_ACCOUNT_ID }}
LIBRA_D1_API_TOKEN: ${{ secrets.LIBRA_D1_API_TOKEN }}
LIBRA_D1_DATABASE_ID: ${{ secrets.LIBRA_D1_DATABASE_ID }}
LIBRA_STORAGE_ENDPOINT: ${{ secrets.LIBRA_STORAGE_ENDPOINT }}
LIBRA_STORAGE_BUCKET: ${{ secrets.LIBRA_STORAGE_BUCKET }}
LIBRA_STORAGE_ACCESS_KEY: ${{ secrets.LIBRA_STORAGE_ACCESS_KEY }}
LIBRA_STORAGE_SECRET_KEY: ${{ secrets.LIBRA_STORAGE_SECRET_KEY }}
run: |
set -euo pipefail
# `cargo test --all` minus the `command_test` binary, which
# `compat-offline-command` shards instead. That one target compiles
# 150 modules (~2950 tests) into a SINGLE process, and roughly a
# third of them serialize on the process-global cwd lock that every
# `ChangeDirGuard` takes — so it runs at about one core regardless of
# the machine. It went past the 360-minute cap the first time the lib
# suite stopped failing early and cargo actually reached it.
#
# Coverage is unchanged: lib, bins and doctests run here, so does
# every other integration target, and `command_test` runs there.
#
# Targets whose `required-features` are not enabled are dropped, not
# named: `cargo test --all` SKIPS those silently, but naming one with
# `--test` is a hard error. The later steps in this job run each of
# them explicitly with the feature it needs.
mapfile -t TARGETS < <(
cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[]
| (.features.default // []) as $default
| .targets[]
| select(.kind[] == "test")
| select(.name != "command_test")
| select(((((."required-features") // []) - $default) | length) == 0)
| .name' \
| sort -u
)
if [ "${#TARGETS[@]}" -lt 100 ]; then
echo "::error::enumerated only ${#TARGETS[@]} integration targets; refusing to run a truncated suite"
exit 1
fi
echo "running lib + bins + doctests + ${#TARGETS[@]} integration targets"
ARGS=()
for target in "${TARGETS[@]}"; do
ARGS+=(--test "$target")
done
cargo test --lib --bins "${ARGS[@]}"
cargo test --doc
# Phase 6 — Local TUI Automation Control scenario suite (docs/improvement/agent.md Part C).
# Without `--features test-provider` + `LIBRA_ENABLE_TEST_PROVIDER=1`, the scenarios
# in tests/code_ui_scenarios.rs and tests/harness_self_test.rs short-circuit; CI
# would silently skip them. `--test-threads=1` because each scenario spawns a
# `libra code` subprocess that contends for 0600 control-token files and ports.
#
# docs/improvement/test.md Wave 1 + Wave 3 also require the SSE harness and
# lease matrix to run under the same gate, otherwise CI silently skips every
# `lease_case!()` / `sse_case!()` registration.
- name: Run TUI automation scenarios
env:
LIBRA_ENABLE_TEST_PROVIDER: "1"
# These scenarios validate the loopback browser against the real
# embedded Next.js app, so the build.rs fallback stub is not valid here.
LIBRA_SKIP_WEB_BUILD: "0"
run: |
cargo test --features test-provider \
--test code_ui_scenarios \
--test harness_self_test \
--test code_codex_default_tui_test \
--test code_ui_remote_lease_matrix \
--test code_ui_remote_sse_matrix \
-- --test-threads=1
# lore.md 1.7: the OTLP wire test needs the feature compiled in
# (required-features excludes it from the default `cargo test --all`).
- name: Run OTLP telemetry wire test (--features otlp)
env:
LIBRA_SKIP_WEB_BUILD: "1"
run: |
cargo test --features otlp --test otlp_telemetry -- --test-threads=1
# lore.md 2.7: keyring-backend plumbing over the in-process mock store
# (debug builds only honor the mock env; headless-safe).
- name: Run keyring auth backend test (--features keyring)
env:
LIBRA_SKIP_WEB_BUILD: "1"
run: |
cargo test --features keyring --test auth_keyring_backend -- --test-threads=1
# plan-20260714 §A.11: auto-upgrade integration targets. Trust-root and
# endpoint injection is compile-time only (the `test-upgrade` feature),
# so a release build cannot alter the trust root even with LIBRA_TEST=1.
- name: Run auto-upgrade tests (--features test-upgrade)
env:
LIBRA_SKIP_WEB_BUILD: "1"
LIBRA_TEST: "1"
run: |
cargo test --features test-upgrade \
--test upgrade_auto_test \
--test upgrade_publish_contract_test -- --test-threads=1
- name: Upload TUI scenario artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: code-ui-scenarios
path: target/code-ui-scenarios/**
if-no-files-found: ignore
retention-days: 7
# The `command_test` half of what `cargo test --all` used to do in one job.
# See the note on compat-offline-core's test step for why it is split out:
# the binary is lock-bound rather than CPU-bound, so the only thing that
# shortens it is running it in more than one PROCESS. Shards are separate
# jobs, so each gets its own cwd lock and they scale with the runner pool.
command-tests:
name: compat-offline-command
runs-on: [self-hosted]
timeout-minutes: 350
strategy:
# One shard failing must not cancel the others: the point of the split is
# to see the whole binary's result in one run.
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
LIBRA_SKIP_WEB_BUILD: "1"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_BUILD_JOBS: "1"
# See compat-offline-core: 2 MiB test threads cannot hold an
# unoptimized async state machine, and the process aborts if one
# overflows. `command::switch_test` needs a little over 2 MiB.
RUST_MIN_STACK: "16777216"
# Kept in one place so the matrix above and the partition below cannot
# disagree — a mismatch would silently drop or double-run tests.
SHARD_COUNT: "4"
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
- name: Run command_test shard ${{ matrix.shard }}
env:
LIBRA_TEST_GITHUB_TOKEN: ${{ secrets.LIBRA_TEST_GITHUB_TOKEN }}
LIBRA_TEST_GITHUB_NAMESPACE: ${{ secrets.LIBRA_TEST_GITHUB_NAMESPACE }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
LIBRA_D1_ACCOUNT_ID: ${{ secrets.LIBRA_D1_ACCOUNT_ID }}
LIBRA_D1_API_TOKEN: ${{ secrets.LIBRA_D1_API_TOKEN }}
LIBRA_D1_DATABASE_ID: ${{ secrets.LIBRA_D1_DATABASE_ID }}
LIBRA_STORAGE_ENDPOINT: ${{ secrets.LIBRA_STORAGE_ENDPOINT }}
LIBRA_STORAGE_BUCKET: ${{ secrets.LIBRA_STORAGE_BUCKET }}
LIBRA_STORAGE_ACCESS_KEY: ${{ secrets.LIBRA_STORAGE_ACCESS_KEY }}
LIBRA_STORAGE_SECRET_KEY: ${{ secrets.LIBRA_STORAGE_SECRET_KEY }}
run: |
set -euo pipefail
# Partition by ENUMERATED TEST NAME, not by module prefix. The modulo
# split is exhaustive and disjoint by construction, so a renamed or
# newly added test cannot silently fall out of every shard the way a
# hand-maintained filter list would eventually let one do.
cargo test --test command_test --no-run
mapfile -t ALL < <(
cargo test --test command_test -- --list --format terse \
| sed -n 's/: test$//p' | sort
)
total=${#ALL[@]}
if [ "$total" -lt 2000 ]; then
echo "::error::enumerated only $total command tests; refusing to run a truncated shard"
exit 1
fi
MINE=()
for index in "${!ALL[@]}"; do
if [ "$(( index % SHARD_COUNT ))" -eq "${{ matrix.shard }}" ]; then
MINE+=("${ALL[$index]}")
fi
done
echo "shard ${{ matrix.shard }} of $SHARD_COUNT: ${#MINE[@]} of $total tests"
cargo test --test command_test -- --exact "${MINE[@]}"
network-remotes:
name: compat-network-remotes
runs-on: [self-hosted]
env:
CARGO_TERM_COLOR: always
RUSTUP_TOOLCHAIN: stable
LIBRA_SKIP_WEB_BUILD: "1"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_BUILD_JOBS: "1"
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@11.10.0 --activate
# Network-only test layer (`test-network` feature gate). Tests requiring outbound
# network but no secrets are surfaced through this job; tests requiring real
# credentials live behind `test-live-ai` / `test-live-cloud` and run only in
# the `compat-live-*` (workflow_dispatch) jobs, which are intentionally not
# GitHub required-checks.
- name: Run network-remote tests
run: cargo test --features test-network --test network_remotes_test -- --test-threads=1