WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
365 stars 100 forks source link

Making standalone plugins usable before they're released to the plugin repo #911

Closed joemcgill closed 5 months ago

joemcgill commented 10 months ago

Feature Description

Once #656 is complete, the intention was that new modules would be initially released as standalone plugins, and not bundled with the main Performance Lab plugin. This creates a situation where new plugin modules can not easily be tested or used prior to them being available on the plugin repo. Given the current long wait times for new plugins to be approved on the repo, this would create a significant problem for efficiently developing and testing out new features and no clear way of testing the feature prior to an initial release.

Currently, a new module can be activated from the Performance Lab settings screen before it has been removed as a standalone plugin, so a new module can be tested by checking out a feature branch of this repo that includes the new module and activating it in the settings screen.

Initial ideas to consider

As originally discussed in https://github.com/WordPress/performance/pull/904#issuecomment-1858540201, there are a few ways to address this issue:

  1. Allow new modules to initially be included as experimental features that can be activated in the Performance Lab plugin prior to being released as a standalone plugin. This would require maintaining the migration logic developed in #656 in the plugin indefinitely, as it will be needed as new plugins are released.
  2. Update the release process for this repo so that we can publish zip files of standalone modules here, before they are available on the plugin repo. This is probably worth looking into regardless, so we can test pre-release zips prior to publishing a new release of a standalone plugin. However, this is still less convenient than being able to test updates from a single repo.

Currently effected modules in development

felixarntz commented 10 months ago

I think I would prefer option 1, as it allows automatic updates easily (simply via Performance Lab). It's also not a lot of additional work required since most of the necessary infrastructure is implemented already.

Any code could start as a module, and once it's approved as standalone plugin, it can be deployed that way. Users would then see the migration notice as needed, and 1-2 releases later the module would be removed from PL.

The main difference that doing this long-term would potentially require is to adjust the standalone plugin build process slightly:

joemcgill commented 10 months ago

I put a bit of time into investigating what we would need to do to publish zips of standalone plugins to the releases page of this repo and if we did want to do this, we would need to update a few parts of our current workflow automation.

Currently, publishing a new release triggers both the main Deploy to WordPress.org workflow as well as the Deploy standalone plugins to WordPress.org workflow.

Both of these workflows would need to be altered so that we could publish a standalone plugin release (or pre-release) that would automate the creation of a new release tag without triggering additional deployment workflows. We could probably use tag filtering (step.if) to accomplish this, but we may want to rethink the whole automation flow so that the published release on the repo is the final result of the release workflow, rather than the trigger to initiate the workflow. We could also consider automating the creation of standalone plugin specific branches, from which each plugin could be tagged and deployed.

All this to say, I do think that option 1 will be less effort initially, though I would like for us to have a better long-term way of offering downloads of standalone plugins—including pre-release versions—for testing purposes outside of the official plugins repo. I do like the idea of moving standalone plugins to a separate folder that is organized as plugin folders rather than needing and think that if we make that change, then keeping a separation between what is a "plugin" and what is a "module" would simplify things a bit.

felixarntz commented 10 months ago

How about we start with the following workflow for modules that graduate into standalone plugins:

This would pretty much be the workflow.

To make that happen, only a few infrastructure changes would need to be implemented:

Once all of this infrastructure exists, we would document the workflow in the Performance Team Handbook, similar to the other documentation that already exists on writing a module. A few points in that existing documentation should probably be updated then as well.

LMKWYT.

joemcgill commented 10 months ago

TLGTM! 😜

For now I think we should separate discussion about moving standalone plugins to a separate built plugins directory from the problem this issue is trying to solve. For now, manually building a plugin before it's released seems like a fine workaround to get the review process started. We could even upload those zips manually to the GH release page if we wanted to make it easier for folks to test pre-releases before they're on the .org repo.

Until a module is available on the .org repo, keeping it available as an option to enable seems sensible. Once it's available, we can migrate it to whatever the current process is for managing the standalone plugins. Let's start a new issue for reorganizing published modules within the codebase in the meantime.

felixarntz commented 10 months ago

Happy to break this apart, but I think the separate built plugins directory is a given anyway. We can't have those continue to live in the modules directory when they shouldn't be modules in PL anymore.

I agree though that the infrastructural change related to having both modules and plugins directories should be implemented regardless of what we decide for this issue here. Even if we end up deciding that we won't start new standalone plugins as a module first, that'll be needed. In that case, we would probably start a new standalone plugin in the plugins directory right away, but then there would need to be another approach if we wanted to make it available before .org approval.

westonruter commented 10 months ago

Happy to break this apart, but I think the separate built plugins directory is a given anyway. We can't have those continue to live in the modules directory when they shouldn't be modules in PL anymore.

Sorry if this was already discussed...

What if they actually are kept in modules and all of the standalone plugins continue to get shipped as part of the PL plugin as modules? This would make migration to standalone plugins much easier, as a site owner could switch over to the standalone plugin at any time. There would be no back-compat breakage. In this way

As soon as someone installs a standalone plugin for a PL module, the module code would then short-circuit so that only one copy of the functionality is active at a time. The PL module could get deactivated (in the plugin DB option) when the standalone plugin is activated, ensuring that when a site owner deactivates the module it doesn't result in the module's behavior (from the PL plugin) from continuing to run unexpectedly. This would be the essence of the migration logic.

This would also solve the problem of the plugin review queue taking so long to approve new plugins. The long wait would not hold up immediate testing of the new module bundled with the PL plugin: it's just that the module wouldn't be able to be tested standalone until the standalone plugin is published on the directory.

felixarntz commented 10 months ago

@westonruter Having the features as modules and plugins was ruled out during the initial project definition as an option. See the conversation starting in https://github.com/WordPress/performance/issues/618#issuecomment-1432785852 for context.

felixarntz commented 8 months ago

@joemcgill Given that we won't use modules anymore, we may want to close this issue. Or at the very least rename it to maybe use "features" instead of "modules".

Personally, I'm not sure there's realistically a need for this in terms of making those features available at scale, as the plugin reviews have become much faster again, so I don't envision us being blocked from that anymore.

What is worth thinking about as you were mentioning the other day is how to make pre-release versions of features easier to test, but that's probably mostly a DX issue to improve for the contributors to the project rather than at scale (as in the 100k+ Performance Lab end users). It may fit better into a new dedicated issue that explains that goal.

joemcgill commented 8 months ago

Thanks @felixarntz. I would like to keep this issue open until we have a documented process for testing standalone plugins in development prior to being released on the .org repo. I've renamed the issue to no longer refer to "modules" in order to be more clear. There are two main reasons this is still needed:

  1. During initial development, you need to be able to test the plugin installed on a local environment. This used to be done by activating the module, but that is no longer possible.
  2. Once the plugin is released to the .org repo, we need to be able to do pre-release tests of new versions of standalone plugins prior to pushing a release to the .org repo, including making sure that there are no conflicts between standalone plugins when installed together (should be caught by our test suite, but still worth making an explicit part of our QA process).

As I've thought more about this, the easiest way for us to solve all of these issues is to make sure all of our standalone plugins are loaded automatically as part of the .wp-env.json config, like this:

{
  "plugins": [
    ".",
    "./plugins/auto-sizes/auto-sizes.php",
    "./plugins/speculation-rules/load.php"
  ]
}

That way the standalone plugins are auto-installed locally without additional workarounds.

Somewhat related, I think it would be nice to update our release workflows so that each plugin gets included individually in our releases page, with zip files attached for each standalone plugin release, along with changelogs, etc. This could also allow us to generate pre-releases if needed.

felixarntz commented 8 months ago

@joemcgill I like your wp-env proposal, that would be a very straightforward start that would already improve DX a lot.

joemcgill commented 8 months ago

👍🏻 PR incoming for that shortly.

felixarntz commented 7 months ago

Removing this from the 3.0.0 milestone as it is not really relevant for end users of the plugin and thus doesn't have to be solved by that release.

westonruter commented 5 months ago

@joemcgill I think this is done now, right?

joemcgill commented 5 months ago

Yes, I think we can close this. The standalone plugin folders are automatically loaded into the wp-env container since #1028. We can also build production versions locally using npm run build-plugins since #1033.