Update relevant files due to L2->L0 policy change for minimum required versions. (https://github.com/woocommerce/woocommerce-blocks/pull/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 <contact@albertjuhe.com>

* remove checklist items about versions for patch releases

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
This commit is contained in:
Darren Ethier 2021-07-29 10:52:34 -04:00 committed by GitHub
parent 651495467f
commit 5ebbd41220
11 changed files with 84 additions and 170 deletions

View File

@ -12,5 +12,5 @@ WORDPRESS_TITLE=WooCommerce Core E2E Test Suite
WORDPRESS_LOGIN=admin
WORDPRESS_PASSWORD=password
WORDPRESS_EMAIL=admin@woocommercecoree2etestsuite.com
WP_VERSION=5.4
WOO_VERSION=5.3.0
WP_VERSION=latest
WOO_VERSION=latest

View File

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

View File

@ -3,13 +3,14 @@ The release pull request has been created! This checklist is a guide to follow f
* [ ] Checkout the release branch locally.
## Initial Preparation
* [ ] Add the changelog to `readme.txt`
* [ ] Add the version and date to the changelog section within `readme.txt`, e.g. `= {{version}} - YYYY-MM-DD =`
* [ ] Copy the changelog from the pull request description above into this new section
* [ ] Update compatibility sections (if applicable). __Note:__ Do not change the stable tag or plugin version; this is automated.
* [ ] Update _Requires at least_, _Tested up to_, and _Requires PHP_ sections at the top of `readme.txt`.
* [ ] Update _Requires at least_, _Requires PHP_, _WC requires at least_, and _WC tested up to_ at the top of `woocommerce-gutenberg-products-block.php`
* [ ] 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.
* [ ] 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.
* [ ] 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.
* [ ] 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" />`.
* [ ] Push above changes to the release branch.
## Write Testing Notes

View File

@ -58,8 +58,8 @@ jobs:
run: |
composer install
JSE2ETestsWP57Gutenberg:
name: JavaScipt E2E Tests (WP 5.7 with Gutenberg plugin)
JSE2EWithGutenberg:
name: JavaScript E2E Tests (WP latest with Gutenberg plugin)
needs: Setup
runs-on: ubuntu-latest
steps:
@ -113,10 +113,9 @@ jobs:
run: |
composer install
- name: E2E Tests (WP 5.7 with Gutenberg plugin)
- name: E2E Tests (WP latest with Gutenberg plugin)
env:
WOOCOMMERCE_BLOCKS_PHASE: 3
WP_VERSION: 5.7-branch
run: |
chmod -R 767 ./ #needed for permissions issues
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:
npm run wp-env clean all
npm run test:e2e
JSE2ETestsWP57:
name: JavaScipt E2E Tests (WP 5.7)
JSE2ETests:
name: JavaScript E2E Tests (latest)
needs: Setup
runs-on: ubuntu-latest
steps:
@ -180,143 +179,10 @@ jobs:
run: |
composer install
- name: E2E Tests (WP 5.7)
- name: E2E Tests (WP latest)
env:
WOOCOMMERCE_BLOCKS_PHASE: 3
WP_VERSION: 5.7-branch
run: |
npm run wp-env start
npm run wp-env clean all
npm run test:e2e
JSE2ETestsWP56:
name: JavaScipt E2E Tests (WP 5.6)
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Npm install and build
run: |
npm ci
FORCE_REDUCED_MOTION=true npm run build:e2e-test
- name: blocks.ini setup
run: |
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: composer
- name: Composer install
run: |
composer install
- name: E2E Tests (WP 5.6)
env:
WOOCOMMERCE_BLOCKS_PHASE: 3
WP_VERSION: 5.6-branch
run: |
JSON='{"core": "WordPress/WordPress#'"$WP_VERSION"'"}'
echo $JSON > .wp-env.override.json
npm run wp-env start
npm run wp-env clean all
npm run test:e2e
JSE2ETestsWP55:
name: JavaScipt E2E Tests (WP 5.5)
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Npm install and build
run: |
npm ci
FORCE_REDUCED_MOTION=true npm run build:e2e-test
- name: blocks.ini setup
run: |
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: composer
- name: Composer install
run: |
composer install
- name: E2E Tests (WP 5.5)
env:
WOOCOMMERCE_BLOCKS_PHASE: 3
WP_VERSION: 5.5-branch
run: |
JSON='{"core": "WordPress/WordPress#'"$WP_VERSION"'"}'
echo $JSON > .wp-env.override.json
npm run wp-env start
npm run wp-env clean all
npm run test:e2e

View File

@ -94,8 +94,6 @@ jobs:
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
- name: Run PHP Unit tests
env:
WOO_VERSION: 5.3.0
run: |
npm run phpunit

View File

@ -17,11 +17,10 @@ Use this plugin if you want access to the bleeding edge of available blocks for
- [Documentation](#documentation)
- [Code Documentation](#code-documentation)
- [Contributing](#contributing)
- [Installing the plugin version](#installing-the-plugin-version)
- [Installing the development version](#installing-the-development-version)
- [Getting started with block development](#getting-started-with-block-development)
- [Vision for the Feature](#vision-for-the-feature)
- [Long-term vision](#long-term-vision)
## Documentation
@ -40,19 +39,16 @@ If you want to see what we're working on for future versions, or want to help ou
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.
> 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.
> 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).
>
> 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+.
>
> 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.
1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
1. Make sure you have the latest available versions of WordPress and WooCommerce on your site.
2. The plugin version is available on WordPress.org. [Download the plugin version here.](https://wordpress.org/plugins/woo-gutenberg-products-block/)
3. Activate the plugin.
## Installing the development version
1. Make sure you have WordPress 5.4+ and WooCommerce 4.3+
1. Make sure you have the latest versions of WordPress and WooCommerce on your site.
2. Get a copy of this plugin using the green "Clone or download" button on the right.
3. `npm install` to install the dependencies.
4. `composer install` to install core dependencies.

View File

@ -9,7 +9,7 @@
<exclude-pattern>languages/woo-gutenberg-products-block.php</exclude-pattern>
<!-- Configs -->
<config name="minimum_supported_wp_version" value="4.7" />
<config name="minimum_supported_wp_version" value="5.6" />
<config name="testVersion" value="7.0-" />
<!-- Rules -->

View File

@ -1,7 +1,7 @@
=== WooCommerce Blocks ===
Contributors: automattic, woocommerce, claudiulodro, tiagonoronha, jameskoster, ryelle, levinmedia, aljullu, mikejolley, nerrad, joshuawold, assassinateur, haszari
Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks
Requires at least: 5.5
Requires at least: 5.8
Tested up to: 5.8
Requires PHP: 7.0
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
= Minimum Requirements =
* WordPress 5.5 or greater
* WooCommerce 4.3 or greater
* Latest release versions of WordPress and WooCommerce ([read more here](https://developer.woocommerce.com/?p=9998))
* PHP version 7.0 or greater (PHP 7.4 or greater is recommended)
* MySQL version 5.6 or greater

View File

@ -100,7 +100,31 @@ class Bootstrap {
* @return boolean
*/
protected function has_core_dependencies() {
return class_exists( 'WooCommerce' ) && function_exists( 'register_block_type' );
$has_needed_dependencies = class_exists( 'WooCommerce' );
if ( $has_needed_dependencies ) {
$plugin_data = \get_file_data(
$this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
[
'RequiredWCVersion' => 'WC requires at least',
]
);
if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
$has_needed_dependencies = false;
add_action(
'admin_notices',
function() {
if ( should_display_compatibility_notices() ) {
?>
<div class="notice notice-error">
<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>
</div>
<?php
}
}
);
}
}
return $has_needed_dependencies;
}
/**

View File

@ -1,4 +1,6 @@
<?php
use Automattic\WooCommerce\Proxies\LegacyProxy;
use Automattic\WooCommerce\Testing\Tools\DependencyManagement\MockableLegacyProxy;
/**
* PHPUnit bootstrap file
*
@ -83,6 +85,35 @@ function wc_test_includes() {
require_once $wc_tests_framework_base_dir . '/framework/helpers/class-wc-helper-settings.php';
}
/**
* Re-initialize the dependency injection engine.
*
* The dependency injection engine has been already initialized as part of the Woo initialization, but we need
* to replace the registered read-only container with a fully configurable one for testing.
* To this end we hack a bit and use reflection to grab the underlying container that the read-only one stores
* in a private property.
*
* Additionally, we replace the legacy/function proxies with mockable versions to easily replace anything
* in tests as appropriate.
*
* @throws \Exception The Container class doesn't have a 'container' property.
*/
function wc_blocks_initialize_dependency_injection() {
try {
$inner_container_property = new \ReflectionProperty( \Automattic\WooCommerce\Container::class, 'container' );
} catch ( ReflectionException $ex ) {
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?' );
}
$inner_container_property->setAccessible( true );
$inner_container = $inner_container_property->getValue( wc_get_container() );
$inner_container->replace( LegacyProxy::class, MockableLegacyProxy::class );
$inner_container->reset_all_resolved();
$GLOBALS['wc_container'] = $inner_container;
}
function wc_load_core() {
define( 'WC_TAX_ROUNDING_MODE', 'auto' );
define( 'WC_USE_TRANSACTIONS', false );
@ -119,3 +150,4 @@ tests_add_filter( 'setup_theme', 'wc_install_core' );
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';
wc_test_includes();
wc_blocks_initialize_dependency_injection();

View File

@ -7,9 +7,9 @@
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woo-gutenberg-products-block
* Requires at least: 5.5
* Requires at least: 5.8
* Requires PHP: 7.0
* WC requires at least: 5.2
* WC requires at least: 5.5
* WC tested up to: 5.5
*
* @package WooCommerce\Blocks
@ -18,7 +18,7 @@
defined( 'ABSPATH' ) || exit;
$minimum_wp_version = '5.5';
$minimum_wp_version = '5.8';
if ( ! defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ) {
define( 'WC_BLOCKS_IS_FEATURE_PLUGIN', true );
@ -54,8 +54,8 @@ if ( version_compare( $GLOBALS['wp_version'], $minimum_wp_version, '<' ) ) {
function woocommerce_blocks_admin_unsupported_wp_notice() {
if ( should_display_compatibility_notices() ) {
?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e( 'WooCommerce Blocks requires a more recent version of WordPress and has been paused. Please update WordPress to continue enjoying WooCommerce Blocks.', 'woo-gutenberg-products-block' ); ?></p>
<div class="notice notice-error">
<p><?php esc_html_e( 'The WooCommerce Blocks feature plugin requires a more recent version of WordPress and has been paused. Please update WordPress to continue enjoying WooCommerce Blocks.', 'woo-gutenberg-products-block' ); ?></p>
</div>
<?php
}