From 864e57ce1f51ef23409b4e6786af2f25adde6485 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Fri, 23 Oct 2026 22:35:00 +0800 Subject: [PATCH] Persist CI Cargo caches and repair runtime regression coverage --- .gitea/workflows/README.md | 23 +++++++++++++++++ .gitea/workflows/ci.yml | 16 +++++++----- Dockerfile.ci | 5 +--- scripts/README.md | 9 +++++++ scripts/verify-ci.sh | 27 ++++++++++++++++++++ src/README.md | 7 ++++++ src/endor_host.rs | 51 ++++++++++++++++++++++---------------- src/ui_bridge.rs | 8 ++++++ src/window.rs | 15 +++++++++++ 9 files changed, 130 insertions(+), 31 deletions(-) create mode 100644 scripts/verify-ci.sh diff --git a/.gitea/workflows/README.md b/.gitea/workflows/README.md index f869a58..ad95553 100644 --- a/.gitea/workflows/README.md +++ b/.gitea/workflows/README.md @@ -17,3 +17,26 @@ Docker is used only in this remote workflow; local compilation is native. The test image installs DejaVu Sans/Mono and Noto CJK for font metrics and Chinese fallback checks. Text regression tests inspect glyph selection, measured advances, fractional scale, multiline bounds, Unicode truncation and antialiased opacity. + +## Incremental verification + +Gitea 1.26 concurrency groups cancel superseded runs on the same ref. Markdown-only +pushes and pull requests skip verification; executable Endor examples and Rust +files (including embedded guide strings) still trigger checks. Manual dispatch +always runs verification. Existing queued runs created from older workflow +revisions retain their old behavior. + +The workflow invokes [verify-ci.sh](../../scripts/verify-ci.sh). Docker builds the +Rust 1.91.1/system/font toolchain from Dockerfile.ci over stdin, without sending a +source build context. The checkout is mounted read-only at /build. Named volumes +persist Cargo registry/git downloads and /cargo-target across container removal, +including failed tests and cancelled runs. Main/manual runs and each PR have +separate cache scopes. Changing Rust/toolchain compatibility requires updating +the image and cache prefix in the script. Cargo lockfiles and fingerprints decide +which dependencies/artifacts are reusable; caches do not bypass checks. + +A host flock serializes each scope's writable target cache. Signal handling +removes only the current run's named container; it never prunes shared Docker +resources or deletes cache volumes. The first run populates caches; later runs +still execute fmt, all tests and Clippy. Cargo compilation remains single-job to +limit memory pressure on the shared host. No CPU-time guarantee is implied. diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 781ef08..49de6dc 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -3,9 +3,15 @@ name: Verify Tessera GUI on: push: branches: [main] + paths-ignore: ["**/*.md"] pull_request: + paths-ignore: ["**/*.md"] workflow_dispatch: +concurrency: + group: tessera-${{ gitea.workflow }}-${{ gitea.ref }} + cancel-in-progress: true + jobs: verify: runs-on: ces-control @@ -41,9 +47,7 @@ jobs: EXPECTED_ASTER_SHA: ${{ steps.aster_revision.outputs.sha }} run: test "$(git -C vendor/aster rev-parse HEAD)" = "$EXPECTED_ASTER_SHA" - - name: Verify portable GUI code - run: | - sh -n scripts/build-macos-app.sh - image="endorphin-tessera-gui-ci:${{ gitea.sha }}" - docker build -f Dockerfile.ci -t "$image" . - docker run --rm --init "$image" + - name: Verify portable GUI code with persistent Cargo caches + env: + CI_CACHE_SCOPE: ${{ gitea.event_name == 'pull_request' && format('pr-{0}', gitea.event.pull_request.number) || 'main' }} + run: sh scripts/verify-ci.sh diff --git a/Dockerfile.ci b/Dockerfile.ci index 146c4a1..322483b 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -4,8 +4,5 @@ RUN apt-get update && apt-get install -y --no-install-recommends pkg-config libx && rm -rf /var/lib/apt/lists/* \ && rustup component add rustfmt clippy ENV CARGO_BUILD_JOBS=1 CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0 -COPY Cargo.toml Cargo.lock ./ -COPY src ./src -COPY examples ./examples -COPY vendor ./vendor +ENV CARGO_TARGET_DIR=/cargo-target CMD ["sh", "-eu", "-c", "cargo fmt --check && cargo test --locked && cargo clippy --all-targets --locked -- -D warnings"] diff --git a/scripts/README.md b/scripts/README.md index f4acee3..6f5dd13 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -13,3 +13,12 @@ The CI workflow only checks this script's shell syntax on Linux; native bundle construction and window presentation are verified on macOS. Return to the [project guide](../README.md). + +## Remote verification + +[verify-ci.sh](verify-ci.sh) runs only on the Linux ces-control host. It builds the +source-independent [toolchain image](../Dockerfile.ci), mounts the checkout +read-only and retains Cargo downloads/build output in project-specific Docker +volumes. CI_CACHE_SCOPE selects main/manual or a PR cache namespace. It acquires +a host lock and removes its own container on interruption; cached volumes survive. +See [workflow details](../.gitea/workflows/README.md) for invalidation and triggers. diff --git a/scripts/verify-ci.sh b/scripts/verify-ci.sh new file mode 100644 index 0000000..91b8d87 --- /dev/null +++ b/scripts/verify-ci.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Run only on the Linux CI host with Docker; never bake source into cache images. +set -eu +scope=${CI_CACHE_SCOPE:-manual} +case "$scope" in *[!a-zA-Z0-9_-]*|'') echo "Invalid cache scope" >&2; exit 1;; esac +root=$(pwd -P) +image=endorphin-tessera-gui-ci:rust-1.91.1 +prefix=tessera-ci-rust-1-91-1-$scope +# Serialize access to each target directory, including manually started checks. +exec 9>"/tmp/$prefix.lock" +flock 9 +sh -n scripts/build-macos-app.sh +# Empty context: only the toolchain and OS dependencies become image layers. +docker build -t "$image" - < Dockerfile.ci +name="$prefix-${GITHUB_RUN_ID:-$$}" +cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; } +trap cleanup EXIT +trap 'exit 130' INT +trap 'exit 143' TERM +docker run --name "$name" --rm --init \ + --mount "type=bind,src=$root,dst=/build,readonly" \ + --mount "type=volume,src=$prefix-target,dst=/cargo-target" \ + --mount "type=volume,src=$prefix-registry,dst=/usr/local/cargo/registry" \ + --mount "type=volume,src=$prefix-git,dst=/usr/local/cargo/git" \ + "$image" & +run_pid=$! +wait "$run_pid" diff --git a/src/README.md b/src/README.md index d5a3f5b..6ea6323 100644 --- a/src/README.md +++ b/src/README.md @@ -228,3 +228,10 @@ A waiting coroutine retains its evaluated operand and frames as managed edges; w While a native tab drag is held over an overflow arrow area, the strip waits 350ms then reveals one hidden tab every 120ms, including in a compatible destination window. The preview scroll does not activate Pages or change business state. Drawing, hit testing and insertion gaps share the same transient visible range; release uses its full-order insertion index. Leaving the strip stops the timer; release, Escape, a new press or runtime generation change restores the normal active-tab-centered strip. A resize or changing tab count clamps the range. Native drag/mixed-DPI behavior still requires platform validation; application-exit lifecycle notifications remain unfinished. + +CI regression fixtures use the published frame's session identity for input, +current Endor statement boundaries/type names and the retained runtime's actual +layout/paint pipeline. Failed first Console rendering discards unpublished Page +registrations through host-only cleanup, preventing the next successful query +from silently opening a previously failed pending render. Earlier ordinary +bindings remain live; explicit page.render can subsequently publish the Page. diff --git a/src/endor_host.rs b/src/endor_host.rs index aebbaca..22ca9f9 100644 --- a/src/endor_host.rs +++ b/src/endor_host.rs @@ -1505,7 +1505,7 @@ class Alternating: Column { page=Page() page.render(Alternating(0,0,RectBlock(120,60))) "#; - let error = compile(source, "app.main", 1).unwrap_err(); + let error = ReplSession::load(source, "app.main", 1, 1).err().unwrap(); assert!( error.to_string().contains("did not converge (cycle)"), "{error:#}" @@ -1531,7 +1531,7 @@ class Invalid: TextBlock { page=Page() page.render(Invalid("invalid")) "##; - let error = compile(source, "app.main", 1).unwrap_err(); + let error = ReplSession::load(source, "app.main", 1, 1).err().unwrap(); assert!(error.to_string().contains("wrapHeight"), "{error:#}"); } @@ -2231,7 +2231,7 @@ page.render(block) ); session .execute( - "cancelled=ui.after(ui,\"cancel\",0,first.apply) cancelled.cancel()", + "cancelled=ui.after(ui,\"cancel\",0,first.apply)\ncancelled.cancel()", "app.main", ) .unwrap(); @@ -2311,7 +2311,7 @@ page.render(block) ); session .execute( - "closing=ui.after(other,\"close\",0,action.apply) other.close()", + "closing=ui.after(other,\"close\",0,action.apply)\nother.close()", "app.main", ) .unwrap(); @@ -2351,7 +2351,7 @@ page.render(block) session.execute("token.status()", "app.main").unwrap().value, "\"cancelled\"" ); - session.execute("broken=ui.after(ui,\"fail\",0,action.fail) later=ui.after(ui,\"later\",0,action.apply)","app.main").unwrap(); + session.execute("broken=ui.after(ui,\"fail\",0,action.fail)\nlater=ui.after(ui,\"later\",0,action.apply)","app.main").unwrap(); assert!(session.poll_tasks().is_err()); assert!(session.is_faulted()); let globals = session.candidate.globals.unwrap(); @@ -2618,7 +2618,7 @@ page.render(block) .vm .dict_delete(globals, &Value::Text("other".into())) .unwrap(); - session.execute("nil", "app.main").unwrap(); + session.execute("0", "app.main").unwrap(); session.candidate.vm.collect_cycles(); assert!(session.candidate.vm.upgrade(weak).unwrap().is_none()); // An externally retained old leaf Mount must not retain the window context. @@ -2694,7 +2694,7 @@ page.render(block) assert!(initial.frame.tabs[1].active); let input = crate::events::Input { window: crate::window::MAIN_WINDOW, - session: 120, + session: initial.frame.session, layout_version: initial.frame.layout_version, mount: initial.frame.tabs[0].id, kind: "tab-activate".into(), @@ -2724,7 +2724,7 @@ page.render(block) let closed = session .dispatch(&crate::events::Input { window: crate::window::MAIN_WINDOW, - session: 120, + session: renamed.frame.session, layout_version: renamed.frame.layout_version, mount: renamed.frame.tabs[1].id, kind: "tab-close".into(), @@ -2892,11 +2892,7 @@ page.render(block) page = Page() page.render(BadRect(80,20,0,"#DDEEFF"))"##; let error = ReplSession::load(source, "app.main", 114, 1).err().unwrap(); - assert!( - error - .to_string() - .contains("window operations are forbidden") - ); + assert!(error.to_string().contains("read-only")); } fn source_measure_stat(session: &mut ReplSession, name: &str) -> i64 { @@ -3240,7 +3236,7 @@ page.render(block) ( "return MeasureResult(parent.block.metrics.width, 60)", "return Point(0,0)", - "wrong result type", + "measure return expects MeasureResult", ), ( "positions.children.at(0).x = self.metrics.left", @@ -3278,7 +3274,7 @@ page.render(block) session .dispatch(&crate::events::Input { window: crate::window::MAIN_WINDOW, - session: 81, + session: initial.frame.session, layout_version: initial.frame.layout_version, mount: circle.id, kind: "click".into(), @@ -3306,7 +3302,7 @@ page.render(block) #[test] fn source_hit_rejects_wrong_result_and_business_writes_before_callbacks() { for (body, message) in [ - ("return 1", "hitTest must return Bool"), + ("return 1", "hitTest return expects Bool"), ( "self.hits.increment()\nreturn point.inCircle(40, 40, 40)", "read-only", @@ -3324,7 +3320,7 @@ page.render(block) let error = session .dispatch(&crate::events::Input { window: crate::window::MAIN_WINDOW, - session: 82, + session: initial.frame.session, layout_version: initial.frame.layout_version, mount: circle.id, kind: "click".into(), @@ -4203,7 +4199,7 @@ page.render(block) session .dispatch(&crate::events::Input { window: crate::window::MAIN_WINDOW, - session: 41, + session: document.frame.session, layout_version: document.frame.layout_version, mount: mount.id, kind: "click".into(), @@ -4672,7 +4668,7 @@ page.render(block) assert!(!session.is_faulted()); assert_eq!( session.execute("token.status()", "app.main").unwrap().value, - "pending" + "\"pending\"" ); assert_eq!(source_measure_stat(&mut session, "layoutCancels"), 1); } @@ -5816,7 +5812,7 @@ returned = button.dispatch(dispatched)"#, let mut session = ReplSession::new(233).unwrap(); session .execute( - "rect = RectBlock(40, 20)\nroot = ColumnBlock(0, 0, rect)", + "rect = RectBlock(40, 20)\nroot = Column(0, 0, rect)", "app.main", ) .unwrap(); @@ -5881,7 +5877,7 @@ returned = button.dispatch(dispatched)"#, "function present(self: WrongResult, window: Window): Number { marker.increment() return 7 }", ), ] { - let input = format!("class {name} {{ {method} }} ui.implement({name}, Presentable)"); + let input = format!("class {name} {{ {method} }}\nui.implement({name}, Presentable)"); let error = session .execute(&input, "app.main") .err() @@ -6398,6 +6394,19 @@ returned = button.dispatch(dispatched)"#, let retained = session.execute("value", "app.main").unwrap(); assert_eq!(retained.value, "3"); assert!(retained.document.is_none()); + // Failed publication leaves the Page/bindings usable, but it can only + // become visible through a later successful explicit render. + let recovered = session + .execute("page.render(ui.text(\"recovered\"))", "app.main") + .unwrap() + .document + .unwrap(); + assert!(recovered.frame.commands.iter().any(|command| matches!( + command, RenderCommand::Text { value, .. } if value == "recovered" + ))); + assert!(recovered.frame.commands.iter().all(|command| !matches!( + command, RenderCommand::Text { value, .. } if value == "discarded" + ))); session.execute("function local(value: Number): Number { result = value result = 42 return result }", "app.main").unwrap(); assert_eq!( session.execute("local(40)", "app.main").unwrap().value, diff --git a/src/ui_bridge.rs b/src/ui_bridge.rs index e1610ba..5b5c6d9 100644 --- a/src/ui_bridge.rs +++ b/src/ui_bridge.rs @@ -2330,6 +2330,14 @@ impl UiBridge { .map_err(|_| anyhow::anyhow!("UI session poisoned"))?; for presentation in state.presentations.values_mut() { let window = object(Some(&vm.get_attr(presentation.desktop, "window")?))?; + // A failed first render must not become visible on the next input + // merely because show() already registered its Page with the Window. + if presentation.active.is_none() && presentation.last_tabs.is_empty() { + let unpublished = crate::window::pages(vm.object_store(), window)?.to_vec(); + for page in unpublished { + crate::window::unregister_page_host(vm, window, page)?; + } + } let pages = crate::window::pages(vm.object_store(), window)?; let next = if presentation.closing { None diff --git a/src/window.rs b/src/window.rs index 20c4d1e..c3c1186 100644 --- a/src/window.rs +++ b/src/window.rs @@ -275,6 +275,21 @@ pub fn unregister_page( cx.replace_payload(window, data)?; Ok(()) } +/// Discard an unpublished Page registration without invoking guest callbacks. +pub fn unregister_page_host( + vm: &mut Vm, + window: ObjectRef, + page: ObjectRef, +) -> Result<(), VmError> { + let mut data = vm.payload::(window, "Window")?.clone(); + if data.pages.contains(&page) { + data.pages.retain(|value| *value != page); + vm.dict_delete(data.tabs, &Value::Text(page.to_string()))?; + vm.replace_payload(window, data)?; + } + Ok(()) +} + pub fn move_page( cx: &mut NativeContext<'_>, window: ObjectRef,