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

Dev: Only one WordPress #41057

Draft
wants to merge 27 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

kraftbj
Copy link
Contributor

@kraftbj kraftbj commented Jan 14, 2025

For unit testing, we often use WorDBless, a variant of WordPress that does not require database setup. Except, we include it a lot so there are a lot of copies of WordPress within the repo when fully installed.

Before and after the changes proposed below (conducted in clean directories on my M1 with composer's cache cleared)

Before:
1st run of jetpack install --all: Between 2m 57s and 3m 17s
2nd run: 56s
Size: (du of monorepo with du of .git subtracted): 5.1 GB

After:
1st run: Between 1m 20s and 1m 52s
2nd run: 55s
Size: 2.7 GB

Proposed changes:

  • Remove inclusion of the WorDBless package in packages that did not use it for testing.
  • Add a new test-environment package to serve as the WorDBless loader for monorepo projects.
  • Replaced all inclusion of WorDBless package in individual packages with the new test-environment, updated bootstraps.
  • Added a new tools/php-test-env package that will install WorDBless once in that directory.
  • Updated monorepo root to install/update tools/php-test-env when itself is installed/updated (so jetpack install --all, -r will cover it.

In short, this changes the packages consumed by individual projects to use the internal test-environment. This ensure it is easy to modify all in the future and required little change to each individual package.

The test-environment loads a class that loads the test-php-env autoloader and loads WorDBless.

The test-php-env quasi-package does a singular install of WorDBless.

Other solution investigated was having the test-environment package directly require WorDBless, but that meant it would be re-installed every time test-environment was installed. No gain (at least) to install time, but it would have ended up with only one copy of WP.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

None yet.

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  • jetpack install -r (at least) and jetpack install a package that uses worDBLess, like packages/admin-ui
  • jetpack test phh packages/admin-ui

Does it still run the test successfully?

@github-actions github-actions bot added [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] Wpcomsh [Status] In Progress [Tests] Includes Tests Docs RNA labels Jan 14, 2025
Copy link
Contributor

github-actions bot commented Jan 14, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Beta plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for February 4, 2025 (scheduled code freeze on undefined).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Backup plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Boost plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Search plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Starter Plugin plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Protect plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Videopress plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Mu Wpcom plugin:

  • Next scheduled release: WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Inspect plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Automattic For agencies client plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Classic Theme helper plugin plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jan 14, 2025
Copy link
Contributor

github-actions bot commented Jan 14, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the try/one-wordpress-to-rule-them-all branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack try/one-wordpress-to-rule-them-all
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin try/one-wordpress-to-rule-them-all
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@kraftbj kraftbj added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 14, 2025
@github-actions github-actions bot added [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Beta For serving live branches and the beta versions. https://github.com/automattic/jetpack-beta [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. labels Jan 14, 2025
@github-actions github-actions bot added the Actions GitHub actions used to automate some of the work around releases and repository management label Jan 14, 2025
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Saw this in a list and the title piqued my curiosity 😀

I wonder if the packages/test-environment package is really needed. It seems to do about the same thing as just sticking something like this in each consumer's bootstrap.php would.

require dirname( __DIR__, 5 ) . '/tools/php-test-env/vendor/autoload.php';
\WorDBless\Load::load();

(vary the 5 as needed based on the directory structure). The one added require seems less boilerplate than a whole extra package that in the end does the same thing.

If you still want the additional error handling, make a tools/php-test-env/load.php file to require instead. 🤷

Comment on lines +85 to +87
echo "::group::Composer"
composer install --working-dir=tools/php-test-env
echo "::endgroup::"
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs to go after the bit just below that's clearing the Composer cache if we want WorDBless nightlies.

You'll probably also need to put code like this before this bit too for that case.

if [[ "$WP_BRANCH" == 'trunk' || "$WP_BRANCH" == 'previous' ]]; then
VER=$(composer --format=json --working-dir="$DIR" show | jq -r '.installed[] | select( .name == "roots/wordpress" ) | .version')
if [[ -n "$VER" ]]; then
INSVER=$WORDPRESS_TAG
[[ "$WORDPRESS_TAG" == 'trunk' ]] && INSVER="dev-main as $VER"
echo "Supposed to run tests against WordPress $WORDPRESS_TAG, so setting roots/wordpress and roots/wordpress-no-content to \"$INSVER\""
# Composer seems to sometimes have issues with deleting the wordpress dir on its own, so do it manually first.
rm -rf "$DIR/wordpress"
composer --working-dir="$DIR" require --dev roots/wordpress="$INSVER" roots/wordpress-no-content="$INSVER"
fi
fi

(and could probably get rid of it there then)

composer.json Outdated Show resolved Hide resolved
projects/packages/test-environment/.phan/baseline.php Outdated Show resolved Hide resolved
projects/packages/test-environment/package.json Outdated Show resolved Hide resolved
tools/php-test-env/composer.json Outdated Show resolved Hide resolved
tools/php-test-env/composer.json Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions GitHub actions used to automate some of the work around releases and repository management Docs [Feature] Contact Form [Feature] Google Analytics [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Photon aka "Image CDN". Feature developed in the Image CDN package and shipped in multiple plugins [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Theme Tools [JS Package] AI Client [JS Package] Analytics [JS Package] Base Styles [JS Package] Boost Score Api [JS Package] Charts [JS Package] Config [JS Package] Critical Css Gen [JS Package] Image Guide [JS Package] Licensing [JS Package] Publicize Components [JS Package] React Data Sync Client [JS Package] Scan [JS Package] Script Data [JS Package] Shared Extension Utils [JS Package] Storybook [JS Package] Svelte Data Sync Client [JS Package] Videopress Core [Package] Admin Ui [Package] Backup Helper Script Manager [Package] Backup [Package] Blaze [Package] Blocks [Package] Boost Core [Package] Boost Speed Score [Package] Chatbot [Package] Classic Theme Helper [Package] Connection [Package] Forms [Package] Google Analytics [Package] Image CDN [Package] Import [Package] Jetpack mu wpcom WordPress.com Features [Package] Licensing [Package] Masterbar [Package] My Jetpack [Package] Password Checker [Package] Plans [Package] Post List [Package] Protect Models [Package] Protect Status [Package] Publicize [Package] Scheduled Updates [Package] Schema [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Stats Admin [Package] Stats Data [Package] Sync [Package] Transport Helper [Package] VideoPress [Package] WAF [Package] WP JS Data Sync [Plugin] Automattic For Agencies Client [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Beta For serving live branches and the beta versions. https://github.com/automattic/jetpack-beta [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Classic Theme Helper Plugin [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] Wpcomsh RNA [Status] In Progress [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants