Make WordPress Core


Ignore:
Timestamp:
02/26/2021 02:07:53 PM (4 years ago)
Author:
johnbillion
Message:

Build/Test Tools: Switch back to running the PHPUnit test suite against the src directory instead of build.

Some PHPUnit tests were concerned with the state of files in the build directory. In order to allow the tests to run without requiring a build to be run first, these have been moved into assertions that run after the build step (and therefore cause it to fail if they do not pass), or into QUnit tests as necessary.

Various other PHPUnit tests implictly depend on built JavaScript files being present. These files are now touched during the test setup to avoid PHP warnings if the build files are not present.

The wp-tests-config-sample.php file and the GitHub Actions configuration have also been changed so ABSPATH uses src instead of build, therefore allowing the PHPUnit tests to be run without a build having to be run first. This means all new local installations of WordPress will use src for PHPUnit testing. If you would like to switch your existing installation over then change the location of ABSPATH in wp-tests-config.php to point to src instead of build.

Props peterwilsoncc, iandunn, gziolo, desroj, johnbillion

Fixes #51734
See #45863

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/phpunit-tests.yml

    r50436 r50441  
    2020
    2121env:
    22   LOCAL_DIR: build
    2322  PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
    2423  COMPOSER_INSTALL: ${{ false }}
     
    2827
    2928jobs:
    30   # Sets up WordPress for testing or development use.
     29  # Sets up the workflow for testing.
    3130  #
    3231  # Performs the following steps:
    3332  # - Cancels all previous workflow runs for pull requests that have not completed.
    34   # - Checks out the repository.
    35   # - Logs debug information about the runner container.
    36   # - Installs NodeJS 14.
    37   # - Sets up caching for NPM.
    38   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
    39   # - Builds WordPress to run from the `build` directory.
    40   # - Creates a ZIP file of compiled WordPress.
    41   # - Uploads ZIP file as an artifact.
    42   setup-wordpress:
    43     name: Setup WordPress
     33  setup-workflow:
     34    name: Setup Workflow
    4435    runs-on: ubuntu-latest
    4536    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
     
    5142        with:
    5243          access_token: ${{ github.token }}
    53 
    54       - name: Checkout repository
    55         uses: actions/checkout@v2
    56 
    57       - name: Log debug information
    58         run: |
    59           echo "$GITHUB_REF"
    60           echo "$GITHUB_EVENT_NAME"
    61           npm --version
    62           node --version
    63           curl --version
    64           git --version
    65           svn --version
    66           php --version
    67           php -i
    68           locale -a
    69 
    70       - name: Install NodeJS
    71         uses: actions/setup-node@v2
    72         with:
    73           node-version: 14
    74 
    75       - name: Cache NodeJS modules
    76         uses: actions/cache@v2
    77         env:
    78           cache-name: cache-node-modules
    79         with:
    80           # npm cache files are stored in `~/.npm` on Linux/macOS
    81           path: ~/.npm
    82           key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    83 
    84       - name: Install Dependencies
    85         run: npx install-changed --install-command="npm ci"
    86 
    87       - name: Build WordPress
    88         run: npm run build
    89 
    90       - name: Create ZIP artifact
    91         uses: thedoctor0/zip-release@0.4.1
    92         with:
    93           filename: built-wp-${{ github.sha }}.zip
    94           exclusions: '*.git* /*node_modules/* packagehash.txt'
    95 
    96       - name: Upload build artifact
    97         uses: actions/upload-artifact@v2
    98         with:
    99           name: built-wp-${{ github.sha }}
    100           path: built-wp-${{ github.sha }}.zip
    101           if-no-files-found: error
    10244
    10345  # Runs the PHPUnit tests for WordPress.
     
    10648  # - Set environment variables.
    10749  # - Sets up the environment variables needed for testing with memcached (if desired).
    108   # - Downloads the built WordPress artifact from the previous job.
    109   # - Unzips the artifact.
    11050  # - Installs NodeJS 14.
    11151  # - Sets up caching for NPM.
    112   # _ Installs NPM dependencies using install-changed to hash the `package.json` file.
     52  # - Installs NPM dependencies
    11353  # - Configures caching for Composer.
    114   # _ Installs Composer dependencies (if desired).
     54  # - Installs Composer dependencies (if desired).
    11555  # - Logs Docker debug information (about both the Docker installation within the runner).
    11656  # - Starts the WordPress Docker container.
     
    12868  test-php:
    12969    name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
    130     needs: setup-wordpress
    13170    runs-on: ${{ matrix.os }}
    13271    strategy:
     
    164103          echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    165104
    166       - name: Download the built WordPress artifact
    167         uses: actions/download-artifact@v2
    168         with:
    169           name: built-wp-${{ github.sha }}
    170 
    171       - name: Unzip built artifact
    172         run: unzip built-wp-${{ github.sha }}.zip
     105      - name: Checkout repository
     106        uses: actions/checkout@v2
    173107
    174108      - name: Install NodeJS
     
    231165        if: ${{ matrix.memcached }}
    232166        run: |
    233           cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php
     167          cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    234168          docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached
    235169
Note: See TracChangeset for help on using the changeset viewer.