Skip to content

CI smoke tests for website examples - #545

Draft
cpsievert wants to merge 21 commits into
mainfrom
example-smoke-tests
Draft

cpsievert wants to merge 21 commits into
mainfrom
example-smoke-tests

Conversation

@cpsievert

@cpsievert cpsievert commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The website ships ~600 runnable examples (website/widgets/*/examples/, website/guide/*/examples/) that users copy code from, but nothing in CI verified they still boot and render. This PR adds a suite that boots every one of them in a headless browser on each PR and asserts a widget view attaches with no console errors, no failed requests, and no Shiny output errors.

It pays for itself immediately — the first runs caught real bit-rot:

  • obsplot/12 and lonboard/14 called table.selected_rows() on a render_itables object — the accessor is .selected(), so both apps rendered nothing (fixed here, including the page prose that teaches the wrong call).
  • The entire niivue.com/demos/images host 404s upstream (niivue moved to the mono repo). All 9 niivue examples load volumes/meshes from it — some assets exist on the replacement host (niivue.github.io/niivue-demo-images, e.g. mni152.nii.gz, pcasl.nii.gz) but aal.*, BrainMesh.*, and the narps map don't, so the niivue page needs a data-host migration beyond this PR (affected examples are skipped with a pointer here).
  • vizarr/01's IDR sample zarr 404s upstream (minio-dev.openmicroscopy.org .../6001240.zarr) — skipped; the example needs a new dataset.
  • Example-only packages were missing from the dev environment (mapwidget, ipydeck, chatlas, nibabel, leafmap, … — added to the test dependency group).

How it works

  • tests/examples/ discovers example apps at collection time (Express or App( markers, recursive globs), one pytest param per app: boot with shiny_app_gen, wait for any .shiny-ipywidget-output to gain a child element (a view attach — .lm-Widget isn't universal; raw-DOM views like pythreejs don't carry it), then assert: no .shiny-output-error elements (Python render errors don't hit the console), no console errors, no failed requests, no transport-level failures. 614 example files → 610 discovered apps; 586 tested in the shared run + overlays, 24 hard-skipped with reasons.
  • tests/examples/manifest.yml holds per-example overrides (not_app, skip, overlay, no_widget, wait_selector, allow_output_error, allowed_errors/allowed_404s). A guardrail unit test (tests/unit/test_examples_manifest.py, runs in both workflows) fails the build if an example file is neither tested nor explained — new examples can't silently escape.
  • Examples whose packages can't join the shared test group use dependency overlays, mirroring the existing REACTABLE_OVERLAY pattern: overlay: reactable (18 examples) and overlay: vizarr (7) are skipped in the shared run and run in matching overlay runs (SHINYWIDGETS_EXAMPLES_OVERLAY=<name>); plain skip: entries are never lifted. leafmap instead joins the shared group since its plotly<7 constraint matches what the group already resolves.
  • lonboard/keplergl examples carry the same version-conditioned, non-strict xfail as the deep suite's ANYWIDGET_INIT_XFAIL while anywidget < 0.11.1 (fix: remove ready gate on comm messages to prevent permanent desync manzt/anywidget#1032) — CI CPU contention otherwise intermittently fails widget init; the workaround lifts itself at 0.11.1.
  • New website-examples.yaml workflow: 6 shards × 3 xdist workers (same shape as py-playwright, 10-min step timeouts + job-level bound), overlays + guardrail on shard 0. It's a separate workflow so its paths: filter can include website/** without making website-only PRs run the 5-Python unit matrix and the deep Playwright suite. Shards currently finish in ~3-5 min, inside the existing CI envelope.

Notable skips, each with a reason in the manifest: niivue (dead upstream host), vizarr/01 (dead dataset), localtileserver (its in-process tile-server uvicorn suppresses the readiness log line Shiny's probe waits for), the draft vitessce page, the deliberately uncommitted gaia-5m parquet, and 03_dark_mode (needs reactable and ipyleaflet; no single environment runs both).

Pre-existing gaps this surfaced (not fixed here)

  • ipyevents ships its nbextension inside the package (not share/jupyter/nbextensions), so require_dependencies() can't serve it locally: leafmap examples 404 on /ipyevents.js before the CDN fallback kicks in (widget still renders). Tolerated via allowed_404s; a local-serving fix belongs in a separate change.
  • ipydatagrid + plotly in one app 404s ipydatagrid's icon PNGs under /lib/anywidget-0.0/ (dependency-resolution quirk, cosmetic).
  • localtileserver's logging interference (above) might warrant an upstream note.
  • test_geolibre_local_cog_via_proxy flaked once on this branch (tile-response timeout under runner contention, passed on re-run and on main consistently) — pre-existing flake class, not caused by this change.

table.selected_rows() -> table.selected(): render_itables's named accessor
is .selected(); selected_rows is the widget trait. Caught by the website
example smoke suite (the apps rendered nothing).
So the website example smoke suite can boot every example: chatlas,
querychat, anthropic (ai-exploration guide), nibabel (niivue), mdtraj
(nglview), mocpy (ipyaladin), scikit-learn (k3d/embedding-atlas),
bokeh_sampledata (bokeh>=3.8 split), leafmap + rioxarray + mapclassify +
localtileserver + scipy (leafmap page).
- Check view attachment via output children, not .lm-Widget (raw-DOM
  widgets like pythreejs don't carry that class); any output counts, not
  just the first
- Overlay runs (reactable, vizarr) with an env-var skip lift, matching
  the existing REACTABLE_OVERLAY pattern; leafmap joins the shared group
  instead since the group's plotly is <7 anyway
- Manifest entries: ipyevents.js 404s (leafmap), drawdata svg height
  console noise, ipydatagrid icon 404s, pydeck widget-less demos, gaia
  parquet not committed, vitessce draft page, localtileserver's
  in-process uvicorn suppressing the readiness probe, dead
  niivue.com/demos/images host
03_dark_mode needs reactable AND ipyleaflet, and the overlay breaks
ipyleaflet's nbextension lookup, so no environment runs it; -k reactable
already covers every example the overlay can serve.
…t types

- The manifest guardrail previously only ran under py-check.yaml, whose
  path filters exclude website/** -- a website-only PR could add an
  unmanifested helper (or stale entry) unnoticed. Run it on shard 0.
- load_manifest rejected unknown keys but not wrong value types: a scalar
  allowed_errors silently became a tuple of characters (trivially
  permissive), and a quoted no_widget string was truthy.
@netlify

netlify Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for shinywidgets canceled.

Name Link
🔨 Latest commit f4c65ad
🔍 Latest deploy log https://app.netlify.com/projects/shinywidgets/deploys/6b13a4dfa51f9410907e53fa

@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 02:56 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The smoke tests can pass despite Python render errors, transport failures, or incomplete widget initialization, leaving significant failures undetected.

3 open issues
What changed in this PR

Adds browser smoke tests for website examples, extending CI coverage to runnable documentation and fixing incorrect table-selection calls.

Changes:

  • Adds example discovery, manifest overrides, and coverage guardrails.
  • Runs smoke tests across six CI shards, with separate dependency overlays.
  • Corrects render_itables accessor usage in examples and guides.
File Description
website/​widgets/​obsplot/​index.md Corrects selection accessor documentation and snippet.
website/​widgets/​obsplot/​gallery/​showcase_gapminder_dashboard.py Fixes table-selection accessor.
website/​widgets/​obsplot/​examples/​12_table_row_highlight.py Fixes table-selection accessor.
website/​widgets/​lonboard/​index.md Corrects selection accessor documentation and snippet.
website/​widgets/​lonboard/​examples/​14_table_to_fly_to.py Fixes table-driven map selection.
tests/​unit/​test_examples_manifest.py Adds discovery and manifest guardrails.
tests/​examples/​test_smoke.py Checks widget attachment and browser errors.
tests/​examples/​manifest.yml Records skips and permitted errors.
tests/​examples/​examples-pytest.ini Configures parallel execution and timeouts.
tests/​examples/​discovery.py Discovers apps and loads overrides.
tests/​examples/​conftest.py Parametrizes examples and manages app processes.
pytest.ini Excludes browser examples from default recursion.
pyproject.toml Adds example dependencies to the test group.
Makefile Adds shared and overlay smoke-test targets.
AGENTS.md Documents the example smoke suite.
.github/​workflows/​website-examples.yaml Adds sharded CI and overlay runs.
.agents/​skills/​adding-shinywidgets-integrations/​SKILL.md Documents smoke-test requirements for examples.

Review effort: Balanced

Comment thread tests/examples/test_smoke.py Resolved
Comment thread tests/examples/test_smoke.py Resolved
Comment thread tests/examples/test_smoke.py Resolved
- Capture transport-level request failures (requestfailed), which
  produce no HTTP response and were invisible to collect_errors
- Assert no .shiny-output-error elements: a Python render error shows
  there (not on the console), and a working sibling widget would let it
  pass. pydeck's intentional deprecation demo opts out via a new
  allow_output_error manifest key
- no_widget examples waited for nothing, so pydeck's static-iframe demo
  could pass without rendering; a new wait_selector manifest key waits
  for the iframe itself
- Brief settle after readiness so late async errors land before the
  assertions
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 03:02 Inactive
The settle added in fe42641 surfaces errors that land just after view
attach; three known classes appear only in CI's headless Linux Chromium:
embedding-atlas's WebGPU warnings (filtered identically by the deep
suite), lonboard's benign luma.gl re-init message, and anywidget
<0.11.1's init failure under CPU contention (the deep suite xfails the
same class).
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 03:07 Inactive
- niivue.com/demos/images 404s for every file since niivue moved to the
  mono repo; some assets exist on the replacement GitHub Pages host but
  aal/BrainMesh/narps don't, so the niivue page needs a data-host
  migration beyond this PR. Skip all 9 affected examples.
- aladin-lite's usage-logger endpoint and pygwalker's CORS-blocked
  update check are third-party phone-home noise on every init.
- maplibre joins lonboard in tolerating the benign luma.gl re-init
  message under CI contention.
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 03:18 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 03:28 Inactive
@cpsievert
cpsievert requested a balanced review from Copilot December 5, 2026 03:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The changes re-enable a broken vizarr example and whitelist a lonboard initialization error, allowing smoke tests to pass despite lost Python-to-JavaScript updates.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread tests/examples/manifest.yml Resolved
Comment thread Makefile Resolved
…ntion

Addresses the second Copilot round:

- The un-skip env var lifted every manifest skip, so the vizarr overlay
  re-enabled 01_quickstart, whose IDR dataset is dead upstream. Skips
  now come in two kinds: an overlay: <name> entry (lifted only by the
  matching SHINYWIDGETS_EXAMPLES_OVERLAY run) and a plain skip entry
  (never lifted). vizarr/01 stays skipped in every run; the vizarr
  overlay run shows 7 passed, 1 skipped.
- Whitelisting lonboards anywidget init error would permanently mask
  real init failures. Mirror the deep suite instead: a version-
  conditioned, non-strict xfail on lonboard/keplergl examples while
  anywidget <0.11.1 (manzt/anywidget#1032), lifting itself at 0.11.1.
@cpsievert
cpsievert force-pushed the example-smoke-tests branch from 9dc193b to ae116e7 Compare December 5, 2026 03:41
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 03:44 Inactive
@cpsievert
cpsievert requested a balanced review from Copilot December 5, 2026 03:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because unpublished findings identify gaps in transport-failure handling, job-wide timeout enforcement, and nested example coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

- The single-level globs silently missed nested examples: the recursive
  glob finds 2 more apps (guide/performance/examples/lifetimes/08,09,
  both pass) and 1 more helper (manifested as not_app). Future nested
  examples can no longer escape the guardrail.
- Add a job-level timeout-minutes alongside the step-level ones.
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 04:05 Inactive
@cpsievert
cpsievert requested a balanced review from Copilot December 5, 2026 05:38
@github-actions
github-actions Bot temporarily deployed to pull request December 5, 2026 05:42 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The filename-based check misses four lonboard-rendering apps, leaving the documented CPU-contention failure unhandled in CI on anywidget versions below 0.11.1.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/examples/conftest.py Outdated
if override.overlay != os.environ.get(_OVERLAY_ENV):
skip_reason = f"needs the {override.overlay} dependency overlay"
marks = [pytest.mark.skip(reason=skip_reason)] if skip_reason else []
if any(pkg in example.rel for pkg in _BIG_ESM_PACKAGES):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f4c65ad: applicability is now determined from source, not paths. uses_big_esm_package() in tests/examples/discovery.py scans each example for lonboard/keplergl imports or render_lonboard/render_keplergl usage (path match kept as a backstop), and a new guardrail in tests/unit/test_examples_manifest.py pins the exact set of detected examples outside lonboard/keplergl paths — the four you named — so future examples that render these packages under a different path fail the unit suite until the xfail logic covers them.

This branch was successfully deployed

1 active deployment
pull request — f4c65ada Deployed Dec 5, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants