Files
JasonHoku-ComfyUI-Ultimate-…/.github/workflows/tests.yml
T
Jason HokuandClaude Fable 5.1 48ab82dacc feat(dashboard): JS/CSS bundle routes with immutable caching (Roadmap 27 M2)
The dashboard shell no longer inlines ~450 KB of scripts and CSS: two fixed routes,
GET /config_tester/dashboard_bundle_js and _css (?v=<content hash>, weak ETag, 304, gzip,
Cache-Control immutable when the hash matches, no-cache otherwise), serve the concatenated
resources (pinned order, standalone last; rebuilt when a resource file changes, so F5 hot
reload still works). The shell drops from ~527 KB to ~68 KB (12 KB gzipped) and repeat loads
cost ~0 KB; the node iframe (srcdoc inherits the parent's base URL) uses the same routes, so
ComfyUI's executed/history payloads shrink too. inline_assets=True (implied by inline_manifest,
or USCG_INLINE_DASHBOARD_ASSETS=1) keeps a fully self-contained page. The v query is only
compared, never used for lookup; no path parameters.

Tests: 16 unit (order, page independence, inline == bundled bytes, hash rebuild, headers,
v-is-never-a-path, node --check of globals + bundle), e2e (top-level + srcdoc iframe + inline +
500 path), CI assembled-page step covers globals + bundle as one script.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-04 18:39:18 -08:00

142 lines
5.2 KiB
YAML

name: Tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
jobs:
pytest-stubs:
name: pytest (ComfyUI + torch stubbed)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: tests/requirements-ci.txt
- run: pip install -r tests/requirements-ci.txt
- name: Assert torch is NOT installed (this leg tests the stub path)
run: python -c "import importlib.util,sys; sys.exit(importlib.util.find_spec('torch') is not None)"
# expect: 554 passed, 17 skipped (the requires_torch tests + the real-torch image test), measured 11/4/26 after wave 2
- run: python -m pytest tests/ -q -ra --ignore=tests/e2e
pytest-torch:
name: pytest (real CPU torch)
runs-on: ubuntu-latest
timeout-minutes: 20
env:
USCG_REQUIRE_TORCH: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: tests/requirements-ci.txt
- name: Install CPU torch (latest CPU wheel; the tests only need the torch API, not a specific minor)
run: pip install torch --index-url https://download.pytorch.org/whl/cpu
- run: pip install -r tests/requirements-ci.txt
- run: python -c "import torch; print(torch.__version__); assert hasattr(torch, 'inference_mode')"
# expect: 571 passed, 0 skipped (the stub leg's passed + skipped; the torch leg itself is not measured locally)
- run: python -m pytest tests/ -q -ra --ignore=tests/e2e
js-syntax:
name: JS syntax
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: web/**/*.js (ES modules)
run: |
for f in $(find web -name '*.js'); do
node --input-type=module --check < "$f" || { echo "FAIL $f"; exit 1; }
done
- name: resources/*.js (plain scripts)
run: |
for f in resources/*.js; do
node --check "$f" || { echo "FAIL $f"; exit 1; }
done
- name: Assembled Dashboard page (all logic_*.js share ONE script scope)
run: |
python - <<'PY'
import os, re, sys
sys.path.insert(0, os.getcwd())
import html_generator
page = html_generator.get_html_template("ci", {"items": []}, "1", inline_assets=True)
bodies = re.findall(r"<script(?![^>]*\bsrc=)[^>]*>(.*?)</script>", page, re.S)
assert bodies, "no inline <script> found in the generated page"
out = os.environ.get("RUNNER_TEMP", ".")
for n, body in enumerate(bodies):
with open(os.path.join(out, f"bundle_{n}.js"), "w", encoding="utf-8") as fh:
fh.write(body)
print(f"wrote {len(bodies)} script bodies to {out}")
# globals script + bundle as ONE script: catches a resource redeclaring
# TARGET_NODE_ID / USCG_STANDALONE / fullManifest
with open(os.path.join(out, "bundle_all.js"), "w", encoding="utf-8") as fh:
fh.write("\n;\n".join(bodies))
with open(os.path.join(out, "bundle_route.js"), "w", encoding="utf-8") as fh:
fh.write(html_generator.get_dashboard_bundle("js").text)
PY
for f in "${RUNNER_TEMP:-.}"/bundle_*.js; do
node --check "$f" || { echo "FAIL $f"; exit 1; }
done
- name: node:test unit tests (tests/js, if present)
run: |
if [ -d tests/js ]; then
node --test tests/js/
else
echo "tests/js not present, skipping"
fi
e2e-dashboard:
name: Dashboard SPA (Playwright)
runs-on: ubuntu-latest
timeout-minutes: 15
env:
USCG_REQUIRE_E2E: "1"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
tests/requirements-ci.txt
tests/e2e/requirements.txt
- run: pip install -r tests/requirements-ci.txt -r tests/e2e/requirements.txt
- name: Cache Playwright browsers
id: pw
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: pw-${{ runner.os }}-${{ hashFiles('tests/e2e/requirements.txt') }}
- name: Install Chromium (cache miss)
if: steps.pw.outputs.cache-hit != 'true'
run: python -m playwright install --with-deps --only-shell chromium
- name: Install Chromium system deps (cache hit)
if: steps.pw.outputs.cache-hit == 'true'
run: python -m playwright install-deps chromium
- run: python -m pytest tests/e2e -q -ra --browser chromium --tracing retain-on-failure --output test-results
- name: Upload traces
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-traces
path: test-results/
retention-days: 7