WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/26/2021 05:21:35 PM (8 months ago)
Author:
desrosj
Message:

Build/Test Tools: Backport GitHub Action and build improvements to the 5.6 branch.

This backports several build and test tool improvements to the 5.6 branch. Most notably, this includes:

  • The changes required to allow each workflow to be triggered by the workflow_dispatch event so that tests can be run on a schedule [50590].
  • The ability to run PHPUnit tests from src instead of build [50441-50443].
  • Splitting single site and multisite tests into parallel jobs [50379].
  • Split slow tests into separate, parallel jobs for PHP 5.6 [50444].
  • Better branch and path scoping for GitHub Action workflows when running on pull_request [50432,50479].
  • Several devDependency updates.

Merges [50267,50299,50379,50387,50413,50416,50432,50435-50436,50441-50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50592,50598] to the 5.6 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667, #52786.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r50301 r50602  
    55    branches:
    66      - master
     7      - trunk
    78      - '3.[7-9]'
    89      - '[4-9].[0-9]'
     
    1112      - '[4-9].[0-9]*'
    1213  pull_request:
     14    branches:
     15      - master
     16      - trunk
     17      - '3.[7-9]'
     18      - '[4-9].[0-9]'
     19  workflow_dispatch:
    1320  # Once weekly On Sundays at 00:00 UTC.
    1421  schedule:
     
    1623
    1724env:
    18   LOCAL_DIR: build
    1925  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    2026  COMPOSER_INSTALL: ${{ false }}
     
    2228  PHPUNIT_SCRIPT: php
    2329  LOCAL_PHP_MEMCACHED: ${{ false }}
     30  SLOW_TESTS: 'external-http,media,restapi'
    2431
    2532jobs:
    26   # Sets up WordPress for testing or development use.
     33  # Sets up the workflow for testing.
    2734  #
    2835  # Performs the following steps:
    2936  # - 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
     37  setup-workflow:
     38    name: Setup Workflow
    4039    runs-on: ubuntu-latest
    4140    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
     
    4443      - name: Cancel previous runs of this workflow (pull requests only)
    4544        if: ${{ github.event_name == 'pull_request' }}
    46         uses: styfle/cancel-workflow-action@0.5.0
    47         with:
    48           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@v1
    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
     45        uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
    10046
    10147  # Runs the PHPUnit tests for WordPress.
     
    10450  # - Set environment variables.
    10551  # - 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.
    10852  # - Installs NodeJS 14.
    10953  # - Sets up caching for NPM.
    110   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     54  # - Installs NPM dependencies
    11155  # - Configures caching for Composer.
    112   # _ Installs Composer dependencies (if desired).
     56  # - Installs Composer dependencies (if desired).
    11357  # - Logs Docker debug information (about both the Docker installation within the runner).
    11458  # - Starts the WordPress Docker container.
     
    12569  # - todo: Configure Slack notifications for failing tests.
    12670  test-php:
    127     name: ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    128     needs: setup-wordpress
     71    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    12972    runs-on: ${{ matrix.os }}
    13073    strategy:
     74      fail-fast: false
    13175      matrix:
    132         php: [ '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6.20' ]
     76        php: [ '5.6.20', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
    13377        os: [ ubuntu-latest ]
    13478        memcached: [ false ]
     79        split_slow: [ false ]
     80        multisite: [ false, true ]
    13581        include:
    136           # Include job for PHP 7.4 with memcached.
     82          # Additional "slow" jobs for PHP 5.6.
     83          - php: '5.6.20'
     84            os: ubuntu-latest
     85            memcached: false
     86            multisite: false
     87            split_slow: true
     88          - php: '5.6.20'
     89            os: ubuntu-latest
     90            memcached: false
     91            multisite: true
     92            split_slow: true
     93          # Include jobs for PHP 7.4 with memcached.
    13794          - php: '7.4'
    13895            os: ubuntu-latest
    13996            memcached: true
     97            multisite: false
     98          - php: '7.4'
     99            os: ubuntu-latest
     100            memcached: true
     101            multisite: true
    140102          # Report the results of the PHP 7.4 without memcached job.
    141103          - php: '7.4'
    142104            os: ubuntu-latest
    143105            memcached: false
     106            multisite: false
    144107            report: true
    145108    env:
    146109      LOCAL_PHP: ${{ matrix.php }}-fpm
    147110      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
     111      PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    148112
    149113    steps:
     
    153117          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    154118
    155       - name: Download the built WordPress artifact
    156         uses: actions/download-artifact@v2
    157         with:
    158           name: built-wp-${{ github.sha }}
    159 
    160       - name: Unzip built artifact
    161         run: unzip built-wp-${{ github.sha }}.zip
     119      - name: Checkout repository
     120        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    162121
    163122      - name: Install NodeJS
    164         uses: actions/setup-node@v1
     123        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    165124        with:
    166125          node-version: 14
    167126
    168127      - name: Use cached Node modules
    169         uses: actions/cache@v2
     128        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    170129        env:
    171130          cache-name: cache-node-modules
     
    174133          path: ~/.npm
    175134          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    176           restore-keys: |
    177             ${{ runner.os }}-npm-
    178135
    179136      - name: Install Dependencies
    180         run: npx install-changed --install-command="npm ci"
     137        run: npm ci
    181138
    182139      - name: Get composer cache directory
     
    187144      - name: Cache Composer dependencies
    188145        if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
    189         uses: actions/cache@v2
     146        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    190147        env:
    191148          cache-name: cache-composer-dependencies
     
    193150          path: ${{ steps.composer-cache.outputs.dir }}
    194151          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    195           restore-keys: |
    196             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    197152
    198153      - name: Install Composer dependencies
     
    224179        if: ${{ matrix.memcached }}
    225180        run: |
    226           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     181          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    227182          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    228183
     
    249204        run: npm run env:install
    250205
     206      - name: Run slow PHPUnit tests
     207        if: ${{ matrix.split_slow }}
     208        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     209
     210      - name: Run PHPUnit tests for single site excluding slow tests
     211        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     212        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     213
     214      - name: Run PHPUnit tests for Multisite excluding slow tests
     215        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     216        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     217
    251218      - name: Run PHPUnit tests
    252         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     219        if: ${{ matrix.php >= '7.0' }}
     220        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    253221
    254222      - name: Run AJAX tests
    255         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
    256 
    257       - name: Run tests as a multisite install
    258         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
     223        if: ${{ ! matrix.split_slow && ! matrix.multisite }}
     224        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    259225
    260226      - name: Run ms-files tests as a multisite install
     227        if: ${{ matrix.multisite && ! matrix.split_slow }}
    261228        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    262229
    263230      - name: Run external HTTP tests
     231        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    264232        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    265233
    266       - name: Run REST API tests
    267         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    268 
    269       # Xdebug supports PHP 8 only from version 3.0, which is not released yet.
    270       # Once Xdebug 3.0 is released and included in the Docker image, the IF condition should be removed.
    271234      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    272235      - name: Run (xDebug) tests
    273         if: ${{ env.LOCAL_PHP != '8.0-fpm' }}
    274         run: LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
     236        if: ${{ ! matrix.split_slow }}
     237        run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__
    275238
    276239      - name: Checkout the WordPress Test Reporter
    277240        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    278         uses: actions/checkout@v2
     241        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    279242        with:
    280243          repository: 'WordPress/phpunit-test-runner'
    281244          path: 'test-runner'
    282 
    283       - name: Set up the Git repository
    284         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    285         run: |
    286           git init
    287           git remote add origin https://github.com/WordPress/wordpress-develop.git
    288           git fetch
    289           git reset origin/master
    290245
    291246      - name: Submit test results to the WordPress.org host test results
Note: See TracChangeset for help on using the changeset viewer.