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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3173f28
test: confirm update callbacks are attached
mindctrl Jan 19, 2024
2f40eb6
chore: Add updater functions
mindctrl Jan 19, 2024
e953566
chore: Add updater callbacks
mindctrl Jan 19, 2024
5463dc5
chore: add convenience constants used by updater functionality
mindctrl Jan 19, 2024
c502398
chore: load updater files via require_once
mindctrl Jan 19, 2024
07d61a7
chore: exclude VIP rule for wp_remote_get calls
mindctrl Jan 19, 2024
87296e8
chore: coding standards
mindctrl Jan 19, 2024
6a93b95
chore: add .zipignore
mindctrl Jan 23, 2024
92946da
chore: add base CircleCI config.
mindctrl Jan 23, 2024
209fe59
chore: Remove unused CircleCI config parts
mindctrl Jan 23, 2024
f7a320b
ci: Add GHA_* parameters to CircleCI config
mindctrl Jan 23, 2024
171016b
chore: fix test that checks for active plugin count.
mindctrl Jan 23, 2024
86532aa
chore: Add blakewilson/wp-enforce-semver dependency
mindctrl Jan 26, 2024
ab3b445
chore: Instantiate EnforceSemVer class
mindctrl Jan 26, 2024
46fdd79
chore: Change support link to GitHub issues
mindctrl Jan 29, 2024
f29354a
ci: Add stub for wp-product-info.yml workflow
mindctrl Jan 29, 2024
74c6230
chore: Tell SonarQube to ignore "useless instantiation".
mindctrl Jan 29, 2024
9f39f13
chore: Remove NOSCAN directive in favor of phpcs:ignore.
mindctrl Jan 29, 2024
03dd9e9
ci: Test temporarily removing conditions for deploy workflow
mindctrl Jan 30, 2024
dc037db
ci: download latest release zip
mindctrl Jan 31, 2024
2d13641
ci: adjust unzip command
mindctrl Jan 31, 2024
05d4e8a
ci: adjust unzip paths
mindctrl Jan 31, 2024
e7a601a
ci: adjust paths
mindctrl Jan 31, 2024
2e57369
ci: debug
mindctrl Jan 31, 2024
969b184
ci: add the dash :facepalm:
mindctrl Jan 31, 2024
02defea
ci: mkdir build
mindctrl Jan 31, 2024
90ea24a
ci: update persist path. Add temp debug info.
mindctrl Feb 1, 2024
f2dd398
ci: add temp debug to json job
mindctrl Feb 1, 2024
0896ad7
ci: move zip to build dir for later deployment
mindctrl Feb 1, 2024
8e6bfd8
ci: remove duplicate mkdir
mindctrl Feb 1, 2024
a6747a2
ci: temp remove branch rules on staging deploy
mindctrl Feb 1, 2024
ff7f79e
ci: temp debug post_zip job
mindctrl Feb 1, 2024
ae68f52
ci: adjust slug to match wp-product-info service route
mindctrl Feb 1, 2024
680b10a
ci: add build version to zip file name when moving to build directory
mindctrl Feb 1, 2024
5c64f60
chore: remove debug statements
mindctrl Feb 5, 2024
2c9bd3d
chore: Rename main plugin file.
mindctrl Feb 5, 2024
1aee962
test: load renamed plugin file when bootstrapping tests
mindctrl Feb 5, 2024
075cf94
chore: update phpcs config to load renamed plugin file
mindctrl Feb 5, 2024
5f21816
ci: restore conditional triggers in CircleCI workflow
mindctrl Feb 5, 2024
831ae27
chore: Customize semver notice text.
mindctrl Feb 5, 2024
bb42c8b
test: confirm callback to customize semver notice text is attached.
mindctrl Feb 5, 2024
ed1598e
chore: remove .zipignore.
mindctrl Feb 5, 2024
33c3d6e
chore: update plugin filename in versionPlugin.js
mindctrl Feb 5, 2024
5829908
chore: update plugin directory name in _lib.sh
mindctrl Feb 5, 2024
b230797
chore: rename package name in composer.json
mindctrl Feb 5, 2024
dbc6071
chore: rename zip artifact in release workflow
mindctrl Feb 5, 2024
4e94575
chore: update text domain in phpcs config
mindctrl Feb 5, 2024
f615be5
chore: update textdomain to wpgraphql-content-blocks
mindctrl Feb 5, 2024
c9afb25
chore: temp remove conditional triggers in CircleCI workflow
mindctrl Feb 5, 2024
af7bfb4
ci: restore conditionals in deploy workflow
mindctrl Feb 6, 2024
45aea24
chore: add changeset
mindctrl Feb 6, 2024
dc8dd04
Revert plugin rename.
mindctrl Feb 9, 2024
9c67f57
ci: update CircleCI config to run deploy jobs on tags
mindctrl Feb 21, 2024
d70b65d
chore: remove wp-product-info deploy workflow.
mindctrl Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-geese-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wpengine/wp-graphql-content-blocks": minor
---

Added support for automatic updates hosted from WP Engine infrastructure. Includes warnings when major versions with potential breaking changes are released.
163 changes: 163 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Notes:
# - Jobs initially start from /home/circleci/project
# - Plugin located at /home/circleci/project/wp-graphql-content-blocks

version: 2.1

orbs:
php: circleci/[email protected]
wp-product-orb: wpengine/[email protected]
node: circleci/[email protected]

jobs:
plugin-unzip:
executor: wp-product-orb/default
environment:
WPE_SESSION_DIR: ./.wpe
parameters:
slug:
type: string
filename:
type: string
steps:
- attach_workspace:
at: .
- wp-product-orb/variable_load
- run:
name: "Unzip plugin files"
command: |
cd ~/project
mkdir build
curl -sL https://github.com/wpengine/wp-graphql-content-blocks/releases/latest/download/wp-graphql-content-blocks.zip > <<parameters.slug>>.zip
unzip -o -d <<parameters.slug>> <<parameters.slug>>.zip
ls -laR
- wp-product-orb/get_version_from_php:
filename: <<parameters.slug>>/<<parameters.filename>>
return_var: BUILD_VERSION
- wp-product-orb/variable:
var: BUILD_VERSION
value: $BUILD_VERSION
- run:
name: "Move zip file to build directory"
command: |
mv <<parameters.slug>>.zip build/<<parameters.slug>>.$BUILD_VERSION.zip
- run:
name: "DEBUG"
command: |
ls -laR
- persist_to_workspace:
root: .
paths:
- .

plugin-build-json:
executor: wp-product-orb/parser
environment:
WPE_SESSION_DIR: ./.wpe
parameters:
slug:
type: string
steps:
- attach_workspace:
at: .
- run:
command: |
cd ~/project
- wp-product-orb/variable_load
- wp-product-orb/parse_wp_readme:
infile: <<parameters.slug>>/readme.txt
outfile: build/<<parameters.slug>>.$BUILD_VERSION.json
- store_artifacts:
path: build
- run:
name: "DEBUG"
command: |
pwd
ls -laR
- persist_to_workspace:
root: .
paths:
- build

plugin-deploy:
executor: wp-product-orb/authenticate
environment:
WPE_SESSION_DIR: ./.wpe
parameters:
auth_url:
type: string
upload_url:
type: string
slug:
type: string
steps:
- attach_workspace:
at: .
- wp-product-orb/variable_load
- wp-product-orb/authenticate:
user: WPE_LDAP_USER
pass: WPE_LDAP_PASS
url: <<parameters.auth_url>>
- run:
name: "DEBUG"
command: |
pwd
ls -laR
- wp-product-orb/post_zip:
url: <<parameters.upload_url>>/<<parameters.slug>>
zip: build/<<parameters.slug>>.$BUILD_VERSION.zip
json: build/<<parameters.slug>>.$BUILD_VERSION.json
version: $BUILD_VERSION

workflows:
deploy:
jobs:
- plugin-unzip:
slug: wpgraphql-content-blocks
filename: wp-graphql-content-blocks.php
# Run this job when a tag is published.
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
Copy link
Contributor 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.

- plugin-build-json:
slug: wpgraphql-content-blocks
requires:
- plugin-unzip
# Run this job when a tag is published.
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- plugin-deploy:
name: "plugin-deploy-staging"
slug: wpgraphql-content-blocks
requires:
- plugin-unzip
- plugin-build-json
filters:
branches:
only:
- main
- canary
tags:
only: /^v.*/
context: wpe-ldap-creds
auth_url: https://auth-staging.wpengine.io/v1/tokens
upload_url: https://wp-product-info-staging.wpesvc.net/v1/plugins
- plugin-deploy:
name: "plugin-deploy-production"
slug: wp-graphql-content-blocks
requires:
- "plugin-deploy-staging"
filters:
branches:
ignore: /.*/
tags:
# Run this job when a tag is published.
only: /^v.*/
context: wpe-ldap-creds
auth_url: https://auth.wpengine.io/v1/tokens
upload_url: https://wp-product-info.wpesvc.net/v1/plugins
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint" />
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get" />
</rule>

<!-- Individual rule configuration -->
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"minimum-stability": "dev",
"require": {
"php": ">=7.4",
"imangazaliev/didom": "^2.0"
"imangazaliev/didom": "^2.0",
"blakewilson/wp-enforce-semver": "^2.0"
},
"require-dev": {
"brain/monkey": "^2.6",
Expand Down
108 changes: 106 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions includes/WPGraphQLContentBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ static function () {
}//end if
}//end if

require_once WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_DIR . 'includes/updates/update-functions.php';
require_once WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_DIR . 'includes/updates/update-callbacks.php';

// phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable -- Library bootstraps itself, hence variable is unused.
$semver = new \EnforceSemVer\EnforceSemVer( WPGRAPHQL_CONTENT_BLOCKS_PATH );
mindctrl marked this conversation as resolved.
Show resolved Hide resolved

return true;
}

Expand Down
Loading
Loading