Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 5f3d26a

Browse files
nerradAljullu
andauthored
Update relevant files due to L2->L0 policy change for minimum required versions. (#4484)
* update README files with version requirements * update phpcs config * update default environment for tests locally * update workflows to only test against versions matching new policy * update plugin header for new version policy * restore older WP version support in E2E tests and PHPCS I realized that we might still want to test against L2 WP versions in our E2E tests until those tests can be moved to WC core. While the feature plugin is L0, we still need to support L2 for existing features that are already surfaced in the WooCommerce plugin package. Also with PHPCS if there are fixes to older things in the codebase, we will need to preserve the usage of L2 friendly (back-compat) code. * add detection of Woo Core version to bootstrap * update version used in phpunit tests * add links to version policy update post * restore 5.5.1 for Woo Core version Getting errors with 5.5.2 - not sure what's going on but might be the tag isn't available as expected for 5.5.2 maybe? * switch to hardcoded version header reference PHPUNIT was tripping on this for some reason. * remove older WP version e2e test workflows * fix phpunit tests for new woo test suite Woo Core now uses a container and has some mocks that are used in some legacy test helpers. * remove explicit set WOO_VERSION for phpunit tests. This should default to latest for the GH workflow runs. * Update release PR template. Add some explicit instructions around updating required WP and WC versions at time of release. * use latest WOO_VERSION in .env * some improvements to reduce the things needing updated * remove extraneous code * Add some more checklist items to release PR templates * remove unnecessary conditional * remove is-dismissible css classes * Improve clarity of error messaging * Update README.md Co-authored-by: Albert Juhé Lluveras <[email protected]> * remove checklist items about versions for patch releases Co-authored-by: Albert Juhé Lluveras <[email protected]>
1 parent 4133792 commit 5f3d26a

File tree

11 files changed

+84
-170
lines changed

11 files changed

+84
-170
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ WORDPRESS_TITLE=WooCommerce Core E2E Test Suite
1212
WORDPRESS_LOGIN=admin
1313
WORDPRESS_PASSWORD=password
1414
WORDPRESS_EMAIL=[email protected]
15-
WP_VERSION=5.4
16-
WOO_VERSION=5.3.0
15+
WP_VERSION=latest
16+
WOO_VERSION=latest

.github/patch-initial-checklist.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ The release pull request has been created! This checklist is a guide to follow f
88
* [ ] Add the version and date to the changelog section within `readme.txt`, e.g. `= {{version}} - YYYY-MM-DD =`
99
* [ ] Copy the changelog from the pull request description above into this new section
1010
* [ ] Update compatibility sections (if applicable). __Note:__ Do not change the stable tag or plugin version; this is automated.
11-
* [ ] Update _Requires at least_, _Tested up to_, and _Requires PHP_ sections at the top of `readme.txt`.
12-
* [ ] Update _Requires at least_, _Requires PHP_, _WC requires at least_, and _WC tested up to_ at the top of `woocommerce-gutenberg-products-block.php`
1311
* [ ] Push above changes to the release branch.
1412

1513
## Write Testing Notes
@@ -20,7 +18,7 @@ Additionally, make sure to differentiate between things in the testing notes tha
2018

2119
* [ ] Run `npm ci`
2220
* [ ] Run `npm run package-plugin:deploy`. This will create a zip of the current branch build locally.
23-
* [ ] Create testing notes for the release. You can usually go through the pull requests linked in the changelog and grab testing notes from each pull.
21+
* [ ] Create testing notes for the release. You can usually go through the pull requests linked in the changelog and grab testing notes from each pull.
2422
* [ ] Add the notes to `docs/testing/releases`
2523
* [ ] Update the `docs/testing/releases/README.md` file index.
2624
* [ ] Copy a link to the release zip you created earlier into the testing notes. To generate the link you can upload the zip as an attachment in a GitHub comment and then just copy the path (without publishing the comment).

.github/release-initial-checklist.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ The release pull request has been created! This checklist is a guide to follow f
33
* [ ] Checkout the release branch locally.
44

55
## Initial Preparation
6-
76
* [ ] Add the changelog to `readme.txt`
87
* [ ] Add the version and date to the changelog section within `readme.txt`, e.g. `= {{version}} - YYYY-MM-DD =`
98
* [ ] Copy the changelog from the pull request description above into this new section
109
* [ ] Update compatibility sections (if applicable). __Note:__ Do not change the stable tag or plugin version; this is automated.
11-
* [ ] Update _Requires at least_, _Tested up to_, and _Requires PHP_ sections at the top of `readme.txt`.
12-
* [ ] Update _Requires at least_, _Requires PHP_, _WC requires at least_, and _WC tested up to_ at the top of `woocommerce-gutenberg-products-block.php`
10+
* [ ] Update _Requires at least_, _Tested up to_, and _Requires PHP_ sections at the top of `readme.txt`. Note, this should also be the latest WordPress version available at time of release.
11+
* [ ] Update _Requires at least_, _Requires PHP_, _WC requires at least_, and _WC tested up to_ at the top of `woocommerce-gutenberg-products-block.php`. Note, this should include requiring the latest WP and WC versions at the time of the plugin release.
12+
* [ ] If necessary, update the value of `$minimum_wp_version` at the top of the `woocommerce-gutenberg-products-block.php` file to the latest available version of WordPress.
13+
* [ ] If necessary, update the `phpcs.xml` file to reference the minimum WP version supported by **WooCommerce Core**. It would be this line: `<config name="minimum_supported_wp_version" value="5.6" />`.
1314
* [ ] Push above changes to the release branch.
1415

1516
## Write Testing Notes
@@ -21,7 +22,7 @@ Additionally, make sure to differentiate between things in the testing notes tha
2122
* [ ] Run `npm ci`
2223
* [ ] Run `npm run package-plugin:deploy`. This will create a zip of the current branch build locally.
2324
* Note: The zip file is functionally equivalent to what gets released except the version bump.
24-
* [ ] Create testing notes for the release. You can usually go through the pull requests linked in the changelog and grab testing notes from each pull.
25+
* [ ] Create testing notes for the release. You can usually go through the pull requests linked in the changelog and grab testing notes from each pull.
2526
* [ ] Add the notes to `docs/testing/releases`
2627
* [ ] Update the `docs/testing/releases/README.md` file index.
2728
* [ ] Copy a link to the release zip you created earlier into the testing notes. To generate the link you can upload the zip as an attachment in a GitHub comment and then just copy the path (without publishing the comment).
@@ -52,7 +53,7 @@ Additionally, make sure to differentiate between things in the testing notes tha
5253
* [ ] Execute `npm run deploy`
5354
* The script will ask you to enter the version number to tag. Please enter the version we're releasing right now. Do not publish any dev tags as a release.
5455
* Note: the script automatically updates version numbers on Github (commits on your behalf).
55-
* **ALERT**: This script will ask you if this release will be deployed to WordPress.org. You should answer yes for this release even if it is a pre-release.
56+
* **ALERT**: This script will ask you if this release will be deployed to WordPress.org. You should answer yes for this release even if it is a pre-release.
5657
* A GitHub release will automatically be created and this will trigger a workflow that automatically deploys the plugin to WordPress.org.
5758
* [ ] Edit the [GitHub release](https://github.com/woocommerce/woocommerce-gutenberg-products-block/releases) and copy changelog into the release notes. Ensure there is a release with the correct version, the one you entered above.
5859
* [ ] The `#team-rubik` slack instance will be notified about the progress with the WordPress.org deploy. Watch for that. If anything goes wrong, an error will be reported and you can followup via the GitHub actions tab and the log for that workflow.

.github/workflows/php-js-e2e-tests.yml

Lines changed: 6 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
run: |
5959
composer install
6060
61-
JSE2ETestsWP57Gutenberg:
62-
name: JavaScipt E2E Tests (WP 5.7 with Gutenberg plugin)
61+
JSE2EWithGutenberg:
62+
name: JavaScript E2E Tests (WP latest with Gutenberg plugin)
6363
needs: Setup
6464
runs-on: ubuntu-latest
6565
steps:
@@ -113,10 +113,9 @@ jobs:
113113
run: |
114114
composer install
115115
116-
- name: E2E Tests (WP 5.7 with Gutenberg plugin)
116+
- name: E2E Tests (WP latest with Gutenberg plugin)
117117
env:
118118
WOOCOMMERCE_BLOCKS_PHASE: 3
119-
WP_VERSION: 5.7-branch
120119
run: |
121120
chmod -R 767 ./ #needed for permissions issues
122121
JSON='{"plugins": ["https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip","https://github.com/WP-API/Basic-Auth/archive/master.zip","https://downloads.wordpress.org/plugin/gutenberg.latest-stable.zip", "."] }'
@@ -125,8 +124,8 @@ jobs:
125124
npm run wp-env clean all
126125
npm run test:e2e
127126
128-
JSE2ETestsWP57:
129-
name: JavaScipt E2E Tests (WP 5.7)
127+
JSE2ETests:
128+
name: JavaScript E2E Tests (latest)
130129
needs: Setup
131130
runs-on: ubuntu-latest
132131
steps:
@@ -180,143 +179,10 @@ jobs:
180179
run: |
181180
composer install
182181
183-
- name: E2E Tests (WP 5.7)
182+
- name: E2E Tests (WP latest)
184183
env:
185184
WOOCOMMERCE_BLOCKS_PHASE: 3
186-
WP_VERSION: 5.7-branch
187185
run: |
188186
npm run wp-env start
189187
npm run wp-env clean all
190188
npm run test:e2e
191-
192-
JSE2ETestsWP56:
193-
name: JavaScipt E2E Tests (WP 5.6)
194-
needs: Setup
195-
runs-on: ubuntu-latest
196-
steps:
197-
- uses: actions/checkout@v2
198-
199-
- name: Cache node modules
200-
uses: actions/cache@v2
201-
env:
202-
cache-name: cache-node-modules
203-
with:
204-
# npm cache files are stored in `~/.npm` on Linux/macOS
205-
path: ~/.npm
206-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
207-
restore-keys: |
208-
${{ runner.os }}-build-${{ env.cache-name }}-
209-
${{ runner.os }}-build-
210-
${{ runner.os }}-
211-
212-
- name: Use Node.js 14.x
213-
uses: actions/setup-node@v1
214-
with:
215-
node-version: 14.x
216-
217-
- name: Npm install and build
218-
run: |
219-
npm ci
220-
FORCE_REDUCED_MOTION=true npm run build:e2e-test
221-
222-
- name: blocks.ini setup
223-
run: |
224-
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
225-
- name: Get Composer Cache Directory
226-
id: composer-cache
227-
run: |
228-
echo "::set-output name=dir::$(composer config cache-files-dir)"
229-
- uses: actions/cache@v2
230-
with:
231-
path: ${{ steps.composer-cache.outputs.dir }}
232-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
233-
restore-keys: |
234-
${{ runner.os }}-composer-
235-
236-
- name: Set up PHP
237-
uses: shivammathur/setup-php@v2
238-
with:
239-
php-version: 7.4
240-
coverage: none
241-
tools: composer
242-
243-
- name: Composer install
244-
run: |
245-
composer install
246-
247-
- name: E2E Tests (WP 5.6)
248-
env:
249-
WOOCOMMERCE_BLOCKS_PHASE: 3
250-
WP_VERSION: 5.6-branch
251-
run: |
252-
JSON='{"core": "WordPress/WordPress#'"$WP_VERSION"'"}'
253-
echo $JSON > .wp-env.override.json
254-
npm run wp-env start
255-
npm run wp-env clean all
256-
npm run test:e2e
257-
258-
JSE2ETestsWP55:
259-
name: JavaScipt E2E Tests (WP 5.5)
260-
needs: Setup
261-
runs-on: ubuntu-latest
262-
steps:
263-
- uses: actions/checkout@v2
264-
265-
- name: Cache node modules
266-
uses: actions/cache@v2
267-
env:
268-
cache-name: cache-node-modules
269-
with:
270-
# npm cache files are stored in `~/.npm` on Linux/macOS
271-
path: ~/.npm
272-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
273-
restore-keys: |
274-
${{ runner.os }}-build-${{ env.cache-name }}-
275-
${{ runner.os }}-build-
276-
${{ runner.os }}-
277-
278-
- name: Use Node.js 14.x
279-
uses: actions/setup-node@v1
280-
with:
281-
node-version: 14.x
282-
283-
- name: Npm install and build
284-
run: |
285-
npm ci
286-
FORCE_REDUCED_MOTION=true npm run build:e2e-test
287-
288-
- name: blocks.ini setup
289-
run: |
290-
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
291-
- name: Get Composer Cache Directory
292-
id: composer-cache
293-
run: |
294-
echo "::set-output name=dir::$(composer config cache-files-dir)"
295-
- uses: actions/cache@v2
296-
with:
297-
path: ${{ steps.composer-cache.outputs.dir }}
298-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
299-
restore-keys: |
300-
${{ runner.os }}-composer-
301-
302-
- name: Set up PHP
303-
uses: shivammathur/setup-php@v2
304-
with:
305-
php-version: 7.4
306-
coverage: none
307-
tools: composer
308-
309-
- name: Composer install
310-
run: |
311-
composer install
312-
313-
- name: E2E Tests (WP 5.5)
314-
env:
315-
WOOCOMMERCE_BLOCKS_PHASE: 3
316-
WP_VERSION: 5.5-branch
317-
run: |
318-
JSON='{"core": "WordPress/WordPress#'"$WP_VERSION"'"}'
319-
echo $JSON > .wp-env.override.json
320-
npm run wp-env start
321-
npm run wp-env clean all
322-
npm run test:e2e

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ jobs:
9494
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
9595
9696
- name: Run PHP Unit tests
97-
env:
98-
WOO_VERSION: 5.3.0
9997
run: |
10098
npm run phpunit
10199

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ Use this plugin if you want access to the bleeding edge of available blocks for
1717

1818
- [Documentation](#documentation)
1919
- [Code Documentation](#code-documentation)
20-
- [Contributing](#contributing)
2120
- [Installing the plugin version](#installing-the-plugin-version)
2221
- [Installing the development version](#installing-the-development-version)
2322
- [Getting started with block development](#getting-started-with-block-development)
24-
- [Vision for the Feature](#vision-for-the-feature)
23+
- [Long-term vision](#long-term-vision)
2524

2625
## Documentation
2726

@@ -40,19 +39,16 @@ If you want to see what we're working on for future versions, or want to help ou
4039

4140
We release a new version of WooCommerce Blocks onto WordPress.org every few weeks, which can be used as an easier way to preview the features.
4241

43-
> Note: The plugin follows a policy of supporting the "L2" strategy for version support. What this means is that the plugin will support the most recent two minor versions of WordPress, and the most recent two minor versions of WooCommerce core at the time of a release.
42+
> Note: The plugin follows a policy of supporting the "L0" strategy for version support. What this means is that the plugin will require the most recent version of WordPress, and the most recent version of WooCommerce core at the time of a release. You can read more about [this policy here](https://developer.woocommerce.com/?p=9998).
4443
>
45-
> That means if the latest version of WooCommerce is 4.3 at the time of a release, then our minimum version requirements for WooCommerce core would be 4.1+.
46-
>
47-
> We **recommend** you always keep WordPress and WooCommerce core up to date in order to ensure your store is running with the most recent fixes and enhancements to help your store be successful.
4844
49-
1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
45+
1. Make sure you have the latest available versions of WordPress and WooCommerce on your site.
5046
2. The plugin version is available on WordPress.org. [Download the plugin version here.](https://wordpress.org/plugins/woo-gutenberg-products-block/)
5147
3. Activate the plugin.
5248

5349
## Installing the development version
5450

55-
1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
51+
1. Make sure you have the latest versions of WordPress and WooCommerce on your site.
5652
2. Get a copy of this plugin using the green "Clone or download" button on the right.
5753
3. `npm install` to install the dependencies.
5854
4. `composer install` to install core dependencies.

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<exclude-pattern>languages/woo-gutenberg-products-block.php</exclude-pattern>
1010

1111
<!-- Configs -->
12-
<config name="minimum_supported_wp_version" value="4.7" />
12+
<config name="minimum_supported_wp_version" value="5.6" />
1313
<config name="testVersion" value="7.0-" />
1414

1515
<!-- Rules -->

readme.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== WooCommerce Blocks ===
22
Contributors: automattic, woocommerce, claudiulodro, tiagonoronha, jameskoster, ryelle, levinmedia, aljullu, mikejolley, nerrad, joshuawold, assassinateur, haszari
33
Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks
4-
Requires at least: 5.5
4+
Requires at least: 5.8
55
Tested up to: 5.8
66
Requires PHP: 7.0
77
Stable tag: 5.6.0-dev
@@ -44,8 +44,7 @@ Use this plugin if you want access to the bleeding edge of available blocks for
4444

4545
= Minimum Requirements =
4646

47-
* WordPress 5.5 or greater
48-
* WooCommerce 4.3 or greater
47+
* Latest release versions of WordPress and WooCommerce ([read more here](https://developer.woocommerce.com/?p=9998))
4948
* PHP version 7.0 or greater (PHP 7.4 or greater is recommended)
5049
* MySQL version 5.6 or greater
5150

src/Domain/Bootstrap.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,31 @@ protected function init() {
100100
* @return boolean
101101
*/
102102
protected function has_core_dependencies() {
103-
return class_exists( 'WooCommerce' ) && function_exists( 'register_block_type' );
103+
$has_needed_dependencies = class_exists( 'WooCommerce' );
104+
if ( $has_needed_dependencies ) {
105+
$plugin_data = \get_file_data(
106+
$this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
107+
[
108+
'RequiredWCVersion' => 'WC requires at least',
109+
]
110+
);
111+
if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
112+
$has_needed_dependencies = false;
113+
add_action(
114+
'admin_notices',
115+
function() {
116+
if ( should_display_compatibility_notices() ) {
117+
?>
118+
<div class="notice notice-error">
119+
<p><?php esc_html_e( 'The WooCommerce Blocks feature plugin requires a more recent version of WooCommerce and has been paused. Please update WooCommerce to the latest version to continue enjoying WooCommerce Blocks.', 'woo-gutenberg-products-block' ); ?></p>
120+
</div>
121+
<?php
122+
}
123+
}
124+
);
125+
}
126+
}
127+
return $has_needed_dependencies;
104128
}
105129

106130
/**

tests/bootstrap.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
use Automattic\WooCommerce\Proxies\LegacyProxy;
3+
use Automattic\WooCommerce\Testing\Tools\DependencyManagement\MockableLegacyProxy;
24
/**
35
* PHPUnit bootstrap file
46
*
@@ -83,6 +85,35 @@ function wc_test_includes() {
8385
require_once $wc_tests_framework_base_dir . '/framework/helpers/class-wc-helper-settings.php';
8486
}
8587

88+
/**
89+
* Re-initialize the dependency injection engine.
90+
*
91+
* The dependency injection engine has been already initialized as part of the Woo initialization, but we need
92+
* to replace the registered read-only container with a fully configurable one for testing.
93+
* To this end we hack a bit and use reflection to grab the underlying container that the read-only one stores
94+
* in a private property.
95+
*
96+
* Additionally, we replace the legacy/function proxies with mockable versions to easily replace anything
97+
* in tests as appropriate.
98+
*
99+
* @throws \Exception The Container class doesn't have a 'container' property.
100+
*/
101+
function wc_blocks_initialize_dependency_injection() {
102+
try {
103+
$inner_container_property = new \ReflectionProperty( \Automattic\WooCommerce\Container::class, 'container' );
104+
} catch ( ReflectionException $ex ) {
105+
throw new \Exception( "Error when trying to get the private 'container' property from the " . \Automattic\WooCommerce\Container::class . ' class using reflection during unit testing bootstrap, has the property been removed or renamed?' );
106+
}
107+
108+
$inner_container_property->setAccessible( true );
109+
$inner_container = $inner_container_property->getValue( wc_get_container() );
110+
111+
$inner_container->replace( LegacyProxy::class, MockableLegacyProxy::class );
112+
$inner_container->reset_all_resolved();
113+
114+
$GLOBALS['wc_container'] = $inner_container;
115+
}
116+
86117
function wc_load_core() {
87118
define( 'WC_TAX_ROUNDING_MODE', 'auto' );
88119
define( 'WC_USE_TRANSACTIONS', false );
@@ -119,3 +150,4 @@ function() {
119150
// Start up the WP testing environment.
120151
require $_tests_dir . '/includes/bootstrap.php';
121152
wc_test_includes();
153+
wc_blocks_initialize_dependency_injection();

0 commit comments

Comments
 (0)