Make WordPress Core


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

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

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

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

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

    r50333 r50625  
    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
     
    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.2' ]
    133         phpunit: [ '6-php-7.2' ]
     137        php: [ '5.3', '5.4', '5.5' ]
    134138        os: [ ubuntu-latest ]
    135139        memcached: [ false ]
     140        split_slow: [ false, true ]
     141        multisite: [ false, true ]
    136142        include:
     143          # Additional "slow" jobs for PHP 5.6.
     144          - php: '5.6'
     145            phpunit: '4-php-5.6'
     146            os: ubuntu-latest
     147            memcached: false
     148            multisite: false
     149            split_slow: true
     150          - php: '5.6'
     151            phpunit: '4-php-5.6'
     152            os: ubuntu-latest
     153            memcached: false
     154            multisite: true
     155            split_slow: true
     156          # Include job for specific PHPUnit versions.
     157          - php: '7.2'
     158            phpunit: '6-php-7.2'
     159            os: ubuntu-latest
     160            memcached: false
     161            multisite: false
     162            split_slow: false
     163          - php: '7.2'
     164            phpunit: '6-php-7.2'
     165            os: ubuntu-latest
     166            memcached: false
     167            multisite: true
     168            split_slow: false
     169          - php: '7.1'
     170            phpunit: '6-php-7.1'
     171            os: ubuntu-latest
     172            memcached: false
     173            multisite: false
     174            split_slow: false
     175          - php: '7.1'
     176            phpunit: '6-php-7.1'
     177            os: ubuntu-latest
     178            memcached: false
     179            multisite: true
     180            split_slow: false
     181          - php: '7.0'
     182            phpunit: '6-php-7.0'
     183            os: ubuntu-latest
     184            memcached: false
     185            multisite: false
     186            split_slow: false
     187          - php: '7.0'
     188            phpunit: '6-php-7.0'
     189            os: ubuntu-latest
     190            memcached: false
     191            multisite: true
     192            split_slow: false
     193          - php: '5.6'
     194            phpunit: '4-php-5.6'
     195            os: ubuntu-latest
     196            memcached: false
     197            multisite: false
     198            split_slow: false
     199          - php: '5.6'
     200            phpunit: '4-php-5.6'
     201            os: ubuntu-latest
     202            memcached: false
     203            multisite: true
     204            split_slow: false
    137205          # Include job for PHP 7.2 with memcached.
    138206          - php: '7.2'
     
    140208            os: ubuntu-latest
    141209            memcached: true
    142           - php: '7.1'
    143             phpunit: '6-php-7.1'
    144             os: ubuntu-latest
    145             memcached: false
    146           - php: '7.0'
    147             phpunit: '6-php-7.0'
    148             os: ubuntu-latest
    149             memcached: false
    150           - php: '5.6'
    151             phpunit: '4-php-5.6'
    152             os: ubuntu-latest
    153             memcached: false
    154           - php: '5.5'
    155             phpunit: '5.5'
    156             os: ubuntu-latest
    157             memcached: false
    158           - php: '5.4'
    159             phpunit: '5.4'
    160             os: ubuntu-latest
    161             memcached: false
    162           - php: '5.3'
    163             phpunit: '5.3'
    164             os: ubuntu-latest
    165             memcached: false
     210            multisite: false
     211            split_slow: false
     212
    166213    env:
    167214      LOCAL_PHP: ${{ matrix.php }}-fpm
    168       LOCAL_PHPUNIT: ${{ matrix.phpunit }}-fpm
     215      LOCAL_PHPUNIT: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}-fpm
    169216      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
     217      PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
    170218
    171219    steps:
     
    176224
    177225      - name: Download the built WordPress artifact
    178         uses: actions/download-artifact@v2
     226        uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8
    179227        with:
    180228          name: built-wp-${{ github.sha }}
     
    184232
    185233      - name: Install NodeJS
    186         uses: actions/setup-node@v1
     234        uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5
    187235        with:
    188236          node-version: 14
    189237
    190238      - name: Use cached Node modules
    191         uses: actions/cache@v2
     239        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    192240        env:
    193241          cache-name: cache-node-modules
     
    196244          path: ~/.npm
    197245          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    198           restore-keys: |
    199             ${{ runner.os }}-npm-
    200246
    201247      - name: Install Dependencies
    202         run: npx install-changed --install-command="npm ci"
     248        run: npm ci
    203249
    204250      - name: Cache Composer dependencies
    205251        if: ${{ env.COMPOSER_INSTALL == true }}
    206         uses: actions/cache@v2
     252        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
    207253        env:
    208254          cache-name: cache-composer-dependencies
     
    210256          path: ${{ steps.composer-cache.outputs.dir }}
    211257          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    212           restore-keys: |
    213             ${{ runner.os }}-php-${{ matrix.php }}-composer-
    214258
    215259      - name: Install Composer dependencies
     
    257301        run: npm run env:install
    258302
     303      - name: Run slow PHPUnit tests
     304        if: ${{ matrix.split_slow }}
     305        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
     306
     307      - name: Run PHPUnit tests for single site excluding slow tests
     308        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
     309        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
     310
     311      - name: Run PHPUnit tests for Multisite excluding slow tests
     312        if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
     313        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
     314
    259315      - name: Run PHPUnit tests
    260         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist
     316        if: ${{ matrix.php >= '7.0' }}
     317        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
    261318
    262319      - name: Run AJAX tests
    263         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax
    264 
    265       - name: Run tests as a multisite install
    266         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
     320        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
     321        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
    267322
    268323      - name: Run ms-files tests as a multisite install
     324        if: ${{ matrix.multisite && ! matrix.split_slow }}
    269325        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    270326
    271327      - name: Run external HTTP tests
     328        if: ${{ ! matrix.multisite && ! matrix.split_slow }}
    272329        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http
    273 
    274       - name: Run REST API tests
    275         run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    276330
    277331      - name: Checkout the WordPress Test Reporter
    278332        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    279         uses: actions/checkout@v2
     333        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
    280334        with:
    281335          repository: 'WordPress/phpunit-test-runner'
Note: See TracChangeset for help on using the changeset viewer.