From 19c6c8718f6174e049dcdc69f9329bb90b1fa7c1 Mon Sep 17 00:00:00 2001 From: Ajay D'Souza Date: Sat, 11 Jan 2025 12:11:00 +0000 Subject: [PATCH] Update unit-tests.yml --- .github/workflows/unit-tests.yml | 52 +++++++++++--------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2c20692..890e7e2 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -50,53 +50,37 @@ jobs: services: mysql: - image: mysql:5.7 + # WP 5.4 is the first WP version which largely supports MySQL 8.0. + # See: https://core.trac.wordpress.org/ticket/49344 + # During the setting up of these tests, it became clear that MySQL 8.0 + # in combination with PHP < 7.4 is not properly/sufficiently supported + # within WP Core. + # See: https://core.trac.wordpress.org/ticket/52496 + image: mysql:${{ ( matrix.wp == 5.3 && '5.6' ) || ( (matrix.wp < 5.4 || matrix.php < 7.4) && '5.7' ) || '8.0' }} env: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: wordpress_test + MYSQL_ALLOW_EMPTY_PASSWORD: false ports: - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10 steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install Subversion - run: sudo apt-get update && sudo apt-get install -y subversion - - - name: Setup PHP + - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: mysql, mysqli coverage: none - tools: composer, phpunit - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Remove composer.lock - run: rm -f composer.lock + # The PHP 5.6 and 7.0 images don't include mysql[i] by default. + extensions: mysqli - - name: Install dependencies - run: | - composer install --no-interaction --prefer-dist --no-progress - - - name: Install WordPress Test Suite - env: - WP_VERSION: ${{ matrix.wp }} - run: | - bash phpunit/install.sh wordpress_test root root localhost ${{ matrix.wp }} + - name: Set up WordPress + run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }} + # On WP 5.2, PHPUnit 5.x, 6.x and 7.x are supported. + # On PHP >= 8.0, PHPUnit 7.5+ is needed, no matter what. - name: Determine supported PHPUnit version id: set_phpunit run: | @@ -135,9 +119,7 @@ jobs: phpunit --version which phpunit - - name: Run PHPUnit - env: - WP_TESTS_DIR: /tmp/wordpress-tests-lib + - name: Run the unit tests - single site run: vendor/bin/phpunit - name: Run the unit tests - multisite