Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
775ce38
environment for multi-php
javiercasares Mar 16, 2024
80b179a
prepare for multi-php
javiercasares Mar 16, 2024
ee4ac7b
test for multi-php
javiercasares Mar 16, 2024
78c5e61
cleanup for multi-php
javiercasares Mar 16, 2024
331ecc3
report for multi-php
javiercasares Mar 16, 2024
ef8a5de
temporary fix
javiercasares Mar 16, 2024
58034b0
some changes
javiercasares Mar 17, 2024
9205042
env file with commints checking
javiercasares Mar 17, 2024
8b49cb2
possible future files
javiercasares Mar 17, 2024
09bf9a6
some changes
javiercasares Mar 17, 2024
fea79f5
testing version
javiercasares Mar 17, 2024
0878108
fixes
javiercasares Mar 17, 2024
109f52d
reorder the commits to run
javiercasares Mar 17, 2024
07e45fc
move the commit to the executed part
javiercasares Mar 17, 2024
d9106c9
checks that there are not duplicated tests to run
javiercasares Mar 17, 2024
5702840
Merge branch 'WordPress:master' into multi-php
javiercasares Mar 17, 2024
2e3b29d
add some documentation
javiercasares Mar 18, 2024
d3eedad
Update .env.default
javiercasares Sep 28, 2024
64d44e8
Update docs/1-setup.md
javiercasares Sep 28, 2024
7f546e3
Update docs/1-setup.md
javiercasares Sep 28, 2024
caa2e34
Update docs/1-setup.md
javiercasares Sep 28, 2024
d8e35c1
Update docs/1-setup.md
javiercasares Sep 28, 2024
7c6ae9a
Update prepare.php
javiercasares Sep 28, 2024
5f232a1
Update prepare.php
javiercasares Sep 28, 2024
770200c
TLS validation active by default
javiercasares Sep 28, 2024
805d78d
Yoda and some organization and fixes
javiercasares Sep 28, 2024
070c9d5
Improving and normalizing code.
javiercasares Sep 28, 2024
234a0e3
80 columns
javiercasares Sep 29, 2024
398b809
readme changes
javiercasares Sep 29, 2024
e1abdad
documentation will be on the readme
javiercasares Sep 29, 2024
592e6c7
Documentation
javiercasares Sep 29, 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
18 changes: 15 additions & 3 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
# $ source .env
###

# Label for the environment. Can be empty (default) or be like "shared", "vps", "cloud" or similar.
# Please use only alphanumeric keywords, and try to be descriptive
export WPT_LABEL=

# Path to the directory where files can be prepared before being delivered to the environment.
export WPT_PREPARE_DIR=/tmp/wp-test-runner

# Path to the directory where the WordPress develop checkout can be placed and tests can be run.
# When running tests in the same environment, set WPT_TEST_DIR to WPT_PREPARE_DIR
export WPT_TEST_DIR=wp-test-runner
export WPT_TEST_DIR=/tmp/wp-test-runner

# API key to authenticate with the reporting service in 'username:password' format.
export WPT_REPORT_API_KEY=
Expand All @@ -38,6 +42,9 @@ export WPT_TABLE_PREFIX=${WPT_TABLE_PREFIX-wptests_}
# (Optionally) define the PHP executable to be called
export WPT_PHP_EXECUTABLE=${WPT_PHP_EXECUTABLE-php}

# (Optionally) array of versions (like: 8.0+/bin/php8.0,8.1+/bin/php8.1)
Comment thread
javiercasares marked this conversation as resolved.
Outdated
export WPT_PHP_EXECUTABLE_MULTI=

# (Optionally) define the PHPUnit command execution call.
# Use if `php phpunit.phar` can't be called directly for some reason.
export WPT_PHPUNIT_CMD=
Expand All @@ -63,16 +70,21 @@ export WPT_DEBUG=

# Certificate validation
# Use 1 to validate, and 0 to not validate
export WPT_CERTIFICATE_VALIDATION=1
export WPT_CERTIFICATE_VALIDATION=0

# WordPress flavor
# 0 = WordPress (simple version)
# 1 = WordPress Multisite
export WPT_FLAVOR=1
export WPT_FLAVOR=0

# Extra tests (groups)
# 0 = none
# 1 = ajax
# 2 = ms-files
# 3 = external-http
export WPT_EXTRATESTS=0

# Check all commits
# 0 = latest
# 1 = all
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All is a bit misleading here because the API caps the results per page at 100. The default is 30.

I would change this to an on or off value. If it's on, the runner will query for the last 30 commits and add them to the queue if they have not yet been tested. If it's off, then only the most recent commit when the runner starts should be tested.

Regardless of this value, though, I think that the commits.json file should still be used to track what has been tested. This will help avoid re-running the suite for a commit that has already been tested and reported.

export WPT_COMMITS=0
106 changes: 85 additions & 21 deletions cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,94 @@
$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) );
$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no';
$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) );
$WPT_RM_TEST_DIR_CMD = trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ? : 'rm -r ' . $WPT_TEST_DIR;
$WPT_PHP_EXECUTABLE_MULTI = trim( getenv( 'WPT_PHP_EXECUTABLE_MULTI' ) ) ? : '';

/**
* The directory path of the test preparation directory is assumed to be previously defined.
* For example: $WPT_PREPARE_DIR = '/path/to/your/preparation/dir';
* Clean up the preparation directory.
* Forcefully deletes only the .git directory and the node_modules cache.
* Afterward, the entire preparation directory is removed to ensure a clean state for the next test run.
*/
perform_operations( array(
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/.git' ),
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/node_modules/.cache' ),
'rm -r ' . escapeshellarg( $WPT_PREPARE_DIR ),
) );
$WPT_PHP_EXECUTABLE_MULTI_ARRAY = array();
if ( '' !== $WPT_PHP_EXECUTABLE_MULTI ) {

/**
* Cleans up the test directory on a remote server.
* This conditional block checks if an SSH connection string is provided and is not empty.
* If a connection string is present, it triggers a cleanup operation on the remote environment.
* The cleanup operation is executed by the `perform_operations` function which takes an array
* of shell commands as its input.
*/
if ( ! empty( $WPT_SSH_CONNECT ) ) {
$php_multi_versions = explode( ',', $WPT_PHP_EXECUTABLE_MULTI );

foreach( $php_multi_versions as $php_multi_version ) {

$php_multi_v = explode( '+', $php_multi_version );

if( isset( $php_multi_v[0] ) && $php_multi_v[0] && isset( $php_multi_v[1] ) && $php_multi_v[1] ) {
$WPT_PHP_EXECUTABLE_MULTI_ARRAY[] = array( 'version' => trim( $php_multi_v[0] ), 'bin' => trim( $php_multi_v[1] ) );
}

unset( $php_multi_version );
}

unset( $php_multi_versions );
}

if( count( $WPT_PHP_EXECUTABLE_MULTI_ARRAY ) ) {

foreach( $WPT_PHP_EXECUTABLE_MULTI_ARRAY as $php_multi ) {

$WPT_PREPARE_DIR_MULTI = $WPT_PREPARE_DIR . '-' . crc32( $php_multi['version'] );
$WPT_TEST_DIR_MULTI = $WPT_TEST_DIR . '-' . crc32( $php_multi['version'] );

$WPT_RM_TEST_DIR_CMD = trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ? : 'rm -r ' . $WPT_TEST_DIR_MULTI;

/**
* The directory path of the test preparation directory is assumed to be previously defined.
* For example: $WPT_PREPARE_DIR = '/path/to/your/preparation/dir';
* Clean up the preparation directory.
* Forcefully deletes only the .git directory and the node_modules cache.
* Afterward, the entire preparation directory is removed to ensure a clean state for the next test run.
*/
perform_operations( array(
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR_MULTI . '/.git' ),
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR_MULTI . '/node_modules/.cache' ),
'rm -r ' . escapeshellarg( $WPT_PREPARE_DIR_MULTI ),
) );

/**
* Cleans up the test directory on a remote server.
* This conditional block checks if an SSH connection string is provided and is not empty.
* If a connection string is present, it triggers a cleanup operation on the remote environment.
* The cleanup operation is executed by the `perform_operations` function which takes an array
* of shell commands as its input.
*/
if ( ! empty( $WPT_SSH_CONNECT ) ) {
perform_operations( array(
'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $WPT_RM_TEST_DIR_CMD ),
) );
}

}

} else {

$WPT_RM_TEST_DIR_CMD = trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ? : 'rm -r ' . $WPT_TEST_DIR;

/**
* The directory path of the test preparation directory is assumed to be previously defined.
* For example: $WPT_PREPARE_DIR = '/path/to/your/preparation/dir';
* Clean up the preparation directory.
* Forcefully deletes only the .git directory and the node_modules cache.
* Afterward, the entire preparation directory is removed to ensure a clean state for the next test run.
*/
perform_operations( array(
'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $WPT_RM_TEST_DIR_CMD ),
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/.git' ),
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/node_modules/.cache' ),
'rm -r ' . escapeshellarg( $WPT_PREPARE_DIR ),
) );
}

/**
* Cleans up the test directory on a remote server.
* This conditional block checks if an SSH connection string is provided and is not empty.
* If a connection string is present, it triggers a cleanup operation on the remote environment.
* The cleanup operation is executed by the `perform_operations` function which takes an array
* of shell commands as its input.
*/
if ( ! empty( $WPT_SSH_CONNECT ) ) {
perform_operations( array(
'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $WPT_RM_TEST_DIR_CMD ),
) );
}

}
5 changes: 5 additions & 0 deletions commits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not quite clear what each of these represent based on their names. Have the executed_commits been successfully tested and reported? If the runner fails to be configured and run the tests is it included in that list?

Are pending_commits in a queue to be tested? Something else? Are testing_commit being tested right now? Will this never be more than one?

Also, not sure if this file is here for testing purposes, but it should probably be added to the .gitignore file.

"executed_commits": [],
"pending_commits": [],
"testing_commit": []
}
5 changes: 5 additions & 0 deletions commits.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"executed_commits": ["hash3"],
"pending_commits": ["hash1", "hash2", ..., "hash10"],
"testing_commit": ["hash4"]
}
15 changes: 15 additions & 0 deletions docs/0-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# About the PHPUnit Test Runner

Hosting companies can have several to millions of websites hosted with WordPress, so it's important to make sure their configuration is as compatible as possible with the software.

To verify this compatibility, the WordPress Community provides a series of PHPUnit tests with which to check the operation of WordPress in any environment.

The Runner tests generates a report with the test results related to a bot user (a hosting company), and this captures and displays those test results at the [Host Test Result](https://make.wordpress.org/hosting/test-results/) page.

## What's the phpunit-test-runner

The [phpunit-test-runner](https://github.com/WordPress/phpunit-test-runner) is a tool designed to make it easier for hosting companies to run the WordPress project’s automated tests.

There is a [whole documentation about this tool](https://make.wordpress.org/hosting/test-results-getting-started/). Also, if you want, you can make your test results appear in the [Host Test Results](https://make.wordpress.org/hosting/test-results/) page of WordPress.

The tool can be run manually or through an automated system like Travis. To see how it works and the purpose of this document, will be shown how to run the tests manually.
Loading