WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/12/2021 07:48:05 PM (10 months ago)
Author:
desrosj
Message:

Build/Test Tools: Restore automated testing in the 4.6 branch.

This commit merges the workflow files required to run automated testing on GitHub Actions.

In addition, [49836] and [50285] have been included in order to keep the local Docker environment consistent across all branches.

Merges [49162,49168-49169,49175,49204,49227-49228,49244,49369,49371,49548,49781-49784,49786,49836,49938,50268,50285,50298] to the 4.6 branch.
See #50401.

Location:
branches/4.6
Files:
1 added
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/4.6

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

    r49162 r50311  
    55    branches:
    66      - master
    7       - '*.*'
     7      - '3.[7-9]'
     8      - '[4-9].[0-9]'
     9    tags:
     10      - '3.[7-9]*'
     11      - '[4-9].[0-9]*'
    812  pull_request:
    913  # Once weekly On Sundays at 00:00 UTC.
     
    2327  #
    2428  # Performs the following steps:
    25   # - Cancels all previous workflow runs that have not completed.
     29  # - Cancels all previous workflow runs for pull requests that have not completed.
    2630  # - Checks out the repository.
    27   # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests).
    2831  # - Logs debug information about the runner container.
    29   # - Installs NodeJS 12 (todo: install the version of NPM specified in the `.nvmrc` file to support older branches)
     32  # - Installs NodeJS 14.
    3033  # - Sets up caching for NPM.
    31   # _ Installs NPM dependencies.
     34  # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    3235  # - Builds WordPress to run from the `build` directory.
    33   # - Creates a ZIP file of compiled WordPress
     36  # - Creates a ZIP file of compiled WordPress.
    3437  # - Uploads ZIP file as an artifact.
    3538  setup-wordpress:
    3639    name: Setup WordPress
    3740    runs-on: ubuntu-latest
     41    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    3842
    3943    steps:
    40       - name: Cancel previous runs of this workflow
     44      - name: Cancel previous runs of this workflow (pull requests only)
     45        if: ${{ github.event_name == 'pull_request' }}
    4146        uses: styfle/cancel-workflow-action@0.5.0
    4247        with:
     
    4651        uses: actions/checkout@v2
    4752
    48       - name: Checkout the WordPress Importer plugin
    49         run: svn checkout -r 2387243 https://plugins.svn.wordpress.org/wordpress-importer/trunk/ tests/phpunit/data/plugins/wordpress-importer
    50 
    5153      - name: Log debug information
    5254        run: |
     55          echo "$GITHUB_REF"
     56          echo "$GITHUB_EVENT_NAME"
    5357          npm --version
    5458          node --version
     
    6367        uses: actions/setup-node@v1
    6468        with:
    65           node-version: 12
     69          node-version: 14
    6670
    6771      - name: Cache NodeJS modules
     
    7781
    7882      - name: Install Dependencies
    79         run: npm ci
     83        run: npx install-changed --install-command="npm ci"
    8084
    8185      - name: Build WordPress
     
    8690        with:
    8791          filename: built-wp-${{ github.sha }}.zip
    88           exclusions: '/*node_modules/*'
     92          exclusions: '*.git* /*node_modules/* packagehash.txt'
    8993
    9094      - name: Upload build artifact
     
    102106  # - Downloads the built WordPress artifact from the previous job.
    103107  # - Unzips the artifact.
    104   # - Installs NodeJS 12 (todo: install the version of NPM specified in the `nvmrc` file to support older branches)
     108  # - Installs NodeJS 14.
    105109  # - Sets up caching for NPM.
    106   # _ Installs NPM dependencies.
     110  # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    107111  # - Configures caching for Composer.
    108   # _ Installs Composer dependencies (if desired)
    109   # - Logs Docker debug information (about both the Docker installation within the runner)
     112  # _ Installs Composer dependencies (if desired).
     113  # - Logs Docker debug information (about both the Docker installation within the runner).
    110114  # - Starts the WordPress Docker container.
    111115  # - Starts the memcached server after the Docker network has been created (if desired).
     
    113117  # - Logs debug general information.
    114118  # - Logs the running Docker containers.
    115   # - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container)
     119  # - Logs debug information about what's installed within the WordPress Docker containers.
    116120  # - Install WordPress within the Docker container.
    117121  # - Run the PHPUnit tests.
    118   # - Reports test results to the Distributed Hosting Tests.
     122  # - Checks out the WordPress Test reporter repository.
     123  # - Reconnect the directory to the Git repository.
     124  # - Submit the test results to the WordPress.org host test results.
    119125  # - todo: Configure Slack notifications for failing tests.
    120126  test-php:
    121     name: ${{ matrix.php_versions }} on ${{ matrix.os }}
     127    name: ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    122128    needs: setup-wordpress
    123129    runs-on: ${{ matrix.os }}
    124130    strategy:
    125131      matrix:
    126         php_versions: [ '8.0', 7.4, '7.4 with memcached', 7.3, 7.2, 7.1, '7.0', 5.6.20 ]
     132        php: [ '7.0' ]
     133        phpunit: [ '5-php-7.0' ]
    127134        os: [ ubuntu-latest ]
     135        memcached: [ false ]
     136        include:
     137          # Include job for PHP 7.1 with memcached.
     138          - php: '7.0'
     139            phpunit: '5-php-7.0'
     140            os: ubuntu-latest
     141            memcached: true
     142          - php: '5.6'
     143            phpunit: '4-php-5.6'
     144            os: ubuntu-latest
     145            memcached: false
     146          - php: '5.5'
     147            phpunit: '5.5'
     148            os: ubuntu-latest
     149            memcached: false
     150          - php: '5.4'
     151            phpunit: '5.4'
     152            os: ubuntu-latest
     153            memcached: false
     154          - php: '5.3'
     155            phpunit: '5.3'
     156            os: ubuntu-latest
     157            memcached: false
    128158    env:
    129       LOCAL_PHP: ${{ matrix.php_versions }}-fpm
     159      LOCAL_PHP: ${{ matrix.php }}-fpm
     160      LOCAL_PHPUNIT: ${{ matrix.phpunit }}-fpm
     161      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
    130162
    131163    steps:
     
    135167          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    136168
    137       - name: Configure memcached
    138         if: ${{ contains( matrix.php_versions, 'memcached' ) }}
    139         run: |
    140           echo "LOCAL_PHP=$(echo ${{ matrix.php_versions }} | cut -c1-3)-fpm" >> $GITHUB_ENV
    141           echo "LOCAL_PHP_MEMCACHED=true" >> $GITHUB_ENV
    142 
    143169      - name: Download the built WordPress artifact
    144170        uses: actions/download-artifact@v2
     
    152178        uses: actions/setup-node@v1
    153179        with:
    154           node-version: 12
     180          node-version: 14
    155181
    156182      - name: Use cached Node modules
     
    166192
    167193      - name: Install Dependencies
    168         run: npm ci
    169 
    170       - name: Get composer cache directory
    171         id: composer-cache
    172         if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
    173         run: echo "::set-output name=dir::$(composer config cache-files-dir)"
     194        run: npx install-changed --install-command="npm ci"
    174195
    175196      - name: Cache Composer dependencies
    176         if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
     197        if: ${{ env.COMPOSER_INSTALL == true }}
    177198        uses: actions/cache@v2
    178199        env:
     
    180201        with:
    181202          path: ${{ steps.composer-cache.outputs.dir }}
    182           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
     203          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    183204          restore-keys: |
    184             ${{ runner.os }}-composer-
     205            ${{ runner.os }}-php-${{ matrix.php }}-composer-
    185206
    186207      - name: Install Composer dependencies
    187         if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
     208        if: ${{ env.COMPOSER_INSTALL == true }}
    188209        run: |
    189210          docker-compose run --rm php composer --version
    190 
    191           # The PHPUnit 7.x phar is not compatible with PHP 8 and won't be updated,
    192           # as PHPUnit 7 is no longer supported. The Composer-installed PHPUnit should be
    193           # used for PHP 8 testing instead.
    194           if [ ${{ env.LOCAL_PHP }} == '8.0-fpm' ]; then
    195             docker-compose run --rm php composer install --ignore-platform-reqs
    196             echo "PHPUNIT_SCRIPT=php-composer" >> $GITHUB_ENV
    197           else
    198             docker-compose run --rm php composer install
    199           fi
     211          docker-compose run --rm php composer install
    200212
    201213      - name: Docker debug information
     
    210222      # The memcached server needs to start after the Docker network has been set up with `npm run env:start`.
    211223      - name: Start the Memcached server.
    212         if: ${{ contains( matrix.php_versions, 'memcached' ) }}
     224        if: ${{ matrix.memcached }}
    213225        run: |
    214226          cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     
    228240      - name: WordPress Docker container debug information
    229241        run: |
    230           docker -v
    231           docker-compose -v
    232242          docker-compose run --rm mysql mysql --version
    233243          docker-compose run --rm php php --version
     
    248258        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
    249259
    250       - name: Run mutlisite file tests
     260      - name: Run ms-files tests as a multisite install
    251261        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    252262
     
    257267        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    258268
    259       # Xdebug supports PHP 8 only from version 3.0, which is not released yet.
    260       # Once Xdebug 3.0 is released and included in the Docker image, the IF condition should be removed.
    261269      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    262270      - name: Run (xDebug) tests
    263         if: ${{ env.LOCAL_PHP != '8.0-fpm' }}
    264271        run: LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
    265272
    266       - name: WordPress Test Reporter
    267         if: ${{ matrix.php_versions == '7.4' }}
     273      - name: Checkout the WordPress Test Reporter
     274        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    268275        uses: actions/checkout@v2
    269276        with:
    270277          repository: 'WordPress/phpunit-test-runner'
    271278          path: 'test-runner'
    272         # TODO: Configure hidden keys to successfully report test results.
    273         # run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
     279
     280      - name: Set up the Git repository
     281        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
     282        run: |
     283          git init
     284          git remote add origin https://github.com/WordPress/wordpress-develop.git
     285          git fetch
     286          git reset origin/master
     287
     288      - name: Submit test results to the WordPress.org host test results
     289        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
     290        env:
     291          WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
     292        run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
Note: See TracChangeset for help on using the changeset viewer.