Shard unit test runs (#39362)

This commit is contained in:
Leif Singer 2023-07-27 14:06:55 +02:00 committed by Kyle Nel
parent d7e5703b07
commit cb787aba19
No known key found for this signature in database
6 changed files with 84 additions and 26 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
@ -62,20 +71,20 @@ jobs:
name: Parse Matrix Variables
uses: actions/github-script@v6
with:
script: |
const parseWPVersion = require( './.github/workflows/scripts/parse-wp-version' );
parseWPVersion( '${{ matrix.wp }}' ).then( ( version ) => {
core.setOutput( 'wpVersion', version );
} );
script: |
const parseWPVersion = require( './.github/workflows/scripts/parse-wp-version' );
parseWPVersion( '${{ matrix.wp }}' ).then( ( version ) => {
core.setOutput( 'wpVersion', version );
} );
- name: Prepare Testing Environment
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce env:test
- name: Run Tests
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce test:unit:env
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
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
@ -56,20 +70,20 @@ jobs:
name: Parse Matrix Variables
uses: actions/github-script@v6
with:
script: |
const parseWPVersion = require( './.github/workflows/scripts/parse-wp-version' );
parseWPVersion( '${{ matrix.wp }}' ).then( ( version ) => {
core.setOutput( 'wpVersion', version );
} );
script: |
const parseWPVersion = require( './.github/workflows/scripts/parse-wp-version' );
parseWPVersion( '${{ matrix.wp }}' ).then( ( version ) => {
core.setOutput( 'wpVersion', version );
} );
- name: Prepare Testing Environment
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce env:test
- name: Run Tests
env:
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce test:unit:env
WP_ENV_CORE: ${{ steps.parseMatrix.outputs.wpVersion }}
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: pnpm --filter=woocommerce test:unit:env --testsuite ${{ matrix.unittests }}

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Shard the unit tests into two test suites.

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,18 @@
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 +50,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

@ -1,5 +1,20 @@
<?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.
*/