From 4a4abec74e25ed6a712ff88f9b7ea14e10b734a3 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 2 Nov 2026 15:39:05 +0000 Subject: [PATCH] Run the scenarios of each package in parallel workers Run every suite through the run-behat-tests runner of wp-cli/wp-cli-tests instead of calling Behat directly, so that WP_CLI_TEST_PARALLEL spreads its scenarios over several workers and a rerun covers exactly the scenarios that failed. Also fixes the name of the framework suite in test-source, which made TEST_PACKAGE=all skip it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/reusable-testing.yml | 8 ++++++++ bin/test-phar | 9 +++++---- bin/test-source | 11 ++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/reusable-testing.yml b/.github/workflows/reusable-testing.yml index 162dfea32..677243a4b 100644 --- a/.github/workflows/reusable-testing.yml +++ b/.github/workflows/reusable-testing.yml @@ -26,6 +26,10 @@ on: use-phar: type: boolean required: true + parallel: + type: number + required: false + default: 4 jobs: run-test: @@ -149,4 +153,8 @@ jobs: WP_CLI_TEST_DBTYPE: ${{ inputs.dbtype }} TEST_PACKAGE: 'wp-cli/${{ inputs.test-package }}' WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock' + # Spread the scenarios of the package over as many workers as the runner has cores, + # each with a test database of its own, as prepared by `composer prepare-tests`. + # Not in Docker containers, as these would not see the Phar under test. + WP_CLI_TEST_PARALLEL: ${{ inputs.parallel }} run: composer test diff --git a/bin/test-phar b/bin/test-phar index 591a7a6dc..c6a2ac2d9 100755 --- a/bin/test-phar +++ b/bin/test-phar @@ -96,13 +96,14 @@ for RELEASE in $RELEASES; do for REPO in $REPOS; do echo "Testing ${RELEASE}:${REPO}..." - BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=${BUILD_DIR}/vendor/${REPO}/features php ${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php) - echo "Behat Tags: $BEHAT_TAGS" + # The test runner of wp-cli/wp-cli-tests derives the environment-specific tags from the + # features of the package, and spreads its scenarios over WP_CLI_TEST_PARALLEL workers. + export BEHAT_FEATURES_FOLDER="vendor/${REPO}/features" set +e - "${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO + "${BUILD_DIR}/vendor/bin/run-behat-tests" --suite "$REPO" if [ $? -ne 0 ]; then - "${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO --rerun + "${BUILD_DIR}/vendor/bin/run-behat-tests" --suite "$REPO" --rerun if [ $? -ne 0 ]; then FAILED_PACKAGES="$FAILED_PACKAGES ${RELEASE}:${REPO}" fi diff --git a/bin/test-source b/bin/test-source index 204690c94..ff2c5add8 100755 --- a/bin/test-source +++ b/bin/test-source @@ -27,7 +27,7 @@ fi if [ "$TEST_PACKAGE" == "all" ]; then REPOS="wp-cli/wp-cli-bundle -wp-cli-/wp-cli +wp-cli/wp-cli $(cat ${BUILD_DIR}/vendor/wp-cli/wp-cli-bundle/composer.json | grep -oE "wp-cli/([a-z\-]*)-command")" fi @@ -43,13 +43,14 @@ for REPO in $REPOS; do echo "Testing package $REPO..." - BEHAT_TAGS=$(BEHAT_FEATURES_FOLDER=${BUILD_DIR}/vendor/${REPO}/features php ${BUILD_DIR}/vendor/wp-cli/wp-cli-tests/utils/behat-tags.php) - echo "Behat Tags: $BEHAT_TAGS" + # The test runner of wp-cli/wp-cli-tests derives the environment-specific tags from the + # features of the package, and spreads its scenarios over WP_CLI_TEST_PARALLEL workers. + export BEHAT_FEATURES_FOLDER="vendor/${REPO}/features" set +e - "${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO + "${BUILD_DIR}/vendor/bin/run-behat-tests" --suite "$REPO" if [ $? -ne 0 ]; then - "${BUILD_DIR}/vendor/bin/behat" --format progress $BEHAT_TAGS --strict --suite $REPO --rerun + "${BUILD_DIR}/vendor/bin/run-behat-tests" --suite "$REPO" --rerun if [ $? -ne 0 ]; then FAILED_PACKAGES="$FAILED_PACKAGES ${RELEASE}:${REPO}" fi