#56179 closed task (blessed) (fixed)
Tools: Automate backporting core blocks from Gutenberg to Core
Reported by: | gziolo | Owned by: | gziolo |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Follow up for #55642.
Syncing stable blocks from the Gutenberg repository to wordpress-develop
is currently a manual process, but it can be automated.
The proposed workflow:
- Read all the block.json files from the
@wordpress/block-library
directory. - Pick the ones without
__experimental
restrictions – these are the stable blocks. - Use that list to generate PHP code that requires appropriate dynamic blocks PHP files.
- Use that list to generate PHP code that calls
remove_action
with appropriate arguments in PHP unit tests. - Use that list yet again in webpack config, instead of the hardcoded one.
To make the process smooth, require and remove_action calls can be extracted to separate PHP files that can be easily autogenerated and overwritten:
wp-includes/blocks/require-dynamic-blocks.php
wp-includes/blocks/require-static-blocks.php
tests/phpunit/includes/unregister-blocks-hooks.php
Change History (11)
This ticket was mentioned in PR #2940 on WordPress/wordpress-develop by gziolo.
2 years ago
#2
- Keywords has-unit-tests added
#4
@
2 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
We still need to improve the integration with the webpack config that depends on bringing the changes applied in https://github.com/WordPress/gutenberg/pull/40655 to WordPress core. In effect, we need to update all core blocks to their latest version before we can land these changes.
2 years ago
#5
I landed most of the changes with https://core.trac.wordpress.org/changeset/53688. The last remaining piece is the changes to the weback config that requires updating core blocks first.
#6
@
2 years ago
May be missing something but... Looking at [53688], think it was decided it's a good idea to not commit auto-generated files to trunk. They are replaced every time when building, there is no point of them being in the repo.
In addition having these dynamically generated, always overwritten files committed may bring problems when building to /build, the same thing that happened with script-loader-packages.php
before.
2 years ago
#7
Any particular reason the auto-generated PHP files are committed to trunk? Think it was decided to not do that again after the problems with script-loader-packages.php
.
Also, these files are supposed to be overwritten every time WP is build, right? So why commit the potentially old versions of them :)
#8
@
2 years ago
Also, these files are supposed to be overwritten every time WP is build, right? So why commit the potentially old versions of them :)
Thank you for raising the issue. It's a different use case though because the script that updates 3 newly extracted files is totally optional. We might want to reword the code comment that gets included in the file after it gets recreated when core blocks change in a specific way in the Gutenberg plugin - new block added, a block promoted from an experiment to a stable version, block transitioned from static to dynamic or the other way around:
https://core.trac.wordpress.org/browser/trunk/tools/release/sync-stable-blocks.js?rev=53688#L22
This file was autogenerated by tools/release/sync-stable-blocks.js, do not change manually!
To further clarify, tools/release/sync-stable-blocks.js
doesn't run on every build. It gets only triggered when calling npm run sync-gutenberg-packages
that you run only when bringing new changes from the Gutenberg plugin to WordPress core. I expect those files to change at most a few times for a given major WordPress release.
2 years ago
#10
With https://core.trac.wordpress.org/changeset/54308 all changes are now included in WordPress core.
Replaces https://github.com/WordPress/wordpress-develop/pull/2647.
Trac ticket: https://core.trac.wordpress.org/ticket/56179.
## What problem does this PR solve?
Syncing stable blocks from the Gutenberg repository to
wordpress-develop
is currently a manual process.The thing is, it can be automated.
That's what this PR does.
## How does this PR solve it?
The big idea is to:
block.json
files from the@wordpress/block-library
directory.__experimental
restrictions – these are the stable blocks.require
s appropriate dynamic blocks PHP files.remove_action
with appropriate arguments in PHP unit tests.All of this is possible thanks to https://github.com/WordPress/gutenberg/pull/40655
To make the process smooth,
require
andremove_action
calls were extracted to separate PPH files that can be easily autogenerated and overwritten:wp-includes/blocks/require-dynamic-blocks.php
wp-includes/blocks/require-static-blocks.php
tests/phpunit/includes/unregister-blocks-hooks.php
## How to test?
npx grunt sync-gutenberg-packages
post-author-name
were excluded from both listscc @adamziel