From ea1c9aa7f6dd5011ac7c46880b6a9a0b46b17882 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Tue, 20 Feb 2024 21:17:16 +0300 Subject: [PATCH 01/11] Generated package skeleton. --- projects/plugins/wpcomsh/.gitattributes | 15 ++++ projects/plugins/wpcomsh/.gitignore | 2 + projects/plugins/wpcomsh/CHANGELOG.md | 7 ++ projects/plugins/wpcomsh/README.md | 24 +++++++ projects/plugins/wpcomsh/README.txt | 68 +++++++++++++++++++ projects/plugins/wpcomsh/changelog/.gitkeep | 0 .../plugins/wpcomsh/changelog/initial-version | 4 ++ projects/plugins/wpcomsh/composer.json | 51 ++++++++++++++ projects/plugins/wpcomsh/package.json | 25 +++++++ projects/plugins/wpcomsh/phpunit.xml.dist | 14 ++++ projects/plugins/wpcomsh/readme.txt | 56 +++++++++++++++ projects/plugins/wpcomsh/src/example.php | 8 +++ projects/plugins/wpcomsh/tests/.phpcs.dir.xml | 4 ++ .../plugins/wpcomsh/tests/php/bootstrap.php | 11 +++ projects/plugins/wpcomsh/wpcomsh.php | 16 +++++ 15 files changed, 305 insertions(+) create mode 100644 projects/plugins/wpcomsh/.gitattributes create mode 100644 projects/plugins/wpcomsh/.gitignore create mode 100644 projects/plugins/wpcomsh/CHANGELOG.md create mode 100644 projects/plugins/wpcomsh/README.md create mode 100644 projects/plugins/wpcomsh/README.txt create mode 100644 projects/plugins/wpcomsh/changelog/.gitkeep create mode 100644 projects/plugins/wpcomsh/changelog/initial-version create mode 100644 projects/plugins/wpcomsh/composer.json create mode 100644 projects/plugins/wpcomsh/package.json create mode 100644 projects/plugins/wpcomsh/phpunit.xml.dist create mode 100644 projects/plugins/wpcomsh/readme.txt create mode 100644 projects/plugins/wpcomsh/src/example.php create mode 100644 projects/plugins/wpcomsh/tests/.phpcs.dir.xml create mode 100644 projects/plugins/wpcomsh/tests/php/bootstrap.php create mode 100644 projects/plugins/wpcomsh/wpcomsh.php diff --git a/projects/plugins/wpcomsh/.gitattributes b/projects/plugins/wpcomsh/.gitattributes new file mode 100644 index 0000000000000..dd08c5ac8f82f --- /dev/null +++ b/projects/plugins/wpcomsh/.gitattributes @@ -0,0 +1,15 @@ +# Files not needed to be distributed in the package. +.gitattributes export-ignore +.github/ export-ignore +package.json export-ignore + +# Files to include in the mirror repo, but excluded via gitignore +# Remember to end all directories with `/**` to properly tag every file. +# /src/js/example.min.js production-include + +# Files to exclude from the mirror repo, but included in the monorepo. +# Remember to end all directories with `/**` to properly tag every file. +.gitignore production-exclude +changelog/** production-exclude +phpunit.xml.dist production-exclude +tests/** production-exclude diff --git a/projects/plugins/wpcomsh/.gitignore b/projects/plugins/wpcomsh/.gitignore new file mode 100644 index 0000000000000..140fd587d2d52 --- /dev/null +++ b/projects/plugins/wpcomsh/.gitignore @@ -0,0 +1,2 @@ +vendor/ +node_modules/ diff --git a/projects/plugins/wpcomsh/CHANGELOG.md b/projects/plugins/wpcomsh/CHANGELOG.md new file mode 100644 index 0000000000000..721294abd00ad --- /dev/null +++ b/projects/plugins/wpcomsh/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + diff --git a/projects/plugins/wpcomsh/README.md b/projects/plugins/wpcomsh/README.md new file mode 100644 index 0000000000000..a0581cbc27e8d --- /dev/null +++ b/projects/plugins/wpcomsh/README.md @@ -0,0 +1,24 @@ +# wpcomsh + +A helper for connecting WordPress.com sites to external host infrastructure. + +## How to install wpcomsh + +### Installation From Git Repo + +## Contribute + +## Get Help + +## Using this package in your WordPress plugin + +If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well. + +## Security + +Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic). + +## License + +wpcomsh is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt) + diff --git a/projects/plugins/wpcomsh/README.txt b/projects/plugins/wpcomsh/README.txt new file mode 100644 index 0000000000000..78bedd8c1d815 --- /dev/null +++ b/projects/plugins/wpcomsh/README.txt @@ -0,0 +1,68 @@ +=== Jetpack wpcomsh === +Contributors: automattic, +Tags: jetpack, stuff +Requires at least: 6.3 +Requires PHP: 7.0 +Tested up to: 6.4 +Stable tag: 3.14.40 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +A helper for connecting WordPress.com sites to external host infrastructure. + +== Description == + +Longer description of the plugin. + +== Installation == + +Installation instructions go here. + +== Frequently Asked Questions == + += A question that someone might have = + +An answer to that question. + +== Screenshots == + +1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from +the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets +directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` +(or jpg, jpeg, gif). +2. This is the second screen shot + +== Changelog == + + + +== Arbitrary section == + +You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated +plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or +"installation." Arbitrary sections will be shown below the built-in sections outlined above. + +== A brief Markdown Example == + +Ordered list: + +1. Some feature +1. Another feature +1. Something else about the plugin + +Unordered list: + +* something +* something else +* third thing + +Here's a link to [WordPress](https://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. +Titles are optional, naturally. + +[markdown syntax]: http://daringfireball.net/projects/markdown/syntax +"Markdown is what the parser uses to process much of the readme file" + +Markdown uses email style notation for blockquotes and I've been told: +> Asterisks for *emphasis*. Double it up for **strong**. + +`` diff --git a/projects/plugins/wpcomsh/changelog/.gitkeep b/projects/plugins/wpcomsh/changelog/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/projects/plugins/wpcomsh/changelog/initial-version b/projects/plugins/wpcomsh/changelog/initial-version new file mode 100644 index 0000000000000..fb1837c901e51 --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/initial-version @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Initial version. diff --git a/projects/plugins/wpcomsh/composer.json b/projects/plugins/wpcomsh/composer.json new file mode 100644 index 0000000000000..755bb2799f9db --- /dev/null +++ b/projects/plugins/wpcomsh/composer.json @@ -0,0 +1,51 @@ +{ + "name": "automattic/jetpack-wpcomsh", + "description": "A helper for connecting WordPress.com sites to external host infrastructure.", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "require": {}, + "require-dev": { + "yoast/phpunit-polyfills": "1.1.0", + "automattic/jetpack-changelogger": "@dev", + "automattic/wordbless": "dev-master" + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "phpunit": [ + "./vendor/phpunit/phpunit/phpunit --colors=always" + ], + "test-php": [ + "@composer phpunit" + ], + "build-production": "echo 'Add your build step to composer.json, please!'", + "build-development": "echo 'Add your build step to composer.json, please!'", + "post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy", + "post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy" + }, + "repositories": [ + { + "type": "path", + "url": "../../packages/*", + "options": { + "monorepo": true + } + } + ], + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "allow-plugins": { + "roots/wordpress-core-installer": true + } + }, + "extra": { + "release-branch-prefix": "wpcomsh", + "changelogger": { + "versioning": "semver" + } + } +} diff --git a/projects/plugins/wpcomsh/package.json b/projects/plugins/wpcomsh/package.json new file mode 100644 index 0000000000000..c6ff4b9f3e893 --- /dev/null +++ b/projects/plugins/wpcomsh/package.json @@ -0,0 +1,25 @@ +{ + "private": true, + "name": "@automattic/jetpack-wpcomsh", + "version": "0.1.0-alpha", + "description": "A helper for connecting WordPress.com sites to external host infrastructure.", + "homepage": "https://jetpack.com", + "bugs": { + "url": "https://github.com/Automattic/jetpack/labels/[Plugin] Wpcomsh" + }, + "repository": { + "type": "git", + "url": "https://github.com/Automattic/jetpack.git", + "directory": "projects/plugins/wpcomsh" + }, + "license": "GPL-2.0-or-later", + "author": "Automattic", + "scripts": { + "build": "echo 'Not implemented.'", + "build-js": "echo 'Not implemented.'", + "build-production": "echo 'Not implemented.'", + "build-production-js": "echo 'Not implemented.'", + "clean": "true" + }, + "devDependencies": {} +} diff --git a/projects/plugins/wpcomsh/phpunit.xml.dist b/projects/plugins/wpcomsh/phpunit.xml.dist new file mode 100644 index 0000000000000..3223c32458db2 --- /dev/null +++ b/projects/plugins/wpcomsh/phpunit.xml.dist @@ -0,0 +1,14 @@ + + + + tests/php + + + + + + + src + + + diff --git a/projects/plugins/wpcomsh/readme.txt b/projects/plugins/wpcomsh/readme.txt new file mode 100644 index 0000000000000..2174864a9ad17 --- /dev/null +++ b/projects/plugins/wpcomsh/readme.txt @@ -0,0 +1,56 @@ +== Description == + +Longer description of the plugin. + +== Installation == + +Installation instructions go here. + +== Frequently Asked Questions == + += A question that someone might have = + +An answer to that question. + +== Screenshots == + +1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from +the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets +directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` +(or jpg, jpeg, gif). +2. This is the second screen shot + +== Changelog == + + + +== Arbitrary section == + +You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated +plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or +"installation." Arbitrary sections will be shown below the built-in sections outlined above. + +== A brief Markdown Example == + +Ordered list: + +1. Some feature +1. Another feature +1. Something else about the plugin + +Unordered list: + +* something +* something else +* third thing + +Here's a link to [WordPress](https://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. +Titles are optional, naturally. + +[markdown syntax]: http://daringfireball.net/projects/markdown/syntax +"Markdown is what the parser uses to process much of the readme file" + +Markdown uses email style notation for blockquotes and I've been told: +> Asterisks for *emphasis*. Double it up for **strong**. + +`` diff --git a/projects/plugins/wpcomsh/src/example.php b/projects/plugins/wpcomsh/src/example.php new file mode 100644 index 0000000000000..a788a63305dc4 --- /dev/null +++ b/projects/plugins/wpcomsh/src/example.php @@ -0,0 +1,8 @@ + + + + diff --git a/projects/plugins/wpcomsh/tests/php/bootstrap.php b/projects/plugins/wpcomsh/tests/php/bootstrap.php new file mode 100644 index 0000000000000..46763b04a2cdb --- /dev/null +++ b/projects/plugins/wpcomsh/tests/php/bootstrap.php @@ -0,0 +1,11 @@ + Date: Tue, 20 Feb 2024 21:59:46 +0300 Subject: [PATCH 02/11] Added the first file. --- projects/plugins/wpcomsh/src/wpcomsh.php | 636 +++++++++++++++++++++++ 1 file changed, 636 insertions(+) create mode 100644 projects/plugins/wpcomsh/src/wpcomsh.php diff --git a/projects/plugins/wpcomsh/src/wpcomsh.php b/projects/plugins/wpcomsh/src/wpcomsh.php new file mode 100644 index 0000000000000..56b78e7c23814 --- /dev/null +++ b/projects/plugins/wpcomsh/src/wpcomsh.php @@ -0,0 +1,636 @@ +,
,  and 
+	// use 
in support docs where linkifying + // breaks shortcodes, etc. + $_split = preg_split( '/(<[^<>]+>)/i', $content, -1, PREG_SPLIT_DELIM_CAPTURE ); + $end = ''; + $out = ''; + $combine = ''; + $split = array(); + + // Defines a set of rules for the wpcomsh_make_content_clickable() function to ignore matching html elements. + $make_clickable_rules = array( + array( + 'match' => array( ' '', + ), + array( + 'match' => array( '
' ),
+			'end'   => '
', + ), + array( + 'match' => array( '' ), + 'end' => '', + ), + array( + 'match' => array( '', + ), + array( + 'match' => array( '', + ), + array( + 'match' => array( '', + ), + array( + 'match' => array( '
' === $chunk[ strlen( $chunk ) - 1 ] ) ) { + $out .= $chunk; + continue; + } + + // three strpos() are faster than one preg_match() here. If we need to check for more protocols, preg_match() would probably be better. + if ( strpos( $chunk, 'http://' ) !== false || strpos( $chunk, 'https://' ) !== false || strpos( $chunk, 'www.' ) !== false ) { + // looks like there is a plain-text url. + $out .= make_clickable( $chunk ); + } else { + $out .= $chunk; + } + } + + return $out; +} +add_filter( 'the_content', 'wpcomsh_make_content_clickable', 120 ); +add_filter( 'the_excerpt', 'wpcomsh_make_content_clickable', 120 ); + +/** + * Hide scan threats from transients + * + * @param mixed $response The response. + * + * @return mixed + */ +function wpcomsh_hide_scan_threats_from_transients( $response ) { + if ( ! empty( $response->threats ) ) { + $response->threats = array(); + } + return $response; +} +add_filter( 'transient_jetpack_scan_state', 'wpcomsh_hide_scan_threats_from_transients' ); + +/** + * Hide scan threats from api + * + * @param mixed $response The reponse. + * + * @return mixed + */ +function wpcom_hide_scan_threats_from_api( $response ) { + if ( + ! ( $response instanceof WP_REST_Response ) + || $response->get_matched_route() !== '/jetpack/v4/scan' + ) { + return $response; + } + $response_data = $response->get_data(); + if ( empty( $response_data['data'] ) || ! is_string( $response_data['data'] ) ) { + return $response; + } + + $json_body = json_decode( $response_data['data'], true ); + if ( null === $json_body || empty( $json_body['threats'] ) ) { + return $response; + } + + $json_body['threats'] = array(); + $response_data['data'] = wp_json_encode( $json_body ); + $response->set_data( $response_data ); + + return $response; +} +add_filter( 'rest_post_dispatch', 'wpcom_hide_scan_threats_from_api' ); + +/** + * Collect RUM performance data + * + * @see p9o2xV-XY-p2 + */ +function wpcomsh_footer_rum_js() { + $service = 'atomic'; + $allow_iframe = ''; + if ( 'admin_footer' === current_action() ) { + $service = 'atomic-wpadmin'; + + if ( method_exists( 'Jetpack_WPCOM_Block_Editor', 'init' ) ) { + $block_editor = Jetpack_WPCOM_Block_Editor::init(); + if ( $block_editor->is_iframed_block_editor() ) { + $service = 'atomic-gutenframe'; + $allow_iframe = 'data-allow-iframe="true"'; + } + } + } + + printf( + '' . "\n", //phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + esc_attr( $service ), + wp_kses_post( $allow_iframe ), + esc_url( 'https://s0.wp.com/wp-content/js/bilmur.min.js?m=' . gmdate( 'YW' ) ) + ); +} +add_action( 'wp_footer', 'wpcomsh_footer_rum_js' ); +add_action( 'admin_footer', 'wpcomsh_footer_rum_js' ); + +add_filter( 'amp_dev_tools_user_default_enabled', '__return_false' ); + +/** + * Tracks helper. Filters Jetpack TOS option if class exists. + * + * @param mixed $event The event. + * @param mixed $event_properties The event property. + * + * @return void + */ +function wpcomsh_record_tracks_event( $event, $event_properties ) { + if ( class_exists( '\Automattic\Jetpack\Tracking' ) ) { + // User has to agree to ToS for tracking. Thing is, on initial Simple -> Atomic we never set the ToS option. + // And since they agreed to WP.com ToS, we can track but in a roundabout way. :). + add_filter( 'jetpack_options', 'wpcomsh_jetpack_filter_tos_for_tracking', 10, 2 ); + + $jetpack_tracks = new \Automattic\Jetpack\Tracking( 'atomic' ); + $jetpack_tracks->tracks_record_event( + wp_get_current_user(), + $event, + $event_properties + ); + + remove_filter( 'jetpack_options', 'wpcomsh_jetpack_filter_tos_for_tracking', 10 ); + } +} + +/** + * Helper for filtering tos_agreed for tracking purposes. + * Explicit function so it can be removed afterwards. + * + * @param mixed $value The value. + * @param mixed $name Name. + * + * @return mixed + */ +function wpcomsh_jetpack_filter_tos_for_tracking( $value, $name ) { + if ( 'tos_agreed' === $name ) { + return true; + } + + return $value; +} + +/** + * Avoid proxied v2 banner + * + * @return void + */ +function wpcomsh_avoid_proxied_v2_banner() { + $priority = has_action( 'wp_footer', 'atomic_proxy_bar' ); + if ( false !== $priority ) { + remove_action( 'wp_footer', 'atomic_proxy_bar', $priority ); + } + + $priority = has_action( 'admin_footer', 'atomic_proxy_bar' ); + if ( false !== $priority ) { + remove_action( 'admin_footer', 'atomic_proxy_bar', $priority ); + } +} + +// We don't want to show a "PROXIED V2" banner for legacy widget previews +// which are normally embedded within another page. +if ( + defined( 'AT_PROXIED_REQUEST' ) && AT_PROXIED_REQUEST && + isset( $_GET['legacy-widget-preview'] ) && //phpcs:ignore WordPress.Security.NonceVerification + 0 === strncmp( $_SERVER['REQUEST_URI'], '/wp-admin/widgets.php?', strlen( '/wp-admin/widgets.php?' ) ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput + add_action( 'plugins_loaded', 'wpcomsh_avoid_proxied_v2_banner' ); +} + +// Temporary feature flag for the new Reading Settings page. +add_filter( 'calypso_use_modernized_reading_settings', '__return_true' ); + +/** + * Temporary feature flags for the new Newsletter and podcasting Settings pages, + * its removal should be preceded by a removal of the filter's usage in Jetpack: https://github.com/Automattic/jetpack/pull/32146 + */ +add_filter( 'calypso_use_newsletter_settings', '__return_true' ); +add_filter( 'calypso_use_podcasting_settings', '__return_true' ); From f735c3d96750bafb9d302f2640d596ac4c38da2f Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Tue, 20 Feb 2024 22:02:03 +0300 Subject: [PATCH 03/11] Removed a duplicate README file. --- projects/plugins/wpcomsh/README.txt | 68 ----------------------------- 1 file changed, 68 deletions(-) delete mode 100644 projects/plugins/wpcomsh/README.txt diff --git a/projects/plugins/wpcomsh/README.txt b/projects/plugins/wpcomsh/README.txt deleted file mode 100644 index 78bedd8c1d815..0000000000000 --- a/projects/plugins/wpcomsh/README.txt +++ /dev/null @@ -1,68 +0,0 @@ -=== Jetpack wpcomsh === -Contributors: automattic, -Tags: jetpack, stuff -Requires at least: 6.3 -Requires PHP: 7.0 -Tested up to: 6.4 -Stable tag: 3.14.40 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html - -A helper for connecting WordPress.com sites to external host infrastructure. - -== Description == - -Longer description of the plugin. - -== Installation == - -Installation instructions go here. - -== Frequently Asked Questions == - -= A question that someone might have = - -An answer to that question. - -== Screenshots == - -1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from -the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets -directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` -(or jpg, jpeg, gif). -2. This is the second screen shot - -== Changelog == - - - -== Arbitrary section == - -You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated -plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or -"installation." Arbitrary sections will be shown below the built-in sections outlined above. - -== A brief Markdown Example == - -Ordered list: - -1. Some feature -1. Another feature -1. Something else about the plugin - -Unordered list: - -* something -* something else -* third thing - -Here's a link to [WordPress](https://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. -Titles are optional, naturally. - -[markdown syntax]: http://daringfireball.net/projects/markdown/syntax -"Markdown is what the parser uses to process much of the readme file" - -Markdown uses email style notation for blockquotes and I've been told: -> Asterisks for *emphasis*. Double it up for **strong**. - -`` From f0ca11068d3f79b1c310b8047a22beae34b26bd0 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 15:30:26 +0300 Subject: [PATCH 04/11] Adding wpcomsh matrix entry. --- .github/files/generate-ci-matrix.php | 10 ++++++++++ .github/files/setup-wordpress-env.sh | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/.github/files/generate-ci-matrix.php b/.github/files/generate-ci-matrix.php index c9e6348c1fe3b..9d7cf307c8502 100755 --- a/.github/files/generate-ci-matrix.php +++ b/.github/files/generate-ci-matrix.php @@ -89,6 +89,16 @@ 'with-woocommerce' => true, ); +// Add WooCommerce tests. +$matrix[] = array( + 'name' => 'PHP tests: PHP 7.4 WP latest with WPCOMSH', + 'script' => 'test-php', + 'php' => '8.1', + 'wp' => 'latest', + 'timeout' => 20, + 'with-wpcomsh' => true, +); + // Add JS tests. $matrix[] = array( 'name' => 'JS tests', diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index 6505d513beeca..4254c3600c3db 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -160,6 +160,16 @@ if [[ "$WITH_WOOCOMMERCE" == true ]]; then echo "::endgroup::" fi +# Install WooCommerce plugin used for some Jetpack integration tests. +if [[ "$WITH_WPCOMSH" == true ]]; then + echo "::group::Installing wpcomsh into WordPress" + + mkdir "wordpress-$WP_BRANCH/src/wp-content/mu-plugins" + cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh" + + echo "::endgroup::" +fi + cd "/tmp/wordpress-$WP_BRANCH" cp wp-tests-config-sample.php wp-tests-config.php From 8b34e4340a81e3ee0cb99b0acc276e5d83269f89 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 15:45:05 +0300 Subject: [PATCH 05/11] Adding the wpcomsh matrix value to the environment. --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 827759b29a3ce..6a44e48659af7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,6 +46,7 @@ jobs: NODE_VERSION: ${{ matrix.node }} MONOREPO_BASE: ${{ github.workspace }} WITH_WOOCOMMERCE: ${{ matrix.with-woocommerce }} + WITH_WPCOMSH: ${{ matrix.with-wpcomsh }} strategy: fail-fast: false matrix: From 34adcfbae49259f3aafa8e2e040001ea26684635 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 16:05:00 +0300 Subject: [PATCH 06/11] Fixed the directory. --- .github/files/setup-wordpress-env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index 4254c3600c3db..2f5cd004c5435 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -164,8 +164,8 @@ fi if [[ "$WITH_WPCOMSH" == true ]]; then echo "::group::Installing wpcomsh into WordPress" - mkdir "wordpress-$WP_BRANCH/src/wp-content/mu-plugins" - cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh" + mkdir "$WORDPRESS_DIR/wp-content/mu-plugins" + cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "$WORDPRESS_DIR/wp-content/plugins/wpcomsh" echo "::endgroup::" fi From edc9fea329d29a3a97ef7281a0df956bf54888c3 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 16:17:36 +0300 Subject: [PATCH 07/11] Using the branch env variable instead. --- .github/files/setup-wordpress-env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index 2f5cd004c5435..238fc7941abe6 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -164,8 +164,8 @@ fi if [[ "$WITH_WPCOMSH" == true ]]; then echo "::group::Installing wpcomsh into WordPress" - mkdir "$WORDPRESS_DIR/wp-content/mu-plugins" - cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "$WORDPRESS_DIR/wp-content/plugins/wpcomsh" + mkdir "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins" + cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh" echo "::endgroup::" fi From 5fe70d5900fba1e956a78d8073360d5473a21c54 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 20:11:44 +0300 Subject: [PATCH 08/11] Adding wpcomsh loading. --- projects/plugins/jetpack/tests/action-test-php.sh | 4 ++++ projects/plugins/jetpack/tests/php/bootstrap.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/projects/plugins/jetpack/tests/action-test-php.sh b/projects/plugins/jetpack/tests/action-test-php.sh index 1c67dbe5573a7..eb82fd51d98cd 100755 --- a/projects/plugins/jetpack/tests/action-test-php.sh +++ b/projects/plugins/jetpack/tests/action-test-php.sh @@ -11,6 +11,10 @@ if [[ "$WITH_WOOCOMMERCE" == true ]]; then exit 0 fi +if [[ "$WITH_WPCOMSH" == true ]]; then + export JETPACK_TEST_WPCOMSH=1 +fi + echo "::group::Jetpack tests" phpunit echo "::endgroup::" diff --git a/projects/plugins/jetpack/tests/php/bootstrap.php b/projects/plugins/jetpack/tests/php/bootstrap.php index 3188c189025ae..af94e3d8058df 100644 --- a/projects/plugins/jetpack/tests/php/bootstrap.php +++ b/projects/plugins/jetpack/tests/php/bootstrap.php @@ -95,6 +95,10 @@ function _manually_load_plugin() { if ( '1' === getenv( 'JETPACK_TEST_WOOCOMMERCE' ) ) { require JETPACK_WOOCOMMERCE_INSTALL_DIR . '/woocommerce.php'; } + + if ( '1' === getenv( 'JETPACK_TEST_WPCOMSH' ) ) { + require __DIR__ . '/../../../../mu-plugins/wpcomsh.php'; + } require __DIR__ . '/../../jetpack.php'; $jetpack = Jetpack::init(); $jetpack->configure(); From 780f9d5c36bc192db424612f3a4445c6ed4c6f42 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 20:19:08 +0300 Subject: [PATCH 09/11] changelog --- projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci diff --git a/projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci b/projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci new file mode 100644 index 0000000000000..bfa76cda3e850 --- /dev/null +++ b/projects/plugins/jetpack/changelog/try-wpcomsh-skeleton-ci @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Added ability to test Jetpack together with wpcomsh. From b97785eb0b5db440acae127972075385a8a6013c Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 21:21:49 +0300 Subject: [PATCH 10/11] Properly copy the plugin contents to mu-plugins. --- .github/files/setup-wordpress-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index 238fc7941abe6..0824af412333d 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -165,7 +165,7 @@ if [[ "$WITH_WPCOMSH" == true ]]; then echo "::group::Installing wpcomsh into WordPress" mkdir "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins" - cp -r "$MONOREPO_BASE/projects/plugins/wpcomsh/src" "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh" + cp -r "/tmp/wordpress-$WP_BRANCH/src/wp-content/plugins/wpcomsh/src" "/tmp/wordpress-$WP_BRANCH/src/wp-content/mu-plugins/wpcomsh" echo "::endgroup::" fi From e7a7bef6652593aa1b4d5b725477c20c874c372e Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Wed, 21 Feb 2024 21:58:45 +0300 Subject: [PATCH 11/11] Require the correct path. --- projects/plugins/jetpack/tests/php/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/tests/php/bootstrap.php b/projects/plugins/jetpack/tests/php/bootstrap.php index af94e3d8058df..10a013e85e858 100644 --- a/projects/plugins/jetpack/tests/php/bootstrap.php +++ b/projects/plugins/jetpack/tests/php/bootstrap.php @@ -97,7 +97,7 @@ function _manually_load_plugin() { } if ( '1' === getenv( 'JETPACK_TEST_WPCOMSH' ) ) { - require __DIR__ . '/../../../../mu-plugins/wpcomsh.php'; + require __DIR__ . '/../../../../mu-plugins/wpcomsh/wpcomsh.php'; } require __DIR__ . '/../../jetpack.php'; $jetpack = Jetpack::init();