Make WordPress Core

Changeset 56439


Ignore:
Timestamp:
08/24/2023 01:08:40 PM (14 months ago)
Author:
desrosj
Message:

Build/Test Tools: Expand database testing to account for all supported versions and types.

This modifies the PHPUnit workflow to add MySQL version 8.0 to the strategy matrix. It also adds an additional strategy matrix to expand testing to include several supported MariaDB versions.

To prevent repeating code, the business logic of the PHPUnit testing has been moved to a new, callable workflow.

Because callable workflows target a specific branch, branches created in the future will continue to benefit from improvements made to the workflow in trunk without requiring backports. If a breaking change is required, older branches will need to be updated to target the commit SHA representing the final commit of the previous state.

Props johnbillion, pento, boonebgorges, netweb, nacin, desrosj.
Fixes #30462.

Location:
trunk/.github/workflows
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/phpunit-tests.yml

    r56402 r56439  
    3636
    3737jobs:
    38   # Runs the PHPUnit tests for WordPress.
    3938  #
    40   # Performs the following steps:
    41   # - Sets environment variables.
    42   # - Checks out the repository.
    43   # - Sets up Node.js.
    44   # - Sets up PHP.
    45   # - Installs Composer dependencies.
    46   # - Installs npm dependencies
    47   # - Logs general debug information about the runner.
    48   # - Logs Docker debug information (about the Docker installation within the runner).
    49   # - Starts the WordPress Docker container.
    50   # - Logs the running Docker containers.
    51   # - Logs debug information about what's installed within the WordPress Docker containers.
    52   # - Install WordPress within the Docker container.
    53   # - Run the PHPUnit tests.
    54   # - Ensures version-controlled files are not modified or deleted.
    55   # - Checks out the WordPress Test reporter repository.
    56   # - Submit the test results to the WordPress.org host test results.
    57   test-php:
    58     name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    59     runs-on: ${{ matrix.os }}
     39  # Creates a PHPUnit test job for each PHP/MySQL combination.
     40  #
     41  test-with-mysql:
     42    name: PHP ${{ matrix.php }}
     43    uses: desrosj/wordpress-develop/.github/workflows/phpunit-tests-run.yml@expanded-db-testing-callable-workflow
    6044    permissions:
    6145      contents: read
    62     timeout-minutes: 20
    6346    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    6447    strategy:
    6548      fail-fast: false
    6649      matrix:
     50        os: [ ubuntu-latest ]
    6751        php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
    68         os: [ ubuntu-latest ]
     52        db-type: [ 'mysql' ]
     53        db-version: [ '5.7', '8.0' ]
     54        multisite: [ false, true ]
    6955        memcached: [ false ]
    70         multisite: [ false, true ]
     56
    7157        include:
    7258          # Include jobs for PHP 7.4 with memcached.
    73           - php: '7.4'
    74             os: ubuntu-latest
     59          - os: ubuntu-latest
     60            php: '7.4'
     61            db-type: 'mysql'
     62            db-version: '5.7'
     63            multisite: false
    7564            memcached: true
     65          - os: ubuntu-latest
     66            php: '7.4'
     67            db-type: 'mysql'
     68            db-version: '5.7'
     69            multisite: true
     70            memcached: true
     71          # Report the results of the PHP 7.4 without memcached job.
     72          - os: ubuntu-latest
     73            php: '7.4'
     74            db-type: 'mysql'
     75            db-version: '5.7'
    7676            multisite: false
    77           - php: '7.4'
    78             os: ubuntu-latest
    79             memcached: true
    80             multisite: true
    81           # Report the results of the PHP 7.4 without memcached job.
    82           - php: '7.4'
    83             os: ubuntu-latest
    8477            memcached: false
    85             multisite: false
    8678            report: true
     79    with:
     80      os: ${{ matrix.os }}
     81      php: ${{ matrix.php }}
     82      db-type: ${{ matrix.db-type }}
     83      db-version: ${{ matrix.db-version }}
     84      multisite: ${{ matrix.multisite }}
     85      memcached: ${{ matrix.memcached }}
     86      phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
     87      report: ${{ matrix.report || false }}
    8788
    88     env:
    89       LOCAL_PHP: ${{ matrix.php }}-fpm
    90       LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
    91       PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
     89  #
     90  # Creates a PHPUnit test job for each PHP/MariaDB combination.
     91  #
     92  test-with-mariadb:
     93    name: PHP ${{ matrix.php }}
     94    uses: desrosj/wordpress-develop/.github/workflows/phpunit-tests-run.yml@expanded-db-testing-callable-workflow
     95    permissions:
     96      contents: read
     97    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
     98    strategy:
     99      fail-fast: false
     100      matrix:
     101        os: [ ubuntu-latest ]
     102        php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
     103        db-type: [ 'mariadb' ]
     104        db-version: [ '10.4', '10.6', '10.11', '11.0' ]
     105        multisite: [ false, true ]
     106        memcached: [ false ]
     107        report: [ false ]
    92108
    93     steps:
    94       - name: Configure environment variables
    95         run: |
    96           echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
    97           echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    98 
    99       - name: Checkout repository
    100         uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
    101 
    102       - name: Set up Node.js
    103         uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
    104         with:
    105           node-version-file: '.nvmrc'
    106           cache: npm
    107 
    108       ##
    109       # This allows Composer dependencies to be installed using a single step.
    110       #
    111       # Since the tests are currently run within the Docker containers where the PHP version varies,
    112       # the same PHP version needs to be configured for the action runner machine so that the correct
    113       # dependency versions are installed and cached.
    114       ##
    115       - name: Set up PHP
    116         uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0
    117         with:
    118           php-version: '${{ matrix.php }}'
    119           coverage: none
    120 
    121       # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
    122       # passing a custom cache suffix ensures that the cache is flushed at least once per week.
    123       - name: Install Composer dependencies
    124         uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
    125         with:
    126           custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")
    127 
    128       - name: Install npm dependencies
    129         run: npm ci
    130 
    131       - name: General debug information
    132         run: |
    133           npm --version
    134           node --version
    135           curl --version
    136           git --version
    137           svn --version
    138           composer --version
    139           locale -a
    140 
    141       - name: Docker debug information
    142         run: |
    143           docker -v
    144           docker-compose -v
    145 
    146       - name: Start Docker environment
    147         run: |
    148           npm run env:start
    149 
    150       - name: Log running Docker containers
    151         run: docker ps -a
    152 
    153       - name: WordPress Docker container debug information
    154         run: |
    155           docker-compose run --rm mysql mysql --version
    156           docker-compose run --rm php php --version
    157           docker-compose run --rm php php -m
    158           docker-compose run --rm php php -i
    159           docker-compose run --rm php locale -a
    160 
    161       - name: Install WordPress
    162         run: npm run env:install
    163 
    164       - name: Run PHPUnit tests
    165         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
    166 
    167       - name: Run AJAX tests
    168         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    169 
    170       - name: Run ms-files tests as a multisite install
    171         if: ${{ matrix.multisite }}
    172         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
    173 
    174       - name: Run external HTTP tests
    175         if: ${{ ! matrix.multisite }}
    176         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
    177 
    178       # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    179       - name: Run (Xdebug) tests
    180         run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
    181 
    182       - name: Ensure version-controlled files are not modified or deleted
    183         run: git diff --exit-code
    184 
    185       - name: Checkout the WordPress Test Reporter
    186         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    187         uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
    188         with:
    189           repository: 'WordPress/phpunit-test-runner'
    190           path: 'test-runner'
    191 
    192       - name: Submit test results to the WordPress.org host test results
    193         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    194         env:
    195           WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
    196         run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
     109        include:
     110        # Include jobs for PHP 7.4 with memcached.
     111        - os: ubuntu-latest
     112          php: '7.4'
     113          db-type: 'mariadb'
     114          db-version: '11.0'
     115          multisite: false
     116          memcached: true
     117          report: false
     118        - os: ubuntu-latest
     119          php: '7.4'
     120          db-type: 'mariadb'
     121          db-version: '11.0'
     122          multisite: true
     123          memcached: true
     124          report: false
     125    with:
     126      os: ${{ matrix.os }}
     127      php: ${{ matrix.php }}
     128      db-type: ${{ matrix.db-type }}
     129      db-version: ${{ matrix.db-version }}
     130      multisite: ${{ matrix.multisite }}
     131      memcached: ${{ matrix.memcached }}
     132      phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
     133      report: ${{ matrix.report }}
    197134
    198135  slack-notifications:
     
    202139      actions: read
    203140      contents: read
    204     needs: [ test-php ]
     141    needs: [ test-with-mysql, test-with-mariadb ]
    205142    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    206143    with:
    207       calling_status: ${{ needs.test-php.result == 'success' && 'success' || needs.test-php.result == 'cancelled' && 'cancelled' || 'failure' }}
     144      calling_status: ${{ needs.test-with-mysql.result == 'success' && needs.test-with-mariadb.result == 'success' && 'success' || ( needs.test-with-mysql.result == 'cancelled' || needs.test-with-mariadb.result == 'cancelled' ) && 'cancelled' || 'failure' }}
    208145    secrets:
    209146      SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
Note: See TracChangeset for help on using the changeset viewer.