Skip to content

test: Validate CLI templates in CI - #3358

Open
mishablablabla wants to merge 2 commits into
mainfrom
test/cli-templates-ci
Open

mishablablabla wants to merge 2 commits into
mainfrom
test/cli-templates-ci

Conversation

@mishablablabla

@mishablablabla mishablablabla commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #3299

New workflow test-cli-templates.yml + checker scripts/test-cli-templates.ts. For every template in packages/typegpu-cli/templates (the list is read from the folder): scaffold with the CLI, npm install, check, build, types, then load the production build and the dev server in headless Chrome (WebGPU on SwiftShader). Fails on console errors, page errors, failed requests and WebGPU validation errors.

  • PRs / merge queue: the CLI and packages are built from the checkout and packed, so the template is tested against the PR's code, not the last npm release.
  • Weekly + manual: @typegpu/cli@latest against whatever npm serves today (templates use caret ranges, so third-party releases can break them).
  • Self-test: plants 5 bugs (including an app that never creates a WebGPU device) and requires the checker to report each one for its own reason. Runs only when the checker changes, weekly and on demand.

Whole PR run takes ~5 min.

Known limits:

  • Expo: install, check and types only (no build script, no browser).
  • Only npm as the package manager.
  • Presenting a canvas frame kills WebGPU in headless Chrome + SwiftShader on hosted runners, so the canvas texture is replaced by an ordinary one: shaders and pipelines run and are validated, frames on screen aren't.
  • vite-react dev logs a React 19.3 use() error (fix(@typegpu/react): useRoot without a Suspense boundary logs a React 19.3 use() error #3353); ignored explicitly until the fix is released.

To decide:

  • I wouldn't make it a required check while it has a path filter (PRs outside packages/** would wait forever).
  • -y always runs npx skills add; the checker removes its output. A --skip-skills flag in the CLI would be cleaner.
  • Who watches the weekly run when it goes red?

Scaffolds every @typegpu/cli template, installs it, runs check, build and
types, then loads the production build and the dev server in headless Chrome
(WebGPU on SwiftShader) and fails on console, page and WebGPU errors.

PRs test the CLI and packages built from the checkout (packed tarballs);
a weekly run tests the published CLI against what npm serves today.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 16:53
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@101e930fc07e079ad840888e86e86bff7d603723
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@101e930fc07e079ad840888e86e86bff7d603723

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.85, 1.65, 3.98, 5.83, 6.15, 11.10, 23.54, 25.22]
  line [0.76, 1.57, 3.51, 6.25, 7.12, 10.86, 21.05, 22.59]
  line [0.80, 1.73, 3.94, 5.26, 6.24, 11.13, 22.49, 27.50]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.20, 0.36, 0.59, 0.71, 0.95, 1.02, 1.28, 1.26]
  line [0.21, 0.39, 0.53, 0.65, 0.86, 0.90, 1.07, 1.21]
  line [0.25, 0.55, 0.56, 0.70, 0.90, 0.90, 1.07, 1.24]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.82, 2.14, 3.91, 7.97, 11.70, 22.81, 51.39, 104.69]
  line [0.78, 2.01, 3.49, 6.59, 12.56, 24.30, 51.34, 103.67]
  line [0.79, 1.94, 3.36, 6.13, 11.26, 24.39, 50.79, 104.28]
Loading

@github-actions

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased ❔ Unknown
0 356 0 0

No notable changes.

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

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 checks can pass without detecting the injected bug or initializing WebGPU, and a stalled readiness request can exceed the advertised 60-second deadline.

3 open issues
What changed in this PR

Adds CI validation for CLI-generated templates, covering checkout-built packages and published releases to catch scaffolding, dependency, build, and browser regressions.

Changes:

  • Discovers templates automatically and checks installation, linting/formatting, builds, and types.
  • Exercises production and development servers in headless Chrome with WebGPU validation.
  • Adds scheduled published-package checks, injected-error self-tests, and diagnostic artifacts.
File Description
scripts/​test-cli-templates.ts Implements scaffolding, package overrides, browser validation, error injection, and reporting.
.github/​workflows/​test-cli-templates.yml Orchestrates package builds, template matrices, scheduled checks, and self-tests.

Review effort: Balanced

Comment thread scripts/test-cli-templates.ts Resolved
Comment thread scripts/test-cli-templates.ts Resolved

@pullfrog pullfrog Bot 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.

ℹ️ Minor suggestions only — the checker itself holds up. The notes below are about how much confidence the self-test actually buys and about the weekly-run gap the PR already flags.

Reviewed changes

  • scripts/test-cli-templates.ts (new) — scaffolds one template with @typegpu/cli, installs it (optionally rewriting deps to packed tarballs via npm overrides, plus a lockfile guard that every packed name resolved from file:), runs check/build/types, then serves the production build and the dev server and loads each in headless Chrome with console/page/HTTP/WebGPU error capture. The canvas texture is swapped for a plain texture and rAF is throttled by onSubmittedWorkDone(), since presenting a frame breaks WebGPU on SwiftShader.
  • .github/workflows/test-cli-templates.yml (new) — discovers templates from packages/typegpu-cli/templates, builds and packs the workspace, runs one job per template against the checkout, a weekly @typegpu/cli@latest job, and a four-bug checker self-test gated on changes to the checker.

I verified the checker end to end from this checkout: packed typegpu, unplugin-typegpu and @typegpu/cli, then ran vite-bare with Chrome 156 on SwiftShader. The tarball install guard, check/build/types, both serve modes and both browser passes succeeded, and all four --inject bugs failed in browser-production with the expected problem text. oxfmt --check and type-aware oxlint are clean on the new script; actionlint reports only a shellcheck info about ls.

( ◦°^°◦) 🏴‍☠️ I read every line o' the diff and sailed the checker through a real packed-CLI run, canvas an' all.

ℹ️ The weekly run has no notification path

The schedule trigger is the only early warning for third-party breakage of the templates, but a red weekly run notifies nobody, so it will go stale unnoticed (the PR body raises this too).

Technical details
# Schedule failures need an owner

## Affected sites
- `.github/workflows/test-cli-templates.yml:31-32` — `schedule` cron with no failure handling.

## Required outcome
- A failed scheduled run reaches a person or a tracked issue instead of only the Actions tab.

## Suggested approach
- Add a final job with `if: failure() && github.event_name == 'schedule'` that opens or updates a GitHub issue (or reuses whatever notification path other workflows use), and name the owner in the workflow comment.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

- The self-test requires each planted bug to be reported for its own reason,
  not just any browser failure.
- Fail when the app never creates a WebGPU device (a page whose script never
  ran used to pass), with a `no-device` self-test for it.
- Bound each readiness request by the 60 s deadline.

@pullfrog pullfrog Bot 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.

✅ No new issues found.

Reviewed changes

  • Added a no-device self-test case that replaces the scaffolded entry module with export {} and requires the browser pass to report the missing device.
  • Replaced the self-test's "first failing step is browser-*" assertion with a per-bug expected problem prefix, so each planted bug must be caught for its own reason.
  • Added an info.devices === 0 check to the browser pass, so a page that loads without errors but never initializes WebGPU fails instead of passing silently.
  • Bounded the server readiness fetch with AbortSignal.timeout(...), so a server that accepts the connection but never answers cannot outlive the 60-second deadline.

I checked the new expectation against Chrome 156 on SwiftShader: an invalid shader module produces uncapturederror: Error while parsing WGSL: :1:1 error: unexpected token ..., which matches the WebGPU uncapturederror: Error while parsing WGSL prefix. The checker-self-test jobs for all five bugs, including no-device, passed on this head.

( ◦°^°◦) 🏴‍☠️ I re-checked the fresh commits from stem to stern and found no new leaks in the hull.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

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

The checker can mask WebGPU validation errors by expanding texture usage and miss same-origin transport failures because it lacks a requestfailed listener.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Preserve configured texture usage in CI

scripts/​test-cli-templates.ts:487

Adding TEXTURE_BINDING and COPY_SRC to the replacement texture makes operations valid in CI that would fail on the real canvas, such as copying from a canvas configured with only the default RENDER_ATTACHMENT usage. This masks WebGPU validation errors that the checker is meant to catch. Preserve the configured usage without granting additional capabilities.

Medium severity Report failed same-origin requests

scripts/​test-cli-templates.ts:544

The response event only covers requests that receive an HTTP response; transport failures and aborted requests emit requestfailed instead. A failed same-origin request whose rejection is handled without logging can therefore leave this check green. Add a same-origin requestfailed listener that records the URL and failure reason, and extend the local Page interface accordingly.

3 resolved since last review

Review effort: Balanced

@iwoplaza

Copy link
Copy Markdown
Collaborator

Thanks for this work!
A few things I'd try to do differently before we merge:

  1. I think using parseArgs from node:util would reduce the custom helpers, and improve the strictness of the args (it throws when an unknown arg was passed in)
  2. Instead of keeping failed global boolean and if guarding on each step, could we use throw, try and catch? We set the global flag and return anyway.

This branch has not been deployed

No deployments
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.

test: Validate that our CLI templates work in CI

3 participants