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

Move Speculation Rules to new location as purely a standalone plugin #946

Conversation

felixarntz
Copy link
Member

Summary

See #904 (comment): Since the Speculation Rules feature will not be published as a module (given the unbundling of Performance Lab) and thus only as a plugin, it should be moved to the new location for standalone plugins (see #934).

This PR is still against the feature branch and prepares that feature branch for a clean merge after #934 has been implemented. There's no blocker for merging this into the feature branch though.

No functional changes are included as part of this PR.

Checklist

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

felixarntz and others added 30 commits May 19, 2023 14:29
Co-authored-by: Weston Ruter <[email protected]>
Implement new module to use Speculation Rules API for prerendering documents on hover
Update feature branch with `trunk`
…or defensive coding, mostly relevant for tests where setting is not registered).
Copy link
Member Author

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@westonruter @swissspidy @mukeshpanchal27 This is pretty much ready now and refreshed for the way things work now in feature/modules-to-plugins.

We should probably merge #1002 first, then do another quick refresh of this one, then merge this one.

After that we'll have both auto-sizes and speculation-rules in the feature/modules-to-plugins branch and can continue development against that branch until it's merged into trunk.

Comment on lines 76 to 82
run: npm run test-php -- -- -- --testsuite auto-sizes
- name: Running multisite unit tests for Auto-sizes for Lazy-Loaded Images Plugin
run: npm run test-php-multisite -- -- -- --testsuite auto-sizes
- name: Running single site unit tests for Speculation Rules Plugin
run: npm run test-php -- -- -- --testsuite speculation-rules
- name: Running multisite unit tests for Speculation Rules Plugin
run: npm run test-php-multisite -- -- -- --testsuite speculation-rules
Copy link
Member Author

Choose a reason for hiding this comment

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

This is cumbersome so we should probably add shortcuts via scripts in composer.json and/or package.json.

There should also be a shortcut that runs the single site and multisite tests respectively for all of these plugins at once, so that we don't have to add every single plugin to this GitHub workflow file.

Let's handle that in a separate PR though, not directly related to the Speculation Rules work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I opened #1017 for that.

phpcs.xml.dist Outdated
@@ -8,7 +8,7 @@
<rule ref="WordPress-Docs"/>
<rule ref="WordPress-Extra" />
<rule ref="WordPress.WP.I18n"/>
<config name="text_domain" value="performance-lab,default,auto-sizes"/>
<config name="text_domain" value="performance-lab,default,auto-sizes,speculation-rules"/>
Copy link
Member Author

Choose a reason for hiding this comment

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

This will need to be adjusted once #1002 is merged, instead a plugins/speculation-rules/phpcs.xml.dist file should be added then.

@westonruter
Copy link
Member

We should probably merge #1002 first, then do another quick refresh of this one, then merge this one.

Let's merge it then. 🚀

@westonruter
Copy link
Member

Let's merge it then. 🚀

Merged!

@felixarntz
Copy link
Member Author

@westonruter @swissspidy @mukeshpanchal27 Should be ready for merge now!

You had already approved prior, but since I now changed the base branch, it would be great if you could do another quick sanity check.

Note that all the actual PHP code for Speculation Rules is unchanged and was already approved in the feature/speculationrules branch, so you can ignore the PHP code for the review.

@felixarntz
Copy link
Member Author

felixarntz commented Feb 27, 2024

@westonruter It looks like a test related to the CDATA fix you implemented fails, see https://github.com/WordPress/performance/actions/runs/8071362067/job/22050829990?pr=946. Maybe it is because the test code isn't limited to the specific WordPress versions?

Since the CDATA issue is only a problem on WordPress 6.4, we probably need to limit the test accordingly. Either we make those assertions conditional, or we mark the entire test to skip unless it's WordPress version 6.4.x. WDYT?

On another note: I think the code comment linking to the Trac ticket points to the wrong ticket? Shouldn't it be https://core.trac.wordpress.org/ticket/60320?

@westonruter
Copy link
Member

@felixarntz I opted to keep the test but add a condition for the WP version. Tests are passing now.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Just some trivial phpdoc changes for the test files, but otherwise I'm pre-approving.

* Class 'PLSR_URL_Pattern_Prefixer'.
*
* @package speculation-rules
* @since n.e.x.t
Copy link
Member

Choose a reason for hiding this comment

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

What about version? When we change it from n.e.x.t to actual version 1.0.0

Copy link
Member

Choose a reason for hiding this comment

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

Since the plugin is already published, this should be already 1.0.0, no?

<?php
/**
* Plugin Name: Speculation Rules
* Plugin URI: https://github.com/WordPress/performance/tree/trunk/modules/js-and-css/speculation-rules
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Plugin URI: https://github.com/WordPress/performance/tree/trunk/modules/js-and-css/speculation-rules
* Plugin URI: https://github.com/WordPress/performance/tree/trunk/plugins/speculation-rules

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I fixed this for auto-sizes as well.

@felixarntz
Copy link
Member Author

@swissspidy @mukeshpanchal27 I've addressed your feedback! This is probably good to merge now.

@felixarntz felixarntz merged commit 7d5f86b into feature/modules-to-plugins Feb 28, 2024
37 checks passed
@felixarntz felixarntz deleted the prepare/speculation-rules-standalone-plugin branch February 28, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Speculative Loading Issues for the Speculative Loading plugin (formerly Speculation Rules) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants