diff --git a/.github/workflows/notebook-e2e.yml b/.github/workflows/notebook-e2e.yml new file mode 100644 index 000000000..9c4af93ea --- /dev/null +++ b/.github/workflows/notebook-e2e.yml @@ -0,0 +1,62 @@ +name: notebook e2e + +on: + push: + paths: + - ".github/workflows/notebook-e2e.yml" + - "Cargo.lock" + - "Cargo.toml" + - "crates/sema-notebook/**" + pull_request: + paths: + - ".github/workflows/notebook-e2e.yml" + - "Cargo.lock" + - "Cargo.toml" + - "crates/sema-notebook/**" + +jobs: + e2e: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - name: Install system dependencies + # The webServer command (playwright.config.ts) shells out to + # `cargo run --bin sema -- notebook serve`, which compiles the native + # binary. That pulls in `serialport` (transitive `libudev-sys`), which + # needs libudev-dev on Linux. Mirrors the same install in ci.yml. + run: | + sudo apt-get update + sudo apt-get install -y libudev-dev + + - uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo + target + uses: Swatinem/rust-cache@v2 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Pre-build the sema binary + # The playwright webServer launches `cargo run --bin sema` with a 60s + # startup timeout; a cold-cache debug build takes minutes. Building here + # keeps the in-webServer `cargo run` near-instant. + run: cargo build --bin sema + + - run: npm ci + working-directory: crates/sema-notebook/tests/e2e + + - run: npx playwright install --with-deps chromium + working-directory: crates/sema-notebook/tests/e2e + + - run: npx playwright test + working-directory: crates/sema-notebook/tests/e2e + + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: playwright-results + # test-results/ (traces, screenshots, error context) is always + # produced; the config declares no html reporter. + path: crates/sema-notebook/tests/e2e/test-results/ diff --git a/crates/sema-notebook/src/ui.rs b/crates/sema-notebook/src/ui.rs index bfbc79844..214862b7c 100644 --- a/crates/sema-notebook/src/ui.rs +++ b/crates/sema-notebook/src/ui.rs @@ -23,6 +23,7 @@ pub fn asset(path: &str) -> Option<(String, String)> { sema_ui_js().to_string(), "application/javascript".to_string(), )), + "vendor/tokens.css" => Some((tokens_css().to_string(), "text/css".to_string())), _ => None, } } @@ -68,3 +69,14 @@ fn js() -> &'static str { fn sema_ui_js() -> &'static str { include_str!("ui/vendor/sema-ui.js") } + +/// The `@sema-lang/ui` design-token sheet — the `--gold*`/`--text-*`/spacing/radius +/// custom properties the component bundle's own styles fall back to. Linked before +/// `style.css` so the notebook's palette overrides land on top. Vendored from the +/// published npm package's `src/styles/tokens.css`. Refresh alongside `sema_ui_js` +/// by fetching the pinned version from the unpkg CDN: +/// curl -fsSL https://unpkg.com/@sema-lang/ui@/src/styles/tokens.css \ +/// -o crates/sema-notebook/src/ui/vendor/tokens.css +fn tokens_css() -> &'static str { + include_str!("ui/vendor/tokens.css") +} diff --git a/crates/sema-notebook/src/ui/index.html b/crates/sema-notebook/src/ui/index.html index bbe59a952..c40c4fbe3 100644 --- a/crates/sema-notebook/src/ui/index.html +++ b/crates/sema-notebook/src/ui/index.html @@ -5,12 +5,13 @@ Sema Notebook + - + @@ -25,45 +26,57 @@ Notebook
- +
- - + + + + + + + + + + + + + +
- - + + + + + + + + + + + + + +
- - + + + + + + + + + + + + + + +
@@ -76,8 +89,8 @@
Empty notebook
- - + + Code + + Markdown
@@ -86,14 +99,17 @@