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

Integrate with wp-product-info for plugin updates #179

Merged
merged 54 commits into from
Feb 21, 2024

Conversation

mindctrl
Copy link
Member

@mindctrl mindctrl commented Jan 19, 2024

Description

Adds the functionality required to get plugin update information from WP Engine's wp-product-info service.

Closes #173

Testing

To test the update functionality against the wp-product-info staging environment from your local machine, you can:

  • temporarily adjust the URL in request_plugin_updates() to point to the staging service (https://wp-product-info-staging.wpesvc.net/v1/plugins/wpgraphql-content-blocks).
  • change the version number in the main plugin file to 1.0.0 to mimic being on an older version.

Here's a screenshot of an update notice with this installed. Note: this mimics a semver breaking change, so it shows the warning about breaking changes.

image

To test the pipeline deploy:

Note: the CircleCI pipeline typically only runs when new releases are created in the GitHub repo.

Copy link

changeset-bot bot commented Jan 19, 2024

🦋 Changeset detected

Latest commit: d70b65d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wpengine/wp-graphql-content-blocks Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

*/
function request_plugin_updates( array $args = [] ) {
return wp_remote_get(
'https://wp-product-info.wpesvc.net/v1/plugins/wpgraphql-content-blocks',
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied initial setup from the Atlas Headless Extension plugin.
Our integration with the plugin update mechanism outputs a "active" row
to display errors when communicating with wp-product-info. This class is
used by WP to style the update notices to match the table row.
This library bootstraps itself and there's no need to save to a variable.

Saving to an unused variable causes a phpcs violation.
@mindctrl mindctrl marked this pull request as ready for review February 6, 2024 14:07
@mindctrl mindctrl requested a review from a team as a code owner February 6, 2024 14:07
@mindctrl mindctrl changed the title WIP: Integrate with wp-product-info for plugin updates Integrate with wp-product-info for plugin updates Feb 6, 2024
Revert "chore: update textdomain to wpgraphql-content-blocks"

This reverts commit f615be5.

Revert "chore: update text domain in phpcs config"

This reverts commit 4e94575.

Revert "chore: rename zip artifact in release workflow"

This reverts commit dbc6071.

Revert "chore: rename package name in composer.json"

This reverts commit b230797.

Revert "chore: update plugin directory name in _lib.sh"

This reverts commit 5829908.

Revert "chore: update plugin filename in versionPlugin.js"

This reverts commit 33c3d6e.

Revert "chore: update phpcs config to load renamed plugin file"

This reverts commit 075cf94.

Revert "test: load renamed plugin file when bootstrapping tests"

This reverts commit 1aee962.

Revert "chore: Rename main plugin file."

This reverts commit 2c9bd3d.
Copy link
Contributor

@blakewilson blakewilson left a comment

Choose a reason for hiding this comment

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

@mindctrl Regardless of the testing instructions, at every stage I received the following error:

Screenshot 2024-02-13 at 2 13 55 PM

This happened at all of these stages:

  1. When I first checked out the branch
  2. After I updated the staging link
  3. After I downgraded the version

I made sure to also run composer update and npm install. Am I missing anything else?

Comment on lines 3 to 5
on:
release:
types: [ published ]
Copy link
Contributor

Choose a reason for hiding this comment

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

If I remember correctly, a workflow can not call another workflow without some additional config.

https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow

Since changesets (another workflow) creates our release, I'm not sure this workflow will get triggered. We experienced this before in the faustjs repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

@blakewilson
Copy link
Contributor

blakewilson commented Feb 13, 2024

@mindctrl Regardless of the testing instructions, at every stage I received the following error:

Screenshot 2024-02-13 at 2 13 55 PM

This happened at all of these stages:

  1. When I first checked out the branch
  2. After I updated the staging link
  3. After I downgraded the version

I made sure to also run composer update and npm install. Am I missing anything else?

When I var_dump the $reason in get_api_error_text, I get the following:

Screenshot 2024-02-13 at 2 29 38 PM

@TeresaGobble
Copy link
Contributor

TeresaGobble commented Feb 13, 2024

Hi @mindctrl and @blakewilson, I can confirm that I'm seeing the same, across all testing steps.

image

(The yellow warning box is a symlink tag, and should have that error message at the moment).

Additionally, I interpreted the testing instructions as a change to the endpoint, here:

image

And a change to the version, here:

image

And then rebuilding at the root of the repo. I expected to see the update notice after this- please let me know if I've missed a step!

@mindctrl
Copy link
Member Author

@blakewilson @TeresaGobble thank you for the reviews!

If the plugin tried to communicate with the service before you changed it to the staging URL, the error you see will be cached for 5 minutes in a transient. You can delete this transient manually using the Transients Manager plugin. Activate and go to Tools > Transients.

I'll take another pass through the code and test things, and will take a closer look at the GitHub Action stuff.

@blakewilson
Copy link
Contributor

@blakewilson @TeresaGobble thank you for the reviews!

If the plugin tried to communicate with the service before you changed it to the staging URL, the error you see will be cached for 5 minutes in a transient. You can delete this transient manually using the Transients Manager plugin. Activate and go to Tools > Transients.

I'll take another pass through the code and test things, and will take a closer look at the GitHub Action stuff.

@mindctrl You are right John. After revisiting I can see all is working as expected now!

@TeresaGobble
Copy link
Contributor

Thank you @mindctrl , I can confirm that after deleting the transient that I see the update notice:

image

I want to check in about the pipeline deployment- how can I best support you in catching issues with the pipeline? Everything seems to be working well with your example staging, and I don't immediately see any missing data here.

@blakewilson
Copy link
Contributor

After checking again, I can't seem to see the breaking changes notice. I disabled other plugins, but still cant see it. Oddly, you can see auto updates has been disabled, so that's working properly:

Screenshot 2024-02-14 at 12 06 07 PM

@TeresaGobble
Copy link
Contributor

TeresaGobble commented Feb 14, 2024

@blakewilson , I'm still seeing it- was there a change to something locally? How did you check it during this second peek?

branches:
ignore: /.*/
tags:
only: /^v.*/
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've updated all these to run directly in CircleCI when tags are created, instead of using the GHA to trigger Circle. I ran into some known bugs with the Circle trigger action. This also simplifies things.

Copy link
Contributor

@blakewilson blakewilson left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work @mindctrl

@mindctrl mindctrl merged commit 9fab724 into main Feb 21, 2024
5 of 7 checks passed
@mindctrl mindctrl deleted the issue173/wp-product-info branch February 21, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup Content Block plugin updates through product info service
3 participants