Make WordPress Core


Ignore:
Timestamp:
07/02/2024 07:59:42 PM (20 months ago)
Author:
desrosj
Message:

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

This updates the 5.0 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).
  • 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.
  • Cache the results of PHP_CodeSniffer runs (#49783).
  • Move the Memcached container into the Docker Compose config (#55700).
  • Improvements to the healthcheck command for the mysql container (#58867).
  • Skip some tests when not in the primary branch (#50401).

Merges [49264], [51673], [52179], [53552], [53895], [56464], [57918], [58157], [57124], [57125], [57249] to the 5.0 branch.

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

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

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

    r55525 r58628  
    2222# Cancels all previous workflow runs for pull requests that have not completed.
    2323concurrency:
    24     # The concurrency group contains the workflow name and the branch name for pull requests
    25     # or the commit hash for any other events.
     24  # The concurrency group contains the workflow name and the branch name for pull requests
     25  # or the commit hash for any other events.
    2626  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
    2727  cancel-in-progress: true
    2828
    29 env:
    30   LOCAL_DIR: build
    31   PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    32   COMPOSER_INSTALL: ${{ false }}
    33   # Controls which npm script to use for running PHPUnit tests. Options ar `php` and `php-composer`.
    34   PHPUNIT_SCRIPT: php
    35   LOCAL_PHP_MEMCACHED: ${{ false }}
    36   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: {}
    3732
    3833jobs:
    39   # Sets up WordPress for testing or development use.
    4034  #
    41   # Performs the following steps:
    42   # - Cancels all previous workflow runs for pull requests that have not completed.
    43   # - Checks out the repository.
    44   # - Logs debug information about the GitHub Action runner.
    45   # - Installs NodeJS.
    46   # _ Installs npm dependencies.
    47   # - Builds WordPress to run from the `build` directory.
    48   # - Creates a ZIP file of compiled WordPress.
    49   # - Uploads ZIP file as an artifact.
    50   setup-wordpress:
    51     name: Setup WordPress
    52     runs-on: ubuntu-latest
     35  # Creates a PHPUnit test job for each PHP combination.
     36  #
     37  test-php:
     38    name: PHP ${{ matrix.php }}
     39    uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v1.yml@trunk
     40    permissions:
     41      contents: read
     42    secrets: inherit
    5343    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    54 
    55     steps:
    56       - name: Checkout repository
    57         uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
    58 
    59       - name: Log debug information
    60         run: |
    61           echo "$GITHUB_REF"
    62           echo "$GITHUB_EVENT_NAME"
    63           npm --version
    64           node --version
    65           curl --version
    66           git --version
    67           svn --version
    68           php --version
    69           php -i
    70           locale -a
    71 
    72       - name: Set up Node.js
    73         uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
    74         with:
    75           node-version-file: '.nvmrc'
    76           cache: npm
    77 
    78       - name: Install Dependencies
    79         run: npm ci
    80 
    81       - name: Build WordPress
    82         run: npm run build
    83 
    84       - name: Create ZIP artifact
    85         uses: thedoctor0/zip-release@a24011d8d445e4da5935a7e73c1f98e22a439464 # v0.7.1
    86         with:
    87           filename: built-wp-${{ github.sha }}.zip
    88           exclusions: '*.git* /*node_modules/* packagehash.txt'
    89 
    90       - name: Upload build artifact
    91         uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
    92         with:
    93           name: built-wp-${{ github.sha }}
    94           path: built-wp-${{ github.sha }}.zip
    95           if-no-files-found: error
    96 
    97   # Runs the PHPUnit tests for WordPress.
    98   #
    99   # Performs the following steps:
    100   # - Sets environment variables.
    101   # - Sets up the environment variables needed for testing with memcached (if desired).
    102   # - Downloads the built WordPress artifact from the previous job.
    103   # - Unzips the artifact.
    104   # - Installs NodeJS.
    105   # _ Installs npm dependencies.
    106   # - Configures caching for Composer.
    107   # _ Installs Composer dependencies (if desired).
    108   # - Logs Docker debug information (about the Docker installation within the runner).
    109   # - Starts the WordPress Docker container.
    110   # - Starts the Memcached server after the Docker network has been created (if desired).
    111   # - Logs general debug information about the runner.
    112   # - Logs the running Docker containers.
    113   # - Logs debug information from inside the WordPress Docker container.
    114   # - Logs debug information about what's installed within the WordPress Docker containers.
    115   # - Install WordPress within the Docker container.
    116   # - Run the PHPUnit tests.
    117   # - Checks out the WordPress Test reporter repository.
    118   # - Reconnect the directory to the Git repository.
    119   # - Submit the test results to the WordPress.org host test results.
    120   test-php:
    121     name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    122     needs: setup-wordpress
    123     runs-on: ${{ matrix.os }}
    124     timeout-minutes: 20
    12544    strategy:
    12645      fail-fast: false
    12746      matrix:
     47        os: [ ubuntu-latest ]
    12848        php: [ '5.3', '5.4', '5.5' ]
    129         os: [ ubuntu-latest ]
    130         memcached: [ false ]
    13149        split_slow: [ false, true ]
    13250        multisite: [ false, true ]
     51        memcached: [ false ]
     52
    13353        include:
    13454          # Include jobs for PHP 7.3 with memcached.
     
    220140            multisite: true
    221141
    222     env:
    223       LOCAL_PHP: ${{ matrix.php }}-fpm
    224       LOCAL_PHPUNIT: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}-fpm
    225       LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
    226       PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    227 
    228     steps:
    229       - name: Configure environment variables
    230         run: |
    231           echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
    232           echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    233 
    234       - name: Download the built WordPress artifact
    235         uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
    236         with:
    237           name: built-wp-${{ github.sha }}
    238 
    239       - name: Unzip built artifact
    240         run: unzip built-wp-${{ github.sha }}.zip
    241 
    242       - name: Set up Node.js
    243         uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
    244         with:
    245           node-version-file: '.nvmrc'
    246           cache: npm
    247 
    248       - name: Install Dependencies
    249         run: npm ci
    250 
    251       - name: Cache Composer dependencies
    252         if: ${{ env.COMPOSER_INSTALL == true }}
    253         uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
    254         env:
    255           cache-name: cache-composer-dependencies
    256         with:
    257           path: ${{ steps.composer-cache.outputs.dir }}
    258           key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    259 
    260       - name: Install Composer dependencies
    261         if: ${{ env.COMPOSER_INSTALL == true }}
    262         run: |
    263           docker-compose run --rm php composer --version
    264           docker-compose run --rm php composer install
    265 
    266       - name: Docker debug information
    267         run: |
    268           docker -v
    269           docker-compose -v
    270 
    271       - name: Start Docker environment
    272         run: |
    273           npm run env:start
    274 
    275       # The memcached server needs to start after the Docker network has been set up with `npm run env:start`.
    276       - name: Start the Memcached server.
    277         if: ${{ matrix.memcached }}
    278         run: |
    279           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
    280           docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    281 
    282       - name: General debug information
    283         run: |
    284           npm --version
    285           node --version
    286           curl --version
    287           git --version
    288           svn --version
    289 
    290       - name: Log running Docker containers
    291         run: docker ps -a
    292 
    293       - name: WordPress Docker container debug information
    294         run: |
    295           docker-compose run --rm mysql mysql --version
    296           docker-compose run --rm php php --version
    297           docker-compose run --rm php php -m
    298           docker-compose run --rm php php -i
    299           docker-compose run --rm php locale -a
    300 
    301       - name: Install WordPress
    302         run: npm run env:install
    303 
    304       - name: Run slow PHPUnit tests
    305         if: ${{ matrix.split_slow }}
    306         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
    307 
    308       - name: Run PHPUnit tests for single site excluding slow tests
    309         if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
    310         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
    311 
    312       - name: Run PHPUnit tests for Multisite excluding slow tests
    313         if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
    314         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
    315 
    316       - name: Run PHPUnit tests
    317         if: ${{ matrix.php >= '7.0' }}
    318         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    319 
    320       - name: Run AJAX tests
    321         if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    322         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    323 
    324       - name: Run ms-files tests as a multisite install
    325         if: ${{ matrix.multisite && ! matrix.split_slow }}
    326         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    327 
    328       - name: Run external HTTP tests
    329         if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    330         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    331 
    332       - name: Checkout the WordPress Test Reporter
    333         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    334         uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
    335         with:
    336           repository: 'WordPress/phpunit-test-runner'
    337           path: 'test-runner'
    338 
    339       - name: Set up the Git repository
    340         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    341         run: |
    342           git init
    343           git remote add origin https://github.com/WordPress/wordpress-develop.git
    344           git fetch
    345           git reset origin/trunk
    346 
    347       - name: Submit test results to the WordPress.org host test results
    348         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
    349         env:
    350           WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
    351         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
     142    with:
     143      os: ${{ matrix.os }}
     144      php: ${{ matrix.php }}
     145      phpunit: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}
     146      multisite: ${{ matrix.multisite }}
     147      split_slow: ${{ matrix.split_slow }}
     148      memcached: ${{ matrix.memcached }}
     149      phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    352150
    353151  slack-notifications:
    354152    name: Slack Notifications
    355153    uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
    356     needs: [ setup-wordpress, test-php ]
     154    permissions:
     155      actions: read
     156      contents: read
     157    needs: [ test-php ]
    357158    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
    358159    with:
     
    367168    name: Failed workflow tasks
    368169    runs-on: ubuntu-latest
     170    permissions:
     171      actions: write
    369172    needs: [ test-php, slack-notifications ]
    370173    if: |
     
    379182    steps:
    380183      - name: Dispatch workflow run
    381         uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
     184        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
    382185        with:
    383186          retries: 2
Note: See TracChangeset for help on using the changeset viewer.