ci: validate generated markup against Gutenberg's own block validator #137
No reviewers
Labels
No labels
build-dist
priority
P1
priority
P2
priority
P3
priority
P4
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Toilville/toilville-design!137
Loading…
Reference in a new issue
No description provided.
Delete branch "ci/gutenberg-block-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#136 fixed five pages whose wrappers WordPress would not accept. This is the gate that would have caught them.
WordPress rebuilds a block's markup from its attributes and compares the two. When they disagree the editor offers "Attempt Block Recovery", and recovering in the Site Editor saves a copy into the database that then shadows the theme's own file — which is how
/news/ended up rendering from an override. A mismatch forks the page; it does not stay an editor warning.Nothing here could have caught it.
copy_coveragecounts text,forgeblock_validatechecks the ForgeBlock contract, and neither knows what WordPress does with a block's attributes. This asks WordPress's own packages.Scope
.forgejo/block-validation/validate-blocks.cjs— parses markup with@wordpress/blocks, registers the core blocks, and registers everytoilville/*block from the plugin's realblock.json, so it compares against what the site registers. Each block's save shape is read off itsindex.jsrather than kept in a list here that would drift..forgejo/workflows/block-validation.yml— runs it twice:core/coverand blocks the Getwid plugins own. Printed so the number stays visible instead of growing quietly..npmrcpinslegacy-peer-deps: npm's strict resolver spends minutes backtracking over the@wordpresspeer ranges and then rejects them.npm cireads the file too, so CI cannot forget it..forgejo/so the JS stays with CI rather than landing in the repo proper.Testing
mainas it stands: the 31 generated files validate clean; the inherited patterns report 47 blocks and exit 0.stylefrom one generated pattern. The job fails and names the file, the block and the attribute:npm cifrom clean: 3s, 324 packages.test_workflow_invariants.pypasses on the new workflow (57 tests);yamllintclean; the full suite is 327 passing.Impact Statement
CI only — no change to any generated artifact, the theme, or the site. Adds one job to pull requests, roughly the cost of
npm ciplus a parse of 31 files. It can fail a PR that would otherwise merge, which is the point: the failure it catches is one that reaches readers as a recovery prompt instead of a page.One caveat, in the README too: these packages track Gutenberg's releases while the site runs the blocks bundled with its WordPress. They agree about the mismatch this exists to catch, but core blocks gain deprecations over time, so a finding against an inherited block may reflect a newer core than the site runs. That is part of why the inherited set only reports.
Forgejo parses ${{ }} wherever it appears in a run block, comments included, and an empty one fails to parse — which took the whole workflow with it (schema validation error, no step run). yamllint and the workflow invariants both pass on it; only Forgejo's parser objects.