From 23dd0781cd49cb9f5fcfa4f940af806de42d8f46 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:57:07 -0400 Subject: [PATCH 1/3] Upgrade tests should not run past the new version --- .../workflows/reusable-upgrade-testing.yml | 39 +++++++++++++++++++ .github/workflows/upgrade-testing.yml | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml index e4c60e6ffea9f..cb0041ca5113a 100644 --- a/.github/workflows/reusable-upgrade-testing.yml +++ b/.github/workflows/reusable-upgrade-testing.yml @@ -42,6 +42,43 @@ on: permissions: {} jobs: + # Checks that a valid version range is being tested. + # + # Upgrade testing should not occur when the original version is greater than or equal to the new version. + check-version: + name: Check for a valid test scenario + runs-on: ${{ inputs.os }} + permissions: + contents: read + timeout-minutes: 5 + + steps: + - name: Compare versions + id: compare + run: | + old="${{ inputs.old_version }}" + new="${{ inputs.new_version }}" + + # Normalize versions to X.Y.Z format (add .0 if needed) + normalize() { + local ver=$1 + if [[ $ver =~ ^[0-9]+\.[0-9]+$ ]]; then + echo "${ver}.0" + else + echo "$ver" + fi + } + + old_norm=$(normalize "$old") + new_norm=$(normalize "$new") + + # Compare using sort -V (version sort) + if printf '%s\n%s\n' "$old_norm" "$new_norm" | sort -V -C; then + echo "result=true" >> "$GITHUB_OUTPUT" + else + echo "result=false" >> "$GITHUB_OUTPUT" + fi + # Runs upgrade tests on a build of WordPress. # # Performs the following steps: @@ -58,6 +95,8 @@ jobs: # - Checks the version of WordPress after the upgrade. upgrade-tests: name: ${{ inputs.wp }} to ${{ inputs.new-version }} / PHP ${{ inputs.php }} with ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }} + needs: [ check-version ] + if: ${{ needs.check-version.outputs.should_run == 'true' }} permissions: contents: read runs-on: ${{ inputs.os }} diff --git a/.github/workflows/upgrade-testing.yml b/.github/workflows/upgrade-testing.yml index fb1d973344c18..75355a41b3bcb 100644 --- a/.github/workflows/upgrade-testing.yml +++ b/.github/workflows/upgrade-testing.yml @@ -91,7 +91,7 @@ jobs: db-type: ${{ matrix.db-type }} db-version: ${{ matrix.db-version }} wp: ${{ matrix.wp }} - new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }} + new-version: ${{ inputs.new-version && inputs.new-version || '6.6' }} multisite: ${{ matrix.multisite }} # Tests 6.x releases where the WordPress database version changed on the oldest and newest supported versions of PHP 7 & 8. From f094082c65f48f35bcfe8555551b6e8118468df4 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:49:19 -0400 Subject: [PATCH 2/3] Move the version check into the same job --- .../workflows/reusable-upgrade-testing.yml | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml index cb0041ca5113a..0ba8c8f9dc2d1 100644 --- a/.github/workflows/reusable-upgrade-testing.yml +++ b/.github/workflows/reusable-upgrade-testing.yml @@ -42,43 +42,6 @@ on: permissions: {} jobs: - # Checks that a valid version range is being tested. - # - # Upgrade testing should not occur when the original version is greater than or equal to the new version. - check-version: - name: Check for a valid test scenario - runs-on: ${{ inputs.os }} - permissions: - contents: read - timeout-minutes: 5 - - steps: - - name: Compare versions - id: compare - run: | - old="${{ inputs.old_version }}" - new="${{ inputs.new_version }}" - - # Normalize versions to X.Y.Z format (add .0 if needed) - normalize() { - local ver=$1 - if [[ $ver =~ ^[0-9]+\.[0-9]+$ ]]; then - echo "${ver}.0" - else - echo "$ver" - fi - } - - old_norm=$(normalize "$old") - new_norm=$(normalize "$new") - - # Compare using sort -V (version sort) - if printf '%s\n%s\n' "$old_norm" "$new_norm" | sort -V -C; then - echo "result=true" >> "$GITHUB_OUTPUT" - else - echo "result=false" >> "$GITHUB_OUTPUT" - fi - # Runs upgrade tests on a build of WordPress. # # Performs the following steps: @@ -95,8 +58,6 @@ jobs: # - Checks the version of WordPress after the upgrade. upgrade-tests: name: ${{ inputs.wp }} to ${{ inputs.new-version }} / PHP ${{ inputs.php }} with ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }} - needs: [ check-version ] - if: ${{ needs.check-version.outputs.should_run == 'true' }} permissions: contents: read runs-on: ${{ inputs.os }} @@ -118,39 +79,63 @@ jobs: -c "exec docker-entrypoint.sh mysqld${{ inputs.db-type == 'mysql' && contains( fromJSON('["7.2", "7.3"]'), inputs.php ) && ' --default-authentication-plugin=mysql_native_password' || '' }}" steps: + - name: Compare versions + id: version_check + env: + OLD_VERSION: ${{ inputs.wp }} + NEW_VERSION: ${{ inputs.new-version }} + run: | + # Add .0 if version is X.Y format + [[ $OLD_VERSION =~ ^[0-9]+\.[0-9]+$ ]] && OLD_VERSION+=".0" + [[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+$ ]] && NEW_VERSION+=".0" + + if printf '%s\n%s\n' "$OLD_VERSION" "$NEW_VERSION" | sort -V -C; then + echo "valid=true" >> "$GITHUB_OUTPUT" + else + echo "valid=false" >> "$GITHUB_OUTPUT" + fi + - name: Set up PHP ${{ inputs.php }} uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3 + if: ${{ steps.version_check.outputs.valid == 'true' }} with: php-version: '${{ inputs.php }}' coverage: none tools: wp-cli - name: Download WordPress ${{ inputs.wp }} + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core download --version="${WP_VERSION}" env: WP_VERSION: ${{ inputs.wp }} - name: Create wp-config.php file + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost="127.0.0.1:${DB_PORT}" env: DB_PORT: ${{ job.services.database.ports['3306'] }} - name: Install WordPress + if: ${{ steps.version_check.outputs.valid == 'true' }} run: | wp core ${{ inputs.multisite && 'multisite-install' || 'install' }} \ --url=http://localhost/ --title="Upgrade Test" --admin_user=admin \ --admin_password=password --admin_email=me@example.org --skip-email - name: Pre-upgrade version check + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core version - name: Update to the latest minor version + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core update --minor - name: Update the database after the minor update + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core update-db ${{ inputs.multisite && '--network' || '' }} - name: Post-upgrade version check after the minor update + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core version - name: Download build artifact for the current branch @@ -172,7 +157,9 @@ jobs: WP_VERSION: ${{ inputs.new-version }} - name: Update the database + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core update-db ${{ inputs.multisite && '--network' || '' }} - name: Post-upgrade version check + if: ${{ steps.version_check.outputs.valid == 'true' }} run: wp core version From 932cf49f6044cf76e5f88ff12aa44eaa75a7f78f Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 1 Oct 2025 16:00:41 -0400 Subject: [PATCH 3/3] Update last conditional --- .github/workflows/reusable-upgrade-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml index 0ba8c8f9dc2d1..5a35fa70dc701 100644 --- a/.github/workflows/reusable-upgrade-testing.yml +++ b/.github/workflows/reusable-upgrade-testing.yml @@ -150,7 +150,7 @@ jobs: wp core update develop.zip - name: Upgrade to WordPress ${{ inputs.new-version }} - if: ${{ inputs.new-version != 'develop' }} + if: ${{ inputs.new-version != 'develop' && steps.version_check.outputs.valid == 'true' }} run: | wp core update ${{ 'latest' != inputs.new-version && '--version="${WP_VERSION}"' || '' }} env: