Make WordPress Core


Ignore:
Timestamp:
03/01/2021 08:21:23 PM (6 years ago)
Author:
johnbillion
Message:

Build/Test Tools: PHPUnit test improvements:

  • Switch back to running the PHPUnit test suite against the src directory instead of build
  • Increase the reliability of backing up the mu-plugins directory during tests
  • Split the PHPUnit tests for PHP versions below 7.0 in half, allowing them to run in parallel and reduce the overall test run duration on GitHub Actions

Merges [50441-50444] to the 5.7 branch.

Fixes #51734, #51735, #52645

Location:
branches/5.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.7

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

    r50413 r50464  
    1616
    1717env:
    18   LOCAL_DIR: build
    1918  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    2019  COMPOSER_INSTALL: ${{ false }}
    … …  
    2221  PHPUNIT_SCRIPT: php
    2322  LOCAL_PHP_MEMCACHED: ${{ false }}
     23  SLOW_TESTS: 'external-http,media,restapi'
    2424
    2525jobs:
    26   # Sets up WordPress for testing or development use.
     26  # Sets up the workflow for testing.
    2727  #
    2828  # Performs the following steps:
    2929  # - Cancels all previous workflow runs for pull requests that have not completed.
    30   # - Checks out the repository.
    31   # - Logs debug information about the runner container.
    32   # - Installs NodeJS 14.
    33   # - Sets up caching for NPM.
    34   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    35   # - Builds WordPress to run from the `build` directory.
    36   # - Creates a ZIP file of compiled WordPress.
    37   # - Uploads ZIP file as an artifact.
    38   setup-wordpress:
    39     name: Setup WordPress
     30  setup-workflow:
     31    name: Setup Workflow
    4032    runs-on: ubuntu-latest
    4133    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    … …  
    4739        with:
    4840          access_token: ${{ github.token }}
    49 
    50       - name: Checkout repository
    51         uses: actions/checkout@v2
    52 
    53       - name: Log debug information
    54         run: |
    55           echo "$GITHUB_REF"
    56           echo "$GITHUB_EVENT_NAME"
    57           npm --version
    58           node --version
    59           curl --version
    60           git --version
    61           svn --version
    62           php --version
    63           php -i
    64           locale -a
    65 
    66       - name: Install NodeJS
    67         uses: actions/setup-node@v2
    68         with:
    69           node-version: 14
    70 
    71       - name: Cache NodeJS modules
    72         uses: actions/cache@v2
    73         env:
    74           cache-name: cache-node-modules
    75         with:
    76           # npm cache files are stored in `~/.npm` on Linux/macOS
    77           path: ~/.npm
    78           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    79           restore-keys: |
    80             ${{ runner.os }}-npm-
    81 
    82       - name: Install Dependencies
    83         run: npx install-changed --install-command="npm ci"
    84 
    85       - name: Build WordPress
    86         run: npm run build
    87 
    88       - name: Create ZIP artifact
    89         uses: thedoctor0/zip-release@0.4.1
    90         with:
    91           filename: built-wp-${{ github.sha }}.zip
    92           exclusions: '*.git* /*node_modules/* packagehash.txt'
    93 
    94       - name: Upload build artifact
    95         uses: actions/upload-artifact@v2
    96         with:
    97           name: built-wp-${{ github.sha }}
    98           path: built-wp-${{ github.sha }}.zip
    99           if-no-files-found: error
    10041
    10142  # Runs the PHPUnit tests for WordPress.
    … …  
    10445  # - Set environment variables.
    10546  # - Sets up the environment variables needed for testing with memcached (if desired).
    106   # - Downloads the built WordPress artifact from the previous job.
    107   # - Unzips the artifact.
    10847  # - Installs NodeJS 14.
    10948  # - Sets up caching for NPM.
    110   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     49  # - Installs NPM dependencies
    11150  # - Configures caching for Composer.
    112   # _ Installs Composer dependencies (if desired).
     51  # - Installs Composer dependencies (if desired).
    11352  # - Logs Docker debug information (about both the Docker installation within the runner).
    11453  # - Starts the WordPress Docker container.
    … …  
    12564  # - todo: Configure Slack notifications for failing tests.
    12665  test-php:
    127     name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    128     needs: setup-wordpress
     66    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    12967    runs-on: ${{ matrix.os }}
    13068    strategy:
    … …  
    13371        os: [ ubuntu-latest ]
    13472        memcached: [ false ]
     73        split_slow: [ false ]
    13574        multisite: [ false, true ]
    13675        include:
     76          # Additional "slow" jobs for PHP 5.6.
     77          - php: '5.6.20'
     78            os: ubuntu-latest
     79            memcached: false
     80            multisite: false
     81            split_slow: true
     82          - php: '5.6.20'
     83            os: ubuntu-latest
     84            memcached: false
     85            multisite: true
     86            split_slow: true
    13787          # Include jobs for PHP 7.4 with memcached.
    13888          - php: '7.4'
    … …  
    161111          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    162112
    163       - name: Download the built WordPress artifact
    164         uses: actions/download-artifact@v2
    165         with:
    166           name: built-wp-${{ github.sha }}
    167 
    168       - name: Unzip built artifact
    169         run: unzip built-wp-${{ github.sha }}.zip
     113      - name: Checkout repository
     114        uses: actions/checkout@v2
    170115
    171116      - name: Install NodeJS
    … …  
    232177        if: ${{ matrix.memcached }}
    233178        run: |
    234           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     179          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    235180          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    236181
    … …  
    257202        run: npm run env:install
    258203
     204      - name: Run slow PHPUnit tests
     205        if: ${{ matrix.split_slow }}
     206        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     207
     208      - name: Run PHPUnit tests for single site excluding slow tests
     209        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     210        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     211
     212      - name: Run PHPUnit tests for Multisite excluding slow tests
     213        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     214        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     215
    259216      - name: Run PHPUnit tests
     217        if: ${{ matrix.php >= '7.0' }}
    260218        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    261219
    262220      - name: Run AJAX tests
     221        if: ${{ ! matrix.split_slow }}
    263222        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    264223
    265224      - name: Run ms-files tests as a multisite install
    266         if: ${{ matrix.multisite }}
     225        if: ${{ matrix.multisite && ! matrix.split_slow }}
    267226        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    268227
    269228      - name: Run external HTTP tests
    270         if: ${{ ! matrix.multisite }}
     229        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    271230        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    272231
    273232      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    274233      - name: Run (xDebug) tests
     234        if: ${{ ! matrix.split_slow }}
    275235        run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__
    276236
    … …  
    281241          repository: 'WordPress/phpunit-test-runner'
    282242          path: 'test-runner'
    283 
    284       - name: Set up the Git repository
    285         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    286         run: |
    287           git init
    288           git remote add origin https://github.com/WordPress/wordpress-develop.git
    289           git fetch
    290           git reset origin/master
    291243
    292244      - name: Submit test results to the WordPress.org host test results
Note: See TracChangeset for help on using the changeset viewer.