Skip to content

ci: run the generated-model tests and verify regeneration freshness - #39

Merged
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:ci-run-tests-and-drift
Aug 10, 2026
Merged

ci: run the generated-model tests and verify regeneration freshness#39
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:ci-run-tests-and-drift

Conversation

@vishkaty

@vishkaty vishkaty commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Observed

js-sdk has generated-model tests (tests/spec-constraints.test.js, spec-set-constraints.test.js — the #34/#37 injector work) and a wired npm test, but no workflow runs them or the model generation. The existing workflows are conventional-commits, governance, linter (pre-commit only), pr-review-listener, and release (build+publish on release). So:

  • A real regression in the committed models ships green: dropping .int().gte(0) from PriceSchema.amount makes npm test red, but no workflow runs it.
  • A broken generator ships green: disabling an injector leaves the committed models untouched, so even npm test stays green — only regenerate-and-compare catches it.

This is the same CI-theater gap closed for python-sdk in #62.

Change

A tests.yml with two jobs, matching the repo's own idiom:

  • testnpm ci + npm test (wires the existing tests into CI).
  • model-drift — checks out the pinned spec (ucp@release/2026-04-08, which the 0.4.x line targets per the README), regenerates, normalizes via the repo's own pinned pre-commit prettier hook, and fails if the committed src/spec_generated.ts differs. No auto-commit — the committed-artifact flow stays the release path (this is a drift check, aligning with the direction in the closed feat: add auto-generate models workflow #10, not a generator).

The generator toolchain is already deterministic via package-lock.json (npm ci), so no extra pin is needed.

Verification (locally, by hand)

Scenario npm test drift gate
clean HEAD green (24/24) zero diff
broken injector (models untouched) green RED (regen differs)
stale committed model RED RED

Raw quicktype output is unformatted (1707-line diff), so prettier normalization is mandatory and reproduces the committed file byte-for-byte. actionlint clean; the workflow matches the repo's existing action-tag convention and adds permissions: contents: read.

Observed: tests/spec-constraints.test.js and tests/spec-set-constraints.test.js
(the merged Universal-Commerce-Protocol#34/Universal-Commerce-Protocol#37 constraint/injector work) exist and `npm test` is wired in
package.json, but no workflow runs them. The model-generation pipeline
(generate_models.sh + scripts/*.mjs) is likewise never exercised in CI. So both
directions of a regression ship green:

  - an injector regresses but the committed src/spec_generated.ts is not
    regenerated: `npm test` still reads the old committed models and passes;
  - the committed models go stale versus the pinned UCP spec: nothing compares
    them to a fresh regeneration.

Expected: CI runs the committed tests, and asserts the committed models equal a
fresh regeneration from the UCP spec release the 0.4.x line targets (README
compatibility table: 0.4.x -> 2026-04-08).

This adds .github/workflows/tests.yml with two jobs, following the repo's own
workflow idiom (actions/checkout@v5, actions/setup-node@v6, node-version lts/*,
npm ci; push/pull_request to main like linter.yml):

  - test: npm ci + npm test, wiring the existing Universal-Commerce-Protocol#34/Universal-Commerce-Protocol#37 tests into CI.
  - model-drift: checkout the pinned ucp@release/2026-04-08, regenerate via
    generate_models.sh, normalize with the repo's own pinned pre-commit prettier
    hook (single source of truth, no second prettier version), then
    git diff --exit-code src/spec_generated.ts with an actionable ::error::.

The drift job is a check, not a generator: it never auto-commits. The committed
artifact stays the release path, aligning with the committed-artifact direction
maintainers preferred over the auto-commit approach in the closed Universal-Commerce-Protocol#10. This
parallels the merged python-sdk#62, which added the same test-plus-regeneration
CI to the Python SDK.
@vishkaty
vishkaty force-pushed the ci-run-tests-and-drift branch from a9ff669 to 8f316e3 Compare August 8, 2026 21:25
@damaz91 damaz91 added status:needs-triage Signal that the PR is ready for human triage status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Aug 8, 2026
@damaz91
damaz91 merged commit 6f3fde6 into Universal-Commerce-Protocol:main Aug 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants