From 1e15b5b7c33a02411f87252ab30886327bf68085 Mon Sep 17 00:00:00 2001 From: Ajay D'Souza Date: Sun, 12 Jan 2025 13:25:16 +0000 Subject: [PATCH] Update unit-tests.yml --- .github/workflows/unit-tests.yml | 100 ++++++++++++++----------------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e0f2d9c..2d42b31 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -5,12 +5,12 @@ on: # Prevent the build from running when there are only irrelevant changes. push: paths-ignore: - - "**.md" - - "**.txt" + - '**.md' + - '**.txt' pull_request: paths-ignore: - - "**.md" - - "**.txt" + - '**.md' + - '**.txt' # Allow manually triggering the workflow. workflow_dispatch: @@ -23,25 +23,25 @@ jobs: matrix: # Notes regarding supported versions in WP: # The base matrix only contains the PHP versions which are supported on all supported WP versions. - php: ["7.2", "7.3", "7.4", "8.0"] - wp: ["latest"] + php: ['8.0', '8.1', '7.4'] + wp: ['latest'] experimental: [false] include: - - php: "8.1" - wp: "trunk" + # Complement the builds run via the matrix with high/low WP builds for PHP 7.4 and 8.0. + # PHP 8.0 is sort of supported since WP 5.6. + # PHP 7.4 is supported since WP 5.3. + - php: '8.3' + wp: 'latest' experimental: true - - php: "8.2" - wp: "trunk" + - php: '8.2' + wp: 'latest' experimental: true - - php: "8.0" - wp: "6.0" + - php: '8.2' + wp: '6.3' experimental: true - - php: "7.4" - wp: "6.3" - experimental: true - - php: "7.4" - wp: "latest" + - php: '8.0' + wp: '5.9' experimental: true name: "PHP ${{ matrix.php }} - WP ${{ matrix.wp }}" @@ -65,69 +65,61 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + extensions: mysqli, mysql coverage: none - extensions: mysqli - - name: Set up WordPress - run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }} - - # Determine the type of Composer install which is needed. - # 1. WP 5.9 or higher - all PHPUnit versions needed are supported, use the most appropriate one. - # 2. WP 5.9 or higher with PHP 8.2 (RC) - not all dependencies of PHPUnit have declared PHP 8.2 compatibility, so needs ignore platform. - # 3. WP < 5.9 with PHP < 8.0 - PHPUnit 5 - 7 supported, use the most appropriate one. - # 4. WP < 5.9 with PHP 8.0 or higher - PHPUnit 5 - 7 supported, needs ignore platform reqs to install PHPUnit 7 for PHP >= 8.0. - - name: Determine the type of Composer install to use - id: composer_toggle + # 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: | - if [[ "${{ matrix.wp }}" =~ ^(trunk|latest|5\.9|[6789]\.[0-9])$ ]]; then - if [[ "${{ matrix.php }}" != "8.2" ]]; then - echo '::set-output name=TYPE::1' - else - echo '::set-output name=TYPE::2' - fi - elif [[ "${{ matrix.php }}" > "7.4" ]]; then - echo '::set-output name=TYPE::4' + if [[ "${{ matrix.php }}" > "8.0" ]]; then + echo "PHPUNIT=9.*" >> $GITHUB_ENV else - echo '::set-output name=TYPE::3' + echo "PHPUNIT=5.7.*||6.*||7.5.*||8.5.*" >> $GITHUB_ENV fi - # Remove the PHPUnit requirement for WP 5.9 and higher in favour of letting the Polyfills manage it. - # The Composer command will exit with error code 2 as the package is not removed, so ignore "failure" of this step. - - name: Conditionally remove PHPUnit requirement - if: ${{ steps.composer_toggle.outputs.TYPE == '1' || steps.composer_toggle.outputs.TYPE == '2' }} - continue-on-error: true - run: composer remove --dev phpunit/phpunit --no-update --no-interaction || true + - name: 'Composer: set up PHPUnit' + env: + PHPUNIT: ${{ env.PHPUNIT }} + run: composer require --no-update phpunit/phpunit:"${{ env.PHPUNIT }}" # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - - name: Install Composer dependencies - normal - if: ${{ steps.composer_toggle.outputs.TYPE == '1' || steps.composer_toggle.outputs.TYPE == '3' }} + - name: Install Composer dependencies for PHP < 8.0 + if: ${{ matrix.php < 8.0 }} uses: "ramsey/composer-install@v2" - # For PHP 8.0 and above on WP 5.2 - 5.8, we need to install with ignore platform reqs as not all dependencies allow it. - - name: Install Composer dependencies with ignore platform reqs - if: ${{ steps.composer_toggle.outputs.TYPE == '2' || steps.composer_toggle.outputs.TYPE == '4' }} + # For the PHP 8.0 and above, we need to install with ignore platform reqs as not all dependencies allow it yet. + - name: Install Composer dependencies for PHP >= 8.0 + if: ${{ matrix.php >= 8.0 }} uses: "ramsey/composer-install@v2" with: - composer-options: --ignore-platform-req=php + composer-options: --ignore-platform-reqs + + - name: Install Subversion + run: sudo apt-get install subversion + + - name: Set up WordPress + run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }} - name: Tool versions - continue-on-error: true run: | php --version composer --version - vendor/bin/phpunit --version + ./vendor/bin/phpunit --version + which ./vendor/bin/phpunit - name: Run the unit tests - single site - run: vendor/bin/phpunit + run: ./vendor/bin/phpunit - name: Run the unit tests - multisite - run: vendor/bin/phpunit env: WP_MULTISITE: 1 + run: ./vendor/bin/phpunit