Make WordPress Core


Ignore:
Timestamp:
06/06/2024 04:34:11 PM (4 months ago)
Author:
desrosj
Message:

Build/Test Tools: Make use of new reusable workflows for 5.9.

This updates the 5.9 branch to utilize the new reusable workflows in trunk introduced in [58165].

This also includes backports for a some additional improvements and bug fixes that are necessary for the local development environment to continue working long term:

  • The image and platform properties for the mysql container have been updated to always prefer amd64 containers (#60822).
  • macos-13 is now pinned for MacOS jobs instead of macos-latest (#61340).
  • Run E2E tests with and without SCRIPT_DEBUG (#58661).
  • Migrating to Docker Compose V2 (#60901).
  • Removing the version property from docker-compose.yml (#59416).
  • Improvements to how artifacts and comments for Playground testing are generated.
  • Removing SVN related commands causing failures (#61216).
  • Updating the actions/github-scripts action to the latest version.
  • Move the Memcached container into the Docker Compose config (#55700).
  • Configure Xdebug modes in the local Docker environment (#56022).

Merges [53895], [53552], [56113], [56114], [57918], [58157], [57124], [57125], [57249] to the 5.9 branch.

Props johnbillion, joemcgill, swissspidy, thelovekesh, narenin, mukesh27, JeffPaul, peterwilsoncc, zieladam, ockham, SergeyBiryukov, jorbin, Clorith, afragen.
See #55700, #61340, #60822, #61216, #60901, #61101, #59416, #59805, #61213, #58661.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/.github/workflows/phpunit-tests.yml

    r55516 r58358  
    2727  cancel-in-progress: true
    2828
    29 env:
    30   PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    31   LOCAL_PHP_MEMCACHED: ${{ false }}
    32   SLOW_TESTS: 'external-http,media,restapi'
     29# Disable permissions for all available scopes by default.
     30# Any needed permissions should be configured at the job level.
     31permissions: {}
     32
    3333
    3434jobs:
    35   # Runs the PHPUnit tests for WordPress.
    3635  #
    37   # Note: Steps running tests for PHP 8.1 jobs are allowed to "continue-on-error".
    38   # This prevents workflow runs from being marked as "failed" when only PHP 8.1 fails.
     36  # Creates a PHPUnit test job for each PHP/MySQL combination.
    3937  #
    40   # Performs the following steps:
    41   # - Sets environment variables.
    42   # - Sets up the environment variables needed for testing with memcached (if desired).
    43   # - Installs Node.js.
    44   # - Installs npm dependencies
    45   # - Configures caching for Composer.
    46   # - Installs Composer dependencies.
    47   # - Logs Docker debug information (about the Docker installation within the runner).
    48   # - Starts the WordPress Docker container.
    49   # - Starts the Memcached server after the Docker network has been created (if desired).
    50   # - Logs general debug information about the runner.
    51   # - Logs the running Docker containers.
    52   # - Logs debug information from inside the WordPress Docker container.
    53   # - Logs debug information about what's installed within the WordPress Docker containers.
    54   # - Install WordPress within the Docker container.
    55   # - Run the PHPUnit tests.
    56   # - Ensures version-controlled files are not modified or deleted.
    57   # - Checks out the WordPress Test reporter repository.
    58   # - Reconnect the directory to the Git repository.
    59   # - Submit the test results to the WordPress.org host test results.
    6038  test-php:
    61     name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    62     runs-on: ${{ matrix.os }}
    63     timeout-minutes: 20
     39    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
     40    uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests.yml@trunk
     41    permissions:
     42      contents: read
     43    secrets: inherit
    6444    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    6545    strategy:
    6646      fail-fast: false
    6747      matrix:
     48        os: [ ubuntu-latest ]
    6849        php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
    69         os: [ ubuntu-latest ]
     50        db-type: [ 'mysql' ]
     51        db-version: [ '5.7' ]
     52        multisite: [ false, true ]
    7053        memcached: [ false ]
    71         split_slow: [ false ]
    72         multisite: [ false, true ]
     54
    7355        include:
    74           # Additional "slow" jobs for PHP 5.6.
    75           - php: '5.6'
    76             os: ubuntu-latest
     56          # Allow PHP 8.1 tests to have errors.
     57          - php: '8.1'
     58            allow-errors: true
     59          # Include jobs for PHP 7.4 with memcached.
     60          - os: ubuntu-latest
     61            php: '7.4'
     62            db-type: 'mysql'
     63            db-version: '5.7'
     64            multisite: false
     65            memcached: true
     66          - os: ubuntu-latest
     67            php: '7.4'
     68            db-type: 'mysql'
     69            db-version: '5.7'
     70            multisite: true
     71            memcached: true
     72          # Report the results of the PHP 7.4 without memcached job.
     73          - os: ubuntu-latest
     74            php: '7.4'
     75            db-type: 'mysql'
     76            db-version: '5.7'
     77            multisite: false
    7778            memcached: false
    78             multisite: false
    79             split_slow: true
    80           - php: '5.6'
    81             os: ubuntu-latest
    82             memcached: false
    83             multisite: true
    84             split_slow: true
    85           # Include jobs for PHP 7.4 with memcached.
    86           - php: '7.4'
    87             os: ubuntu-latest
    88             memcached: true
    89             multisite: false
    90           - php: '7.4'
    91             os: ubuntu-latest
    92             memcached: true
    93             multisite: true
    94           # Report the results of the PHP 7.4 without memcached job.
    95           - php: '7.4'
    96             os: ubuntu-latest
    97             memcached: false
    98             multisite: false
    9979            report: true
    100 
    101     env:
    102       LOCAL_PHP: ${{ matrix.php }}-fpm
    103       LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
    104       PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    105 
    106     steps:
    107       - name: Configure environment variables
    108         run: |
    109           echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
    110           echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    111 
    112       - name: Checkout repository
    113         uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
    114 
    115       - name: Install Node.js
    116         uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
    117         with:
    118           node-version-file: '.nvmrc'
    119           cache: npm
    120 
    121       - name: Install npm dependencies
    122         run: npm ci
    123 
    124       # This date is used to ensure that the Composer cache is refreshed at least once every week.
    125       # http://man7.org/linux/man-pages/man1/date.1.html
    126       - name: "Get last Monday's date"
    127         id: get-date
    128         run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
    129 
    130       - name: Get Composer cache directory
    131         id: composer-cache
    132         run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
    133 
    134       - name: Cache Composer dependencies
    135         uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
    136         env:
    137           cache-name: cache-composer-dependencies
    138         with:
    139           path: ${{ steps.composer-cache.outputs.composer_dir }}
    140           key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }}
    141 
    142       - name: Install Composer dependencies
    143         run: |
    144           docker-compose run --rm php composer --version
    145 
    146           # Install using `composer update` as there is no `composer.lock` file.
    147           if [ ${{ env.LOCAL_PHP }} == '8.1-fpm' ]; then
    148             docker-compose run --rm php composer update --ignore-platform-reqs
    149           else
    150             docker-compose run --rm php composer update
    151           fi
    152 
    153       - name: Docker debug information
    154         run: |
    155           docker -v
    156           docker-compose -v
    157 
    158       - name: Start Docker environment
    159         run: |
    160           npm run env:start
    161 
    162       # The memcached server needs to start after the Docker network has been set up with `npm run env:start`.
    163       - name: Start the Memcached server.
    164         if: ${{ matrix.memcached }}
    165         run: |
    166           cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    167           docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    168 
    169       - name: General debug information
    170         run: |
    171           npm --version
    172           node --version
    173           curl --version
    174           git --version
    175           svn --version
    176 
    177       - name: Log running Docker containers
    178         run: docker ps -a
    179 
    180       - name: WordPress Docker container debug information
    181         run: |
    182           docker-compose run --rm mysql mysql --version
    183           docker-compose run --rm php php --version
    184           docker-compose run --rm php php -m
    185           docker-compose run --rm php php -i
    186           docker-compose run --rm php locale -a
    187 
    188       - name: Install WordPress
    189         run: npm run env:install
    190 
    191       - name: Run slow PHPUnit tests
    192         if: ${{ matrix.split_slow }}
    193         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
    194 
    195       - name: Run PHPUnit tests for single site excluding slow tests
    196         if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
    197         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
    198 
    199       - name: Run PHPUnit tests for Multisite excluding slow tests
    200         if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
    201         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
    202 
    203       - name: Run PHPUnit tests
    204         if: ${{ matrix.php >= '7.0' }}
    205         continue-on-error: ${{ matrix.php == '8.1' }}
    206         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
    207 
    208       - name: Run AJAX tests
    209         if: ${{ ! matrix.split_slow }}
    210         continue-on-error: ${{ matrix.php == '8.1' }}
    211         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    212 
    213       - name: Run ms-files tests as a multisite install
    214         if: ${{ matrix.multisite && ! matrix.split_slow }}
    215         continue-on-error: ${{ matrix.php == '8.1' }}
    216         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
    217 
    218       - name: Run external HTTP tests
    219         if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    220         continue-on-error: ${{ matrix.php == '8.1' }}
    221         run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
    222 
    223       # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    224       - name: Run (xDebug) tests
    225         if: ${{ ! matrix.split_slow }}
    226         continue-on-error: ${{ matrix.php == '8.1' }}
    227         run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
    228 
    229       - name: Ensure version-controlled files are not modified or deleted
    230         run: git diff --exit-code
    231 
    232       - name: Checkout the WordPress Test Reporter
    233         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    234         uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
    235         with:
    236           repository: 'WordPress/phpunit-test-runner'
    237           path: 'test-runner'
    238 
    239       - name: Submit test results to the WordPress.org host test results
    240         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    241         env:
    242           WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
    243         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
     80    with:
     81      os: ${{ matrix.os }}
     82      php: ${{ matrix.php }}
     83      db-type: ${{ matrix.db-type }}
     84      db-version: ${{ matrix.db-version }}
     85      multisite: ${{ matrix.multisite }}
     86      memcached: ${{ matrix.memcached }}
     87      phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
     88      report: ${{ matrix.report || false }}
     89      allow-errors: ${{ matrix.allow-errors || false }}
    24490
    24591  slack-notifications:
    24692    name: Slack Notifications
    24793    uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
     94    permissions:
     95      actions: read
     96      contents: read
    24897    needs: [ test-php ]
    24998    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
     
    259108    name: Failed workflow tasks
    260109    runs-on: ubuntu-latest
     110    permissions:
     111      actions: write
    261112    needs: [ test-php, slack-notifications ]
    262113    if: |
Note: See TracChangeset for help on using the changeset viewer.