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

Allow specifying a WordPres/WordPress branch and pulling from GitHub. #1705

Merged
merged 7 commits into from
Aug 28, 2024

Conversation

peterwilsoncc
Copy link
Contributor

Motivation for the change, related issues

As a Core contributor, it can be helpful to pull in trunk or the head of another branch to test changes before they are tagged, released or appear in a nightly. This is especially the case for older branches that do not have nightly builds.

This allows for the pulling in of a zip from the GitHub build repository.

Implementation details

Update to plugin-proxy.php

  1. Accepts the new parameter branch
  2. Considers trunk and master as the head of the repo
  3. Considers x.x and x.x-branch as the head of the specified branch

Update to unzipWordPress()

  1. After calculating the WordPress path, it checks for the file wp-config-sample.php
  2. If the file does not exist, adds a desperate last attempt to determine the correct directory

Testing Instructions (or ideally a Blueprint)

  1. Run PLAYGROUND_URL=http://localhost:9999 npx nx run playground-website:build:wasm-wordpress-net
  2. Run php -S localhost:9999 -t dist/packages/playground/wasm-wordpress-net
  3. To test with the 6.6 branch use this blueprint pointing to localhost.
  4. To test with trunk, use this blueprint pointing to localhost.

@peterwilsoncc peterwilsoncc added the [Type] Enhancement New feature or request label Aug 25, 2024
@adamziel
Copy link
Collaborator

That's lovely @peterwilsoncc, thank you! I only left a few minor notes.

Hey, @dmsnell @sirreal, you'll like this one! It's one step closer to a ?wordpress-pr=56927 and a corresponding Gutenberg parameter.

@peterwilsoncc
Copy link
Contributor Author

I've renamed the parameter in 7179bf6.

Something that's occurred to me since opening this is that it would be possible to also accept:

  • x.x.x as a tag with some juggling to account for x.x.0
  • [a-f0-9]{7,40} for a specific commit, which might be handy for demonstrating bugs introduced in a specific commit.

Would you like me to add either or both of those?

@adamziel
Copy link
Collaborator

adamziel commented Aug 28, 2024

Would you like me to add either or both of those?

Oh, nice! That would be lovely! I'll merge this PR to make the feature available already, and let's explore that in a follow-up.

@adamziel adamziel merged commit 838e548 into trunk Aug 28, 2024
5 checks passed
@adamziel adamziel deleted the wordpress-branch branch August 28, 2024 14:26
bgrgicak pushed a commit that referenced this pull request Sep 12, 2024
## Motivation for the change, related issues

This extends the allowable resources available via the
`wordpress-branch` query string parameter to include all available
resources.

I've also improved the robustness of the code by getting the location
header from the official URL rather than the destination URL.

Follow up to #1705.

## Implementation details

Which resource to download is determined by the the form the
`wordpress-branch` parameter:

* the HEAD of any branch in the form x.x or x.x-branch,
* a specific tag in the form x.x.x, normalizing the value for major
releases,
* a specific commit in the form [a-z0-9]{7,40}

To allow for the querying of the location header, I've needed to make
the `PluginDownloader::gitHubRequest()` method public. If there is an
alternative approach, please let me know.

## Testing Instructions (or ideally a Blueprint)

In the command line run the following commands:

```
PLAYGROUND_URL=http://localhost:9999 npx nx run playground-website:build:wasm-wordpress-net
php -S localhost:9999 -t dist/packages/playground/wasm-wordpress-net
```

Blueprint configs using the localhost:

*
[trunk](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=trunk%22%7D%7D)
* [HEAD of the 6.6 branch using
`wordpress-branch=6.6`](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=6.6%22%7D%7D)
* [HEAD of the 6.6 branch using
`wordpress-branch=6.6-branch`](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=6.6-branch%22%7D%7D)
* [6.6 major
release](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=6.6.0%22%7D%7D)
* [6.5.2 minor
release](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=6.5.2%22%7D%7D)
*
WordPress/WordPress@b8dbab9
using [the long form
hash](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=b8dbab954688836bafc72457a21300380e96078a%22%7D%7D)
* Above using a [short form
hash](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=b8dbab9546%22%7D%7D)
* [an invalid resource
`puppies-and-kittens`](http://localhost:9999/?#%7B%22$schema%22:%22https://playground.wordpress.net/blueprint-schema.json%22,%22landingPage%22:%22/wp-admin%22,%22login%22:true,%22preferredVersions%22:%7B%22php%22:%227.4%22,%22wp%22:%22http://localhost:9999/plugin-proxy.php?wordpress-branch=puppiesandkittens%22%7D%7D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants