Make WordPress Core


Ignore:
Timestamp:
03/26/2021 08:02:01 PM (4 years ago)
Author:
desrosj
Message:

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

This backports several build and test tool improvements to the 5.2 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,50598] to the 5.2 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r50336 r50606  
    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 }}
     72    needs: setup-workflow
    12973    runs-on: ${{ matrix.os }}
    13074    strategy:
    13175      matrix:
    132         php: [ '7.3', '7.2', '7.1', '7.0', '5.6' ]
     76        php: [ '5.6', '7.0', '7.1', '7.2', '7.3' ]
    13377        os: [ ubuntu-latest ]
    13478        memcached: [ false ]
     79        split_slow: [ false ]
     80        multisite: [ false, true ]
    13581        include:
    136           # Include job for PHP 7.3 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.3 with memcached.
    13794          - php: '7.3'
    13895            os: ubuntu-latest
    13996            memcached: true
     97            multisite: false
     98          - php: '7.3'
     99            os: ubuntu-latest
     100            memcached: true
     101            multisite: true
    140102          # Report the results of the PHP 7.3 without memcached job.
    141103          - php: '7.3'
    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
     138
     139      - name: Get composer cache directory
     140        id: composer-cache
     141        if: ${{ env.COMPOSER_INSTALL == true }}
     142        run: echo "::set-output name=dir::$(composer config cache-files-dir)"
    181143
    182144      - name: Cache Composer dependencies
    183145        if: ${{ env.COMPOSER_INSTALL == true }}
    184         uses: actions/cache@v2
     146        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    185147        env:
    186148          cache-name: cache-composer-dependencies
     
    188150          path: ${{ steps.composer-cache.outputs.dir }}
    189151          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    190           restore-keys: |
    191             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    192152
    193153      - name: Install Composer dependencies
     
    210170        if: ${{ matrix.memcached }}
    211171        run: |
    212           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     172          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    213173          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    214174
     
    235195        run: npm run env:install
    236196
     197      - name: Run slow PHPUnit tests
     198        if: ${{ matrix.split_slow }}
     199        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     200
     201      - name: Run PHPUnit tests for single site excluding slow tests
     202        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     203        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     204
     205      - name: Run PHPUnit tests for Multisite excluding slow tests
     206        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     207        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     208
    237209      - name: Run PHPUnit tests
    238         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     210        if: ${{ matrix.php >= '7.0' }}
     211        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    239212
    240213      - name: Run AJAX tests
    241         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
     214        if: ${{ ! matrix.split_slow && ! matrix.multisite }}
     215        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    242216
    243217      - name: Run tests as a multisite install
     
    245219
    246220      - name: Run ms-files tests as a multisite install
     221        if: ${{ matrix.multisite && ! matrix.split_slow }}
    247222        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    248223
    249224      - name: Run external HTTP tests
     225        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    250226        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    251 
    252       - name: Run REST API tests
    253         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    254227
    255228      - name: Checkout the WordPress Test Reporter
    256229        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    257         uses: actions/checkout@v2
     230        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    258231        with:
    259232          repository: 'WordPress/phpunit-test-runner'
    260233          path: 'test-runner'
    261 
    262       - name: Set up the Git repository
    263         if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    264         run: |
    265           git init
    266           git remote add origin https://github.com/WordPress/wordpress-develop.git
    267           git fetch
    268           git reset origin/master
    269234
    270235      - name: Submit test results to the WordPress.org host test results
Note: See TracChangeset for help on using the changeset viewer.