Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically sync stable blocks from Gutenberg to wordpress-develop on release #2940

Closed

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Jul 4, 2022

Replaces #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:

  1. Read all the block.json files from the @wordpress/block-library directory.
  2. Pick the ones without __experimental restrictions – these are the stable blocks.
  3. Use that list to generate PHP code that requires appropriate dynamic blocks PHP files.
  4. Use that list to generate PHP code that calls remove_action with appropriate arguments in PHP unit tests.
  5. Use that list yet again in Webpack config, instead of the hardcoded one.

All of this is possible thanks to WordPress/gutenberg#40655

To make the process smooth, require and remove_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?

  1. Wait for the Gutenberg 13.2 release on May 11th where Declare blocks as __experimental in block.json to automate syncing Gutenberg packages to WordPress gutenberg#40655 will be included
  2. Confirm all the checks are green on this PR
  3. Checkout this branch
  4. Run npx grunt sync-gutenberg-packages
  5. Confirm all the stable blocks are now represented in the PHP files listed above
  6. Confirm all the stable blocks were included in the build.
  7. Confirm experimental blocks like post-author-name were excluded from both lists

cc @adamziel

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@adamziel adamziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're good – this is great, thank you so much for taking #2647 across the line! With this PR, 90% of the mundane tasks required for the editor merge process are automated!

@gziolo gziolo force-pushed the add/sync-stable-blocks-utility branch from 1ffc973 to ace61e4 Compare July 8, 2022 11:56
@gziolo
Copy link
Member Author

gziolo commented Jul 8, 2022

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.

@gziolo gziolo force-pushed the add/sync-stable-blocks-utility branch from ace61e4 to 8e40981 Compare July 8, 2022 12:39
@azaozz
Copy link
Contributor

azaozz commented Jul 8, 2022

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 :)

@ockham ockham mentioned this pull request Aug 30, 2022
@gziolo gziolo force-pushed the add/sync-stable-blocks-utility branch from 8e40981 to edef13c Compare September 23, 2022 10:03
@gziolo gziolo force-pushed the add/sync-stable-blocks-utility branch from edef13c to 793e9a5 Compare September 26, 2022 11:30
@gziolo
Copy link
Member Author

gziolo commented Sep 26, 2022

With https://core.trac.wordpress.org/changeset/54308 all changes are now included in WordPress core.

@gziolo gziolo closed this Sep 26, 2022
@gziolo gziolo deleted the add/sync-stable-blocks-utility branch September 26, 2022 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants