Make WordPress Core


Ignore:
Timestamp:
02/12/2021 07:34:39 PM (4 years ago)
Author:
desrosj
Message:

Build/Test Tools: Restore automated testing in the 4.8 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.8 branch.
See #50401.

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

Legend:

Unmodified
Added
Removed
  • branches/4.8

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

    r49162 r50309  
    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.1' ]
     133        phpunit: [ '6-php-7.1' ]
    127134        os: [ ubuntu-latest ]
     135        memcached: [ false ]
     136        include:
     137          # Include job for PHP 7.1 with memcached.
     138          - php: '7.1'
     139            phpunit: '6-php-7.1'
     140            os: ubuntu-latest
     141            memcached: true
     142          - php: '7.0'
     143            phpunit: '6-php-7.0'
     144            os: ubuntu-latest
     145            memcached: false
     146          - php: '5.6'
     147            phpunit: '4-php-5.6'
     148            os: ubuntu-latest
     149            memcached: false
     150          - php: '5.5'
     151            phpunit: '5.5'
     152            os: ubuntu-latest
     153            memcached: false
     154          - php: '5.4'
     155            phpunit: '5.4'
     156            os: ubuntu-latest
     157            memcached: false
     158          - php: '5.3'
     159            phpunit: '5.3'
     160            os: ubuntu-latest
     161            memcached: false
    128162    env:
    129       LOCAL_PHP: ${{ matrix.php_versions }}-fpm
     163      LOCAL_PHP: ${{ matrix.php }}-fpm
     164      LOCAL_PHPUNIT: ${{ matrix.phpunit }}-fpm
     165      LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
    130166
    131167    steps:
     
    135171          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    136172
    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 
    143173      - name: Download the built WordPress artifact
    144174        uses: actions/download-artifact@v2
     
    152182        uses: actions/setup-node@v1
    153183        with:
    154           node-version: 12
     184          node-version: 14
    155185
    156186      - name: Use cached Node modules
     
    166196
    167197      - 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)"
     198        run: npx install-changed --install-command="npm ci"
    174199
    175200      - name: Cache Composer dependencies
    176         if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
     201        if: ${{ env.COMPOSER_INSTALL == true }}
    177202        uses: actions/cache@v2
    178203        env:
     
    180205        with:
    181206          path: ${{ steps.composer-cache.outputs.dir }}
    182           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
     207          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    183208          restore-keys: |
    184             ${{ runner.os }}-composer-
     209            ${{ runner.os }}-php-${{ matrix.php }}-composer-
    185210
    186211      - name: Install Composer dependencies
    187         if: ${{ env.COMPOSER_INSTALL == true || env.LOCAL_PHP == '8.0-fpm' }}
     212        if: ${{ env.COMPOSER_INSTALL == true }}
    188213        run: |
    189214          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
     215          docker-compose run --rm php composer install
    200216
    201217      - name: Docker debug information
     
    210226      # The memcached server needs to start after the Docker network has been set up with `npm run env:start`.
    211227      - name: Start the Memcached server.
    212         if: ${{ contains( matrix.php_versions, 'memcached' ) }}
     228        if: ${{ matrix.memcached }}
    213229        run: |
    214230          cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     
    228244      - name: WordPress Docker container debug information
    229245        run: |
    230           docker -v
    231           docker-compose -v
    232246          docker-compose run --rm mysql mysql --version
    233247          docker-compose run --rm php php --version
     
    248262        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml
    249263
    250       - name: Run mutlisite file tests
     264      - name: Run ms-files tests as a multisite install
    251265        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files
    252266
     
    257271        run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group restapi-jsclient
    258272
    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.
    261273      # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
    262274      - name: Run (xDebug) tests
    263         if: ${{ env.LOCAL_PHP != '8.0-fpm' }}
    264275        run: LOCAL_PHP_XDEBUG=true npm run test:php -- -v --group xdebug --exclude-group __fakegroup__
    265276
    266       - name: WordPress Test Reporter
    267         if: ${{ matrix.php_versions == '7.4' }}
     277      - name: Checkout the WordPress Test Reporter
     278        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
    268279        uses: actions/checkout@v2
    269280        with:
    270281          repository: 'WordPress/phpunit-test-runner'
    271282          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
     283
     284      - name: Set up the Git repository
     285        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
     286        run: |
     287          git init
     288          git remote add origin https://github.com/WordPress/wordpress-develop.git
     289          git fetch
     290          git reset origin/master
     291
     292      - name: Submit test results to the WordPress.org host test results
     293        if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }}
     294        env:
     295          WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
     296        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.