Make WordPress Core


Ignore:
Timestamp:
03/31/2021 07:20:38 PM (4 years ago)
Author:
desrosj
Message:

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

This backports several build and test tool improvements to the 5.1 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].
  • 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 [45317,50267,50379,50387,50413,50416,50432,50435-50436,50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50598] to the 5.1 branch.
See #50401, #51801, #51802, #52548, #52608, #52612, #52624, #52625, #52645, #52653, #52658, #52660, #52667.

Location:
branches/5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1

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

    r50335 r50622  
    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:
     
    2229  PHPUNIT_SCRIPT: php
    2330  LOCAL_PHP_MEMCACHED: ${{ false }}
     31  SLOW_TESTS: 'external-http,media,restapi'
    2432
    2533jobs:
     
    4452      - name: Cancel previous runs of this workflow (pull requests only)
    4553        if: ${{ github.event_name == 'pull_request' }}
    46         uses: styfle/cancel-workflow-action@0.5.0
    47         with:
    48           access_token: ${{ github.token }}
     54        uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
    4955
    5056      - name: Checkout repository
    51         uses: actions/checkout@v2
     57        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    5258
    5359      - name: Log debug information
     
    6571
    6672      - name: Install NodeJS
    67         uses: actions/setup-node@v1
     73        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    6874        with:
    6975          node-version: 14
    7076
    7177      - name: Cache NodeJS modules
    72         uses: actions/cache@v2
     78        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    7379        env:
    7480          cache-name: cache-node-modules
     
    7783          path: ~/.npm
    7884          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    79           restore-keys: |
    80             ${{ runner.os }}-npm-
    8185
    8286      - name: Install Dependencies
    83         run: npx install-changed --install-command="npm ci"
     87        run: npm ci
    8488
    8589      - name: Build WordPress
     
    8791
    8892      - name: Create ZIP artifact
    89         uses: thedoctor0/zip-release@0.4.1
     93        uses: thedoctor0/zip-release@a1afcab9c664c9976ac398fa831eac67bed1eb0e # v0.4.1
    9094        with:
    9195          filename: built-wp-${{ github.sha }}.zip
     
    9397
    9498      - name: Upload build artifact
    95         uses: actions/upload-artifact@v2
     99        uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
    96100        with:
    97101          name: built-wp-${{ github.sha }}
     
    125129  # - todo: Configure Slack notifications for failing tests.
    126130  test-php:
    127     name: ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
     131    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    128132    needs: setup-wordpress
    129133    runs-on: ${{ matrix.os }}
    130134    strategy:
     135      fail-fast: false
    131136      matrix:
    132         php: [ '7.3' ]
    133         phpunit: [ '7.3' ]
     137        php: [ '5.3', '5.4', '5.5', '7.1', '7.2', '7.3' ]
    134138        os: [ ubuntu-latest ]
    135139        memcached: [ false ]
     140        split_slow: [ false ]
     141        multisite: [ false, true ]
    136142        include:
    137           # Include job for PHP 7.3 with memcached.
     143          # Include jobs for PHP 7.3 with memcached.
    138144          - php: '7.3'
    139             phpunit: '7.3'
    140             os: ubuntu-latest
    141             memcached: false
    142           - php: '7.2'
    143             phpunit: '7.2'
    144             os: ubuntu-latest
    145             memcached: false
    146           - php: '7.1'
    147             phpunit: '7.1'
    148             os: ubuntu-latest
    149             memcached: false
     145            os: ubuntu-latest
     146            memcached: true
     147            split_slow: false
     148            multisite: false
     149          - php: '7.3'
     150            os: ubuntu-latest
     151            memcached: true
     152            split_slow: false
     153            multisite: true
     154          # Include jobs when specific PHPUnit versions are required.
    150155          - php: '7.0'
    151156            phpunit: '6-php-7.0'
    152157            os: ubuntu-latest
    153158            memcached: false
     159            multisite: false
     160          - php: '7.0'
     161            phpunit: '6-php-7.0'
     162            os: ubuntu-latest
     163            memcached: false
     164            multisite: true
    154165          - php: '5.6'
    155166            phpunit: '4-php-5.6'
    156167            os: ubuntu-latest
    157168            memcached: false
     169            multisite: false
     170          - php: '5.6'
     171            phpunit: '4-php-5.6'
     172            os: ubuntu-latest
     173            memcached: false
     174            multisite: true
     175          # Additional "slow" jobs for PHP <= 5.6.
     176          - php: '5.6'
     177            phpunit: '4-php-5.6'
     178            os: ubuntu-latest
     179            memcached: false
     180            split_slow: true
     181            multisite: false
     182          - php: '5.6'
     183            phpunit: '4-php-5.6'
     184            os: ubuntu-latest
     185            memcached: false
     186            split_slow: true
     187            multisite: true
    158188          - php: '5.5'
    159             phpunit: '5.5'
    160             os: ubuntu-latest
    161             memcached: false
     189            os: ubuntu-latest
     190            memcached: false
     191            split_slow: true
     192            multisite: false
     193          - php: '5.5'
     194            os: ubuntu-latest
     195            memcached: false
     196            split_slow: true
     197            multisite: true
    162198          - php: '5.4'
    163             phpunit: '5.4'
    164             os: ubuntu-latest
    165             memcached: false
     199            os: ubuntu-latest
     200            memcached: false
     201            split_slow: true
     202            multisite: false
     203          - php: '5.4'
     204            os: ubuntu-latest
     205            memcached: false
     206            split_slow: true
     207            multisite: true
    166208          - php: '5.3'
    167             phpunit: '5.3'
    168             os: ubuntu-latest
    169             memcached: false
     209            os: ubuntu-latest
     210            memcached: false
     211            split_slow: true
     212            multisite: false
     213          - php: '5.3'
     214            os: ubuntu-latest
     215            memcached: false
     216            split_slow: true
     217            multisite: true
     218
    170219    env:
    171220      LOCAL_PHP: ${{ matrix.php }}-fpm
    172       LOCAL_PHPUNIT: ${{ matrix.phpunit }}-fpm
     221      LOCAL_PHPUNIT: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}-fpm
    173222      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
     223      PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    174224
    175225    steps:
     
    180230
    181231      - name: Download the built WordPress artifact
    182         uses: actions/download-artifact@v2
     232        uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8
    183233        with:
    184234          name: built-wp-${{ github.sha }}
     
    188238
    189239      - name: Install NodeJS
    190         uses: actions/setup-node@v1
     240        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    191241        with:
    192242          node-version: 14
    193243
    194244      - name: Use cached Node modules
    195         uses: actions/cache@v2
     245        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    196246        env:
    197247          cache-name: cache-node-modules
     
    200250          path: ~/.npm
    201251          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    202           restore-keys: |
    203             ${{ runner.os }}-npm-
    204252
    205253      - name: Install Dependencies
    206         run: npx install-changed --install-command="npm ci"
     254        run: npm ci
    207255
    208256      - name: Cache Composer dependencies
    209257        if: ${{ env.COMPOSER_INSTALL == true }}
    210         uses: actions/cache@v2
     258        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    211259        env:
    212260          cache-name: cache-composer-dependencies
     
    214262          path: ${{ steps.composer-cache.outputs.dir }}
    215263          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    216           restore-keys: |
    217             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    218264
    219265      - name: Install Composer dependencies
     
    261307        run: npm run env:install
    262308
     309      - name: Run slow PHPUnit tests
     310        if: ${{ matrix.split_slow }}
     311        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     312
     313      - name: Run PHPUnit tests for single site excluding slow tests
     314        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     315        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     316
     317      - name: Run PHPUnit tests for Multisite excluding slow tests
     318        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     319        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     320
    263321      - name: Run PHPUnit tests
    264         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     322        if: ${{ matrix.php >= '7.0' }}
     323        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    265324
    266325      - name: Run AJAX tests
    267         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
    268 
    269       - name: Run tests as a multisite install
    270         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
     326        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
     327        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    271328
    272329      - name: Run ms-files tests as a multisite install
     330        if: ${{ matrix.multisite && ! matrix.split_slow }}
    273331        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    274332
    275333      - name: Run external HTTP tests
     334        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    276335        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    277 
    278       - name: Run REST API tests
    279         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    280336
    281337      - name: Checkout the WordPress Test Reporter
    282338        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    283         uses: actions/checkout@v2
     339        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    284340        with:
    285341          repository: 'WordPress/phpunit-test-runner'
Note: See TracChangeset for help on using the changeset viewer.