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

Release 2.7.0 #2401

Merged
merged 33 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dcd0d70
WIP Update LIbs
puntope Apr 24, 2024
2507ea8
WIP - Update Linking logic
puntope Apr 25, 2024
9b0cb32
Tweak GoogleAdsCleanupService after estruture update
puntope Apr 25, 2024
a3131d3
Update to Google API V16
puntope Apr 26, 2024
137a76e
Add BypassFinals library allowing finals mock
puntope Apr 29, 2024
88d07e0
Tweak tests
puntope Apr 29, 2024
1c89f03
Restore compose command order
puntope Apr 29, 2024
f36da07
Restore package.lock.json
puntope Apr 29, 2024
bb085a8
Attempt to reduce more the size
puntope Apr 29, 2024
71187ac
Remove previous versions
puntope Apr 29, 2024
bc8d13c
Conver lbs to lb when mapping WC product to Google product
ianlin May 6, 2024
96dba1c
Merge pull request #2391 from woocommerce/trunk
ianlin May 7, 2024
b26050f
Merge pull request #2389 from woocommerce/fix/use-lb-instead-of-lbs-b…
ianlin May 8, 2024
0c41e33
Setup WooCommerce using sh
puntope May 8, 2024
aae2355
Avoid running untrusted inputs as shell command in the GitHub Actions.
eason9487 May 9, 2024
eb50e5d
Be sure GLA is activated
puntope May 9, 2024
1078c58
Fix wrong classes
puntope May 9, 2024
53743a9
Merge pull request #2394 from woocommerce/dev/fix-gha-untrusted-input
eason9487 May 9, 2024
d01d24c
Add comment
puntope May 9, 2024
b22bc3c
Merge pull request #2395 from woocommerce/fix/e2e-tests
puntope May 9, 2024
ce707e1
Avoid running malicious inputs as shell commands in the GitHub Actions.
eason9487 May 10, 2024
ad30181
Merge pull request #2397 from woocommerce/dev/avoid-gha-malicious-input
eason9487 May 13, 2024
7564eb8
Revert "Merge pull request #2397 from woocommerce/dev/avoid-gha-malic…
eason9487 May 13, 2024
69b001a
Avoid running malicious inputs as shell commands in the GitHub Actions.
eason9487 May 10, 2024
db77fd5
Merge pull request #2399 from woocommerce/dev/avoid-gha-malicious-input
eason9487 May 13, 2024
bc7b0bf
Merge pull request #2393 from woocommerce/fix/e2e-setup-wp-env
puntope May 13, 2024
140d16a
Remove space
puntope May 14, 2024
f39a0ca
Merge pull request #2386 from woocommerce/update/google-api-v16
puntope May 14, 2024
08ca196
Start `release/2.7.0`.
github-actions[bot] May 14, 2024
b15f2f3
Update changelog
puntope May 14, 2024
9979965
Product version bump update
puntope May 14, 2024
718b8cf
Changelog update
puntope May 14, 2024
b9548fa
Update hooks documentation from branch.
github-actions[bot] May 14, 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
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
Loading