Shard unit test runs (#39302)

closes #38973
This commit is contained in:
Leif Singer 2023-07-20 10:01:28 +02:00 committed by GitHub
parent 5823385084
commit 9ee44947e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 8 deletions

View File

@ -28,11 +28,20 @@ jobs:
matrix:
php: ['7.4', '8.0']
wp: ['latest']
unittests: ['shard1', 'shard2']
include:
- wp: nightly
php: '7.4'
unittests: 'shard1'
- wp: nightly
php: '7.4'
unittests: 'shard2'
- wp: '6.1'
php: 7.4
unittests: 'shard1'
- wp: '6.1'
php: 7.4
unittests: 'shard2'
services:
database:
image: mysql:5.6
@ -78,4 +87,4 @@ jobs:
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce test:unit:env
run: pnpm --filter=woocommerce test:unit:env --testsuite ${{ matrix.unittests }}

View File

@ -28,14 +28,28 @@ jobs:
matrix:
php: ['7.4', '8.0']
wp: ['latest']
unittests: ['shard1', 'shard2']
include:
- wp: nightly
php: '7.4'
unittests: 'shard1'
- wp: nightly
php: '7.4'
unittests: 'shard2'
- wp: '6.1'
php: 7.4
unittests: 'shard1'
- wp: '6.1'
php: 7.4
unittests: 'shard2'
- wp: 'latest'
php: '7.4'
hpos: true
unittests: 'shard1'
- wp: 'latest'
php: '7.4'
hpos: true
unittests: 'shard2'
services:
database:
image: mysql:5.6
@ -72,4 +86,4 @@ jobs:
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce test:unit:env
run: pnpm --filter=woocommerce test:unit:env --testsuite ${{ matrix.unittests }}

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Shard the unit tests running on GitHub Actions.

View File

@ -9,10 +9,18 @@
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<testsuites>
<testsuite name="WooCommerce Test Suite">
<testsuite name="wc-unittests-all">
<directory suffix=".php">./tests/legacy/unit-tests</directory>
<directory suffix=".php">./tests/php</directory>
</testsuite>
<testsuite name="shard1">
<directory suffix=".php">./tests/legacy/unit-tests</directory>
<directory suffix=".php">./tests/php</directory>
<exclude>./tests/legacy/unit-tests/woocommerce-admin</exclude>
</testsuite>
<testsuite name="shard2">
<directory suffix=".php">./tests/legacy/unit-tests/woocommerce-admin</directory>
</testsuite>
</testsuites>
<coverage includeUncoveredFiles="true">
<include>

View File

@ -7,10 +7,19 @@
use Automattic\WooCommerce\Internal\Admin\CustomerEffortScoreTracks;
// CustomerEffortScoreTracks only works in wp-admin, so let's fake it.
class CurrentScreenMock {
public function in_admin() {
return true;
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
if ( ! class_exists( 'CurrentScreenMock' ) ) {
/**
* Class CurrentScreenMock
*/
class CurrentScreenMock {
/**
* CustomerEffortScoreTracks only works in wp-admin, so let's fake it.
*/
public function in_admin() {
return true;
}
}
}
@ -42,7 +51,7 @@ class WC_Admin_Tests_CES_Tracks extends WC_Unit_Test_Case {
}
public function tearDown(): void {
parent::tearDown();
parent::tearDown();
if ( $this->current_screen_backup ) {
$GLOBALS['current_screen'] = $this->current_screen_backup;
}

View File

@ -666,8 +666,12 @@ class WC_Admin_Tests_Reports_Orders_Stats extends WC_Unit_Test_Case {
$orders[] = $order;
}
$this->assertEquals( 15, count( WC_Helper_Queue::get_all_pending() ) );
WC_Helper_Queue::run_all_pending();
$this->assertEquals( 0, count( WC_Helper_Queue::get_all_pending() ) );
$data_store = new OrdersStatsDataStore();
// Test for the current hour.

View File

@ -1,5 +1,21 @@
<?php
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
if ( ! class_exists( 'CurrentScreenMock' ) ) {
/**
* Class CurrentScreenMock
*/
class CurrentScreenMock {
/**
* CustomerEffortScoreTracks only works in wp-admin, so let's fake it.
*/
public function in_admin() {
return true;
}
}
}
/**
* Class WC_Orders_Tracking_Test.
*/