Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
298ab8c
Add website example smoke-test CI workflow
cpsievert Dec 5, 2026
5fe8c39
Document website example smoke suite in integration skill and AGENTS.md
cpsievert Dec 5, 2026
65b55f4
Add website example discovery module, manifest, and guardrail tests
cpsievert Dec 5, 2026
3ae9e03
Add website example smoke-test suite and make target
cpsievert Dec 5, 2026
0654e70
Merge branch 'example-smoke/ci-and-docs' into example-smoke-tests
cpsievert Dec 5, 2026
591b6b8
Add mapwidget and ipydeck to test deps for any-widget guide examples
cpsievert Dec 5, 2026
3f61ed7
Drop untracked uv.lock from workflow path filters
cpsievert Dec 5, 2026
aba8015
Fix render_itables accessor misuse in obsplot/lonboard examples
cpsievert Dec 5, 2026
23598a2
Add example-only packages to the test dependency group
cpsievert Dec 5, 2026
805b356
Triage website example smoke suite to green
cpsievert Dec 5, 2026
d7c76b5
Limit reactable overlay run to reactable-matching examples
cpsievert Dec 5, 2026
5dd89fe
Address final review: run guardrail in the workflow, validate manifes…
cpsievert Dec 5, 2026
fe42641
Deepen smoke assertions from Copilot review
cpsievert Dec 5, 2026
6105762
Allow CI-environment console noise the deep suite already tolerates
cpsievert Dec 5, 2026
71ebb03
Skip niivue examples (dead upstream data host), tolerate telemetry noise
cpsievert Dec 5, 2026
0fb1301
Tolerate pygwalker's generic net::ERR_FAILED console message too
cpsievert Dec 5, 2026
ac97758
Skip vizarr/01 (dead IDR sample dataset), tolerate lonboard/11 anywid…
cpsievert Dec 5, 2026
ae116e7
Distinguish overlay skips from permanent skips; xfail anywidget conte…
cpsievert Dec 5, 2026
fa33d2b
Recurse example globs; bound the workflow job
cpsievert Dec 5, 2026
7266527
Re-request Copilot review
cpsievert Dec 5, 2026
f4c65ad
Detect big-_esm examples from source, not just paths
cpsievert Dec 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .agents/skills/adding-shinywidgets-integrations/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Turn the guide into `website/widgets/<slug>/`: `index.md` (front matter: `title`

- Add the page to the Widgets sidebar group in `website/_quarto.yml` and the `render_<x>` function to the matching quartodoc `contents:` list; a new sidebar group also needs a matching category card in `website/index.qmd` (`make docs` fails the build when the groups and cards don't match).
- `website/_tools/check_docs.py` must report nothing (snippets match example files byte-for-byte; links resolve). Bump the hardcoded sidebar-link count in `website/_tools/check_site.py` (checked by `make docs-check`).
- Every `examples/*.py` you add is booted in a browser by the website-example smoke suite (`tests/examples/`, `make test-examples`) and must render a widget with no browser console errors. An example that can't run in CI (network, credentials, renders no widget) or that logs a known-benign error needs a `tests/examples/manifest.yml` entry — the guardrail in `tests/unit/test_examples_manifest.py` fails the build until every example file is either tested or explained there.
- Code blocks name their file: ` ```{.python file="examples/x.py"} `. Reshoot screenshots rather than reusing stale ones.
- The bundled agent skill ships a matching reference: add `shinywidgets/.agents/skills/shinywidgets/references/widgets/<slug>.md` (end it with a `Written against \`<pkg>\` N.x.` stamp) and a roster row in that skill's `SKILL.md` Widgets table. `tests/unit/test_agent_skill.py` fails until both exist.

Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/website-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: website-examples.yaml

on:
push:
branches: ["main", "rc-*"]
paths:
- "shinywidgets/**/*"
- "js/**/*"
- "website/**/*"
- "tests/**/*"
- "Makefile"
- "pyproject.toml"
- ".github/workflows/website-examples.yaml"
pull_request:
paths:
- "shinywidgets/**/*"
- "js/**/*"
- "website/**/*"
- "tests/**/*"
- "Makefile"
- "pyproject.toml"
- ".github/workflows/website-examples.yaml"
workflow_dispatch:

permissions:
contents: read

env:
UV_VERSION: "0.13.x"

# Smoke-boots every website widget/guide example in a browser. Runs in its own
# workflow (parallel to py-check's jobs) so the repo's ~5-minute CI wall-clock
# is unchanged as long as shards stay within the 10-minute job timeout.
jobs:
py-examples:
runs-on: ubuntu-latest
# Shard steps are individually bounded (10 min each); bound the whole
# job too so a stuck install can't hold a runner
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v6.1.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
cache-suffix: examples

- name: Set up Python 3.12
run: uv python install 3.12

- name: Install dependencies
run: uv sync --python 3.12 --all-groups

# The guardrail is part of the unit suite, which py-check only runs for
# non-website changes -- run it here too so a website-only PR can't add
# an example file without a manifest entry (or a stale entry) unnoticed
- name: Run manifest guardrail
if: matrix.shard == 0
run: uv run pytest tests/unit/test_examples_manifest.py -q

- name: Run website example smoke tests (shard ${{ matrix.shard }}/6)
# Healthy shards should finish in ~5 minutes; kill stragglers quickly
timeout-minutes: 10
# Retry failures twice, matching the py-playwright job's flake posture
run: make test-examples PYTEST_EXAMPLES_ARGS="--num-shards 6 --shard-id ${{ matrix.shard }} -n 3 --reruns 2 --reruns-delay 5"

# reactable and vizarr can't join the shared test group (ipyreact and
# zarr<3 pins respectively), so their examples run with dependency
# overlays, once (shard 0)
- name: Run overlay example smoke tests
if: matrix.shard == 0
timeout-minutes: 10
run: |
make test-examples-reactable PYTEST_EXAMPLES_ARGS="-n 3 --reruns 2 --reruns-delay 5"
make test-examples-vizarr PYTEST_EXAMPLES_ARGS="-n 3 --reruns 2 --reruns-delay 5"
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cd js && yarn install && yarn watch
- **Unit tests**: `make test` (or `make test-unit`)
- **Run a single test**: `uv run pytest tests/unit/test_foo.py::test_name`
- **Playwright (browser) tests**: `make test-playwright`
- **Website example smoke tests**: `make test-examples` (boots every `website/{widgets,guide}` example in a browser; overrides in `tests/examples/manifest.yml`)
- **All tests**: `make test-all-local`
- **Coverage**: `make coverage`
- **Build package**: `make dist`
Expand Down Expand Up @@ -154,5 +155,6 @@ SPLIT=$(git log --format=%H -1 -S'class render_plotly(' -- shinywidgets/_render_

- **Unit tests** (`tests/unit/`): Cover comm transport, serialization, rendering lifecycle, widget coercion, dependencies, reactivity, and layout defaults. Run with `make test-unit`.
- **Playwright tests** (`tests/playwright/`): Browser-based integration tests that spin up real Shiny apps from `tests/apps/` fixtures. Run with `make test-playwright`.
- **Example smoke tests** (`tests/examples/`): Browser smoke checks that every website example app boots and renders a widget with a clean console. Discovered automatically from `website/{widgets,guide}/*/examples/*.py`; per-example overrides (skip, no_widget, allowed errors) live in `tests/examples/manifest.yml`, guarded by `tests/unit/test_examples_manifest.py`. Run with `make test-examples`.
- Pyright type checking excludes `tests/playwright/` (see `pyproject.toml` `[tool.pyright]` config).
- CI runs format, types, and unit tests across Python 3.10-3.14; Playwright tests on 3.12 only.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help clean clean-build clean-pyc clean-test setup check-format check-types check-tests check check-tox build format coverage check-build test test-unit test-reactable test-playwright test-playwright-reactable test-playwright-coverage test-all-local coverage-ci coverage-combine coverage-html dist install pyright docs docs-preview docs-check
.PHONY: help clean clean-build clean-pyc clean-test setup check-format check-types check-tests check check-tox build format coverage check-build test test-unit test-reactable test-playwright test-playwright-reactable test-playwright-coverage test-examples test-examples-reactable test-examples-vizarr test-all-local coverage-ci coverage-combine coverage-html dist install pyright docs docs-preview docs-check

.DEFAULT_GOAL := help

Expand All @@ -8,6 +8,7 @@ PYTHON_PATHS := shinywidgets tests
PYRIGHT_PATHS := shinywidgets tests/__init__.py tests/unit/test_version_metadata.py
PYTEST_UNIT := uv run pytest -c "$(REPO_ROOT)/pytest.ini" --confcutdir "$(REPO_ROOT)"
PYTEST_PLAYWRIGHT := uv run pytest -c "$(REPO_ROOT)/tests/playwright/playwright-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/playwright" "$(REPO_ROOT)/tests/playwright"
PYTEST_EXAMPLES := uv run pytest -c "$(REPO_ROOT)/tests/examples/examples-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/examples" "$(REPO_ROOT)/tests/examples"
# reactable can't join the shared test/dev groups (importing it builds a
# process-global ipyreact Module widget that order-sensitive FakeSession unit
# tests don't expect), it imports great_tables without declaring it, and it
Expand Down Expand Up @@ -96,6 +97,21 @@ test-playwright: ## run Playwright regression tests
uv run playwright install chromium
$(PYTEST_PLAYWRIGHT) $(PYTEST_PLAYWRIGHT_ARGS)

test-examples: ## smoke-test every website example app in a browser
uv run playwright install chromium
$(PYTEST_EXAMPLES) $(PYTEST_EXAMPLES_ARGS)

# Examples that need a dependency overlay are skipped in the shared run (see
# tests/examples/manifest.yml); SHINYWIDGETS_EXAMPLES_OVERLAY lifts the skip
# for entries whose `overlay:` names that overlay.
test-examples-reactable: ## smoke-test reactable website examples (needs the overlay; see REACTABLE_OVERLAY)
uv run playwright install chromium
SHINYWIDGETS_EXAMPLES_OVERLAY=reactable uv run $(REACTABLE_OVERLAY) pytest -c "$(REPO_ROOT)/tests/examples/examples-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/examples" "$(REPO_ROOT)/tests/examples" -k reactable $(PYTEST_EXAMPLES_ARGS)

test-examples-vizarr: ## smoke-test vizarr website examples (needs the overlay; vizarr pins zarr<3)
uv run playwright install chromium
SHINYWIDGETS_EXAMPLES_OVERLAY=vizarr uv run --with vizarr pytest -c "$(REPO_ROOT)/tests/examples/examples-pytest.ini" --confcutdir "$(REPO_ROOT)/tests/examples" "$(REPO_ROOT)/tests/examples" -k vizarr $(PYTEST_EXAMPLES_ARGS)

test-reactable: ## run reactable unit tests (needs the overlay; see REACTABLE_OVERLAY)
$(PYTEST_REACTABLE)

Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,23 @@ test = [
# cartopy 0.25 has no Python 3.14 wheels. Drop the pin and the markers once
# geoviews supports cartopy>=0.26 (which has 3.14 wheels).
"cartopy<0.26; python_version < '3.14'",
"anthropic",
"bokeh_sampledata",
"chatlas",
"querychat",
"nibabel",
"mdtraj",
"mocpy",
"scikit-learn",
# leafmap stays out of the shared group only via its extra because of
# plotlymap's plotly<7 need; the examples don't use plotlymap, so the
# group can carry leafmap with the group's plotly
"leafmap",
"rioxarray",
"mapclassify",
# leafmap[raster] examples (05_raster_cog, 10_drawn_features_zonal)
"localtileserver",
"scipy",
"datashader",
"drawdata>=0.5",
# duckdb (a dependency of embedding-atlas, mosaic-widget, pygwalker, and
Expand All @@ -282,6 +299,7 @@ test = [
"ipycanvas",
"ipycytoscape",
"ipydatagrid>=1.2.0",
"ipydeck",
"ipyfilechooser",
"ipyleaflet>=0.20.0",
"ipysigma",
Expand All @@ -304,6 +322,9 @@ test = [
# Python 3.15+ yet, so lonboard can't be installed there
"lonboard; python_version < '3.15'",
"maplibre[anywidget]",
# mapwidget and ipydeck aren't shinywidgets integrations (the any-widget
# guide's third-party examples use them via the generic render_widget)
"mapwidget",
"mols2grid>=2.2.0,<3",
"nglview",
"pandas",
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minversion = 6.0
# Default to fast, deterministic unit tests. Playwright tests are run explicitly
# via their own config file under tests/playwright/.
testpaths = tests/unit
norecursedirs = tests/playwright
norecursedirs = tests/playwright tests/examples

addopts =
-ra
Expand Down
69 changes: 69 additions & 0 deletions tests/examples/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from __future__ import annotations

import importlib.metadata
import os
from dataclasses import dataclass

import pytest
from packaging.version import Version
from shiny.run import ShinyAppProc

# Same private helper shiny's own pytest plugin (create_app_fixture) uses; it
# handles port search, readiness waiting, and subprocess teardown.
from shiny.run._run import shiny_app_gen
from tests.examples.discovery import Example, discover_examples, uses_big_esm_package


@dataclass(frozen=True)
class RunningExample:
proc: ShinyAppProc
example: Example


# Examples whose package can't join the shared test group carry
# `overlay: <name>` in the manifest and are skipped unless the matching
# overlay run names it here (see the test-examples-* Makefile targets).
_OVERLAY_ENV = "SHINYWIDGETS_EXAMPLES_OVERLAY"

# anywidget <0.11.1 rejects a model's init after a hard-coded 2s and then
# drops all subsequent state updates (manzt/anywidget#1030, fixed by
# manzt/anywidget#1032). lonboard's and keplergl's multi-MB inline _esm trip
# that budget under CI-grade CPU contention, intermittently failing widget
# init. Mirrors ANYWIDGET_INIT_XFAIL in tests/playwright/conftest.py:
# non-strict, and lifts itself once anywidget 0.11.1+ is installed.
_ANYWIDGET_INIT_XFAIL = pytest.mark.xfail(
Version(importlib.metadata.version("anywidget")) < Version("0.11.1"),
reason="anywidget <0.11.1 can fail widget init under CPU contention (manzt/anywidget#1032)",
strict=False,
)


def _params() -> list:
params = []
for example in discover_examples():
override = example.override
skip_reason = override.skip
if skip_reason is None and override.overlay is not None:
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 uses_big_esm_package(example):
marks.append(_ANYWIDGET_INIT_XFAIL)
params.append(pytest.param(example, id=example.rel, marks=marks))
return params


@pytest.fixture(params=_params())
def running_example(request):
example: Example = request.param
gen = shiny_app_gen(
example.path,
cwd=str(example.path.parent),
timeout_secs=30,
env={"SHINY_TESTMODE": "1"},
)
proc = next(gen)
try:
yield RunningExample(proc=proc, example=example)
finally:
proc.close()
Loading
Loading