diff --git a/.github/workflows/reusable-upgrade-testing.yml b/.github/workflows/reusable-upgrade-testing.yml index e4c60e6ffea9f..5a35fa70dc701 100644 --- a/.github/workflows/reusable-upgrade-testing.yml +++ b/.github/workflows/reusable-upgrade-testing.yml @@ -79,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 @@ -126,14 +150,16 @@ 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: 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 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.