Skip to content

Commit

Permalink
Merge pull request #2401 from woocommerce/release/2.7.0
Browse files Browse the repository at this point in the history
Release 2.7.0
  • Loading branch information
puntope authored May 14, 2024
2 parents 9dfd3f4 + b9548fa commit 8d0906a
Show file tree
Hide file tree
Showing 52 changed files with 797 additions and 701 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ jobs:
- name: Prepare BundleWatch env values - pull request
if: ${{ github.event_name == 'pull_request' }}
env:
HEAD_REF: ${{ github.head_ref }}
run: |
echo "CI_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "CI_BRANCH=${HEAD_REF}" >> $GITHUB_ENV
echo "CI_BRANCH_BASE=${{ github.base_ref }}" >> $GITHUB_ENV
echo "CI_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ jobs:

- name: Install WP release candidate (optional)
if: github.event.inputs.wp-rc-version != ''
env:
INPUT_WP_RC_VERSION: ${{ github.event.inputs.wp-rc-version }}
run: |
npm run -- wp-env run tests-cli -- wp core update --version=${{ github.event.inputs.wp-rc-version }}
npm run -- wp-env run tests-cli -- wp core update --version="${INPUT_WP_RC_VERSION}"
npm run -- wp-env run tests-cli -- wp core update-db
- name: Install WC release candidate (optional)
if: github.event.inputs.wc-rc-version != ''
env:
INPUT_WC_RC_VERSION: ${{ github.event.inputs.wc-rc-version }}
run: |
npm run -- wp-env run tests-cli -- wp plugin update woocommerce --version=${{ github.event.inputs.wc-rc-version }}
npm run -- wp-env run tests-cli -- wp plugin update woocommerce --version="${INPUT_WC_RC_VERSION}"
npm run -- wp-env run tests-cli -- wp wc update
- name: Download and install Chromium browser.
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/php-hook-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
source-directories: src/,views/,google-listings-and-ads.php,uninstall.php

- name: Commit hook documentation
env:
HEAD_REF: ${{ github.head_ref }}
shell: bash
# Use the github-actions bot account to commit.
# https://api.github.com/users/github-actions%5Bbot%5D
Expand All @@ -43,6 +45,6 @@ jobs:
echo "*No documentation changes to commit.*" >> $GITHUB_STEP_SUMMARY
else
echo "*Committing documentation changes.*" >> $GITHUB_STEP_SUMMARY
git commit -q -m "Update hooks documentation from ${{ github.head_ref }} branch."
git commit -q -m "Update hooks documentation from ${HEAD_REF} branch."
git push
fi
5 changes: 4 additions & 1 deletion .github/workflows/php-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ jobs:
uses: woocommerce/grow/prepare-mysql@actions-v1

- name: Install WP tests
run: ./bin/install-wp-tests.sh wordpress_test root root localhost ${{ inputs.wp-rc-version }} ${{ inputs.wc-rc-version }}
env:
INPUT_WP_RC_VERSION: ${{ inputs.wp-rc-version }}
INPUT_WC_RC_VERSION: ${{ inputs.wc-rc-version }}
run: ./bin/install-wp-tests.sh wordpress_test root root localhost "${INPUT_WP_RC_VERSION}" "${INPUT_WC_RC_VERSION}"

- name: Run PHP unit tests
run: composer test-unit
Expand Down
1 change: 0 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"phpVersion": "8.0",
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip",
"https://github.com/WP-API/Basic-Auth/archive/master.zip",
"./tests/e2e/test-data",
"./tests/e2e/test-snippets",
Expand Down
57 changes: 49 additions & 8 deletions bin/GoogleAdsCleanupServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GoogleAdsCleanupServices {
*
* @var string
*/
protected $version = 'V14';
protected $version = 'V16';

/**
* @var Event Composer event.
Expand All @@ -48,11 +48,18 @@ class GoogleAdsCleanupServices {
*/
protected $code_path = null;

/**
* @var string[] List of Service to NOT remove even when usage is not found.
*/
protected $avoid_cleanup = [
'ExtensionFeedItem',
];

/**
* Constructor.
*
* @param Event|null $event Composer event.
* @param string|null $path Path of the Ads library.
* @param string|null $path Path of the Ads library.
*/
public function __construct( Event $event = null, string $path = null ) {
$this->event = $event;
Expand Down Expand Up @@ -92,7 +99,10 @@ protected function remove_services() {
$used = array_unique(
array_merge(
$this->find_used_pattern(
"use Google\\\\Ads\\\\GoogleAds\\\\{$this->version}\\\\Services\\\\([A-Za-z0-9]+)ServiceClient;"
"use Google\\\\Ads\\\\GoogleAds\\\\{$this->version}\\\\Services\\\\Client\\\\([A-Za-z0-9]+)ServiceClient;"
),
$this->find_used_pattern(
"use Google\\\\Ads\\\\GoogleAds\\\\{$this->version}\\\\Services\\\\([A-Za-z0-9]+);"
),
$this->find_used_pattern(
"use Google\\\\Ads\\\\GoogleAds\\\\{$this->version}\\\\Resources\\\\([A-Za-z0-9]+);"
Expand All @@ -111,6 +121,11 @@ protected function remove_services() {
* @param string $service Service name.
*/
protected function remove_service( string $service ) {
if ( in_array( $service, $this->avoid_cleanup, true ) ) {
$this->output_text( "Skip Removing service {$service}" );
return;
}

$this->output_text( "Removing service {$service}" );
$this->src_path = '/src/Google/Ads/GoogleAds';

Expand Down Expand Up @@ -185,8 +200,9 @@ protected function remove_enum( string $enum_name ) {
/**
* Find a list of files in a path, including subdirectories, matching a pattern.
*
* @param string $path Package path
* @param string $path Package path
* @param string $pattern Regex pattern to match
*
* @return array Matching files
*/
protected function get_dir_contents( $path, $pattern ) {
Expand Down Expand Up @@ -243,7 +259,7 @@ protected function find_used_pattern( string $pattern ): array {
* Find a specific filename pattern within the library.
*
* @param string $pattern Regexp pattern to match.
* @param string|null $suffix Suffix to remove from filename.
* @param string|null $suffix Suffix to remove from filename.
*
* @return array List of matched names.
*/
Expand All @@ -257,6 +273,7 @@ protected function find_library_file_pattern( string $pattern, string $suffix =
return array_map(
function ( $file ) use ( $suffix ) {
$name = pathinfo( $file, PATHINFO_FILENAME );

return $suffix ? $this->remove_suffix( $suffix, $name ) : $name;
},
$output
Expand All @@ -267,7 +284,7 @@ function ( $file ) use ( $suffix ) {
* Optionally remove a suffix from a string.
*
* @param string $suffix Suffix to remove.
* @param string $text Text to remove the suffix from.
* @param string $text Text to remove the suffix from.
*
* @return string
*/
Expand All @@ -282,7 +299,7 @@ protected function remove_suffix( string $suffix, string $text ): string {
* @param string $name
*/
protected function remove_use_statement( string $file, string $name ) {
$pattern = '/\s*use\s+[\w\d\\\]+' . preg_quote( $name, '/' ) . ';/';
$pattern = '/\s*use\s+[\w\d\\\]+\\\{1}' . preg_quote( $name, '/' ) . ';/';
$this->remove_pattern( $file, $pattern );
}

Expand All @@ -296,6 +313,7 @@ protected function remove_function( string $file, string $name ) {
$file = $this->file_path( $file );
if ( ! file_exists( $file ) ) {
$this->warning( sprintf( 'File does not exist: %s', $file ) );

return;
}

Expand All @@ -304,6 +322,7 @@ protected function remove_function( string $file, string $name ) {
$pattern = '/function ' . preg_quote( $name, '/' ) . '\(/';
if ( ! preg_match( $pattern, $contents, $matches, PREG_OFFSET_CAPTURE ) ) {
$this->warning( sprintf( 'Function %s not found in %s', $name, $file ) );

return;
}

Expand All @@ -329,6 +348,7 @@ protected function remove_function( string $file, string $name ) {

if ( false === $start || 0 > $start || $end >= $length ) {
$this->warning( sprintf( 'Function %s not found in %s', $name, $file ) );

return;
}

Expand All @@ -342,6 +362,7 @@ protected function remove_function( string $file, string $name ) {

if ( empty( $new ) ) {
$this->warning( sprintf( 'Replace failed for function %s in %s', $name, $file ) );

return;
}

Expand All @@ -358,18 +379,21 @@ protected function remove_pattern( string $file, string $pattern ) {
$file = $this->file_path( $file );
if ( ! file_exists( $file ) ) {
$this->warning( sprintf( 'File does not exist: %s', $file ) );

return;
}

$contents = file_get_contents( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions
if ( ! preg_match( $pattern, $contents, $matches ) ) {
$this->warning( sprintf( 'Pattern %s not found in %s', $pattern, $file ) );

return;
}

$new = preg_replace( $pattern, '', $contents );
if ( empty( $new ) ) {
$this->warning( sprintf( 'Replace failed for pattern %s in %s', $pattern, $file ) );

return;
}

Expand All @@ -385,6 +409,7 @@ protected function remove_file( string $file ) {
$file = $this->file_path( $file );
if ( ! file_exists( $file ) ) {
$this->warning( sprintf( 'File does not exist: %s', $file ) );

return;
}

Expand All @@ -400,10 +425,26 @@ protected function remove_directory( string $directory ) {
$directory = $this->file_path( $directory );
if ( ! is_dir( $directory ) ) {
$this->warning( sprintf( 'Directory does not exist: %s', $directory ) );

return;
}

rmdir( $directory ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir
if ( $this->is_empty_directory( $directory ) ) {
rmdir( $directory ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_rmdir
} else {
$this->warning( sprintf( 'Directory not empty: %s', $directory ) );
}
}

/**
* Check if a directory is empty
*
* @param string $directory
*
* @return bool True if empty
*/
protected function is_empty_directory( string $directory ): bool {
return ( count( scandir( $directory ) ) === 2 );
}

/**
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
*** WooCommerce Google Listings and Ads Changelog ***

= 2.7.0 - 2024-05-14 =
* Fix - Convert `lbs` to `lb` when mapping WC products to Google products.
* Fix - E2E tests
* Tweak - WC 8.9 compatibility.
* Update - Update Google API to V16.

= 2.6.9 - 2024-05-07 =
* Tweak - Confirm issues are present when retrieving product status.

Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"automattic/jetpack-autoloader": "^3.0",
"automattic/jetpack-config": "^2.0",
"automattic/jetpack-connection": "^2.3",
"google/apiclient": "^2.15",
"google/apiclient-services": "~0.312",
"googleads/google-ads-php": "^19.2",
"google/apiclient": "^2.16",
"google/apiclient-services": "^0.350.0",
"googleads/google-ads-php": "dev-legacy-v22.1.0",
"league/container": "^3.4",
"league/iso3166": "^4.1",
"phpseclib/bcmath_compat": "^2.0",
Expand All @@ -23,6 +23,7 @@
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
"dg/bypass-finals": "^1.6",
"phpunit/phpunit": "^9.5",
"wp-cli/i18n-command": "^2.2",
"wp-coding-standards/wpcs": "^3.0",
Expand Down Expand Up @@ -62,7 +63,7 @@
"Google\\Task\\Composer::cleanup",
"Automattic\\WooCommerce\\GoogleListingsAndAds\\Util\\SymfonyPolyfillCleanup::remove",
"Automattic\\WooCommerce\\GoogleListingsAndAds\\Util\\GoogleAdsCleanupServices::remove",
"composer run-script remove-google-ads-api-version-support -- 11 12 13",
"composer run-script remove-google-ads-api-version-support -- 14 15",
"php ./bin/prefix-vendor-namespace.php",
"bash ./bin/cleanup-vendor-files.sh",
"composer dump-autoload"
Expand Down
Loading

0 comments on commit 8d0906a

Please sign in to comment.