diff options
author | Jonathan Desrosiers <desrosj@git.wordpress.org> | 2021-04-02 16:02:57 +0000 |
---|---|---|
committer | Jonathan Desrosiers <desrosj@git.wordpress.org> | 2021-04-02 16:02:57 +0000 |
commit | 91d7ab0f37f86cc28170f8c18a2cb81b4187aa75 (patch) | |
tree | b77d6872bc981f0e0fcdb99a9cabc8ebc970a183 /.github/workflows/phpunit-tests.yml | |
parent | 6e497fb6abaae374033949f2882f5b9e024051ba (diff) | |
download | wordpress-91d7ab0f37f86cc28170f8c18a2cb81b4187aa75.tar.gz wordpress-91d7ab0f37f86cc28170f8c18a2cb81b4187aa75.zip |
Build/Test Tools: Backport GitHub Action and build improvements to the 4.1 branch.
This backports several build and test tool improvements to the 4.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 [50379,50387,50416,50432,50435-50436,50444,50446,50473-50474,50476,50479,50485-50487,50545,50590] to the 4.1 branch.
See #50401, #51801, #51802, #52548, #52612, #52624, #52625, #52645, #52653, #52658, #52660, #52667.
git-svn-id: https://develop.svn.wordpress.org/branches/4.1@50643 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to '.github/workflows/phpunit-tests.yml')
-rw-r--r-- | .github/workflows/phpunit-tests.yml | 102 |
1 files changed, 63 insertions, 39 deletions
diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 1634abc2d7..801e8b020d 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -4,12 +4,19 @@ on: push: branches: - master + - trunk - '3.[7-9]' - '[4-9].[0-9]' tags: - '3.[7-9]*' - '[4-9].[0-9]*' pull_request: + branches: + - master + - trunk + - '3.[7-9]' + - '[4-9].[0-9]' + workflow_dispatch: # Once weekly On Sundays at 00:00 UTC. schedule: - cron: '0 0 * * 0' @@ -43,12 +50,10 @@ jobs: steps: - name: Cancel previous runs of this workflow (pull requests only) if: ${{ github.event_name == 'pull_request' }} - uses: styfle/cancel-workflow-action@0.5.0 - with: - access_token: ${{ github.token }} + uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Log debug information run: | @@ -64,35 +69,33 @@ jobs: locale -a - name: Install NodeJS - uses: actions/setup-node@v1 + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: node-version: 14 - name: Cache NodeJS modules - uses: actions/cache@v2 + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 env: cache-name: cache-node-modules with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - name: Install Dependencies - run: npx install-changed --install-command="npm ci" + run: npm ci - name: Build WordPress run: npm run build - name: Create ZIP artifact - uses: thedoctor0/zip-release@0.4.1 + uses: thedoctor0/zip-release@a1afcab9c664c9976ac398fa831eac67bed1eb0e # v0.4.1 with: filename: built-wp-${{ github.sha }}.zip exclusions: '*.git* /*node_modules/* packagehash.txt' - name: Upload build artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 with: name: built-wp-${{ github.sha }} path: built-wp-${{ github.sha }}.zip @@ -124,32 +127,48 @@ jobs: # - Submit the test results to the WordPress.org host test results. # - todo: Configure Slack notifications for failing tests. test-php: - name: ${{ matrix.php }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} + name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }} ${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} needs: setup-wordpress runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - php: [ '5.6' ] - phpunit: [ '4-php-5.6' ] + php: [ '5.3', '5.4', '5.5' ] os: [ ubuntu-latest ] + split_slow: [ false, true ] + multisite: [ false, true ] memcached: [ false ] include: - - php: '5.5' - phpunit: '5.5' + - php: '5.6' + phpunit: '4-php-5.6' + os: ubuntu-latest + split_slow: false + multisite: false + memcached: false + - php: '5.6' + phpunit: '4-php-5.6' os: ubuntu-latest + split_slow: false + multisite: true memcached: false - - php: '5.4' - phpunit: '5.4' + - php: '5.6' + phpunit: '4-php-5.6' os: ubuntu-latest + split_slow: true + multisite: false memcached: false - - php: '5.3' - phpunit: '5.3' + - php: '5.6' + phpunit: '4-php-5.6' os: ubuntu-latest + split_slow: true + multisite: true memcached: false env: LOCAL_PHP: ${{ matrix.php }}-fpm - LOCAL_PHPUNIT: ${{ matrix.phpunit }}-fpm + LOCAL_PHPUNIT: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}-fpm LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }} + PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }} + SLOW_TESTS: 'external-http,media' steps: - name: Configure environment variables @@ -158,7 +177,7 @@ jobs: echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV - name: Download the built WordPress artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 with: name: built-wp-${{ github.sha }} @@ -166,34 +185,30 @@ jobs: run: unzip built-wp-${{ github.sha }}.zip - name: Install NodeJS - uses: actions/setup-node@v1 + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 with: node-version: 14 - name: Use cached Node modules - uses: actions/cache@v2 + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 env: cache-name: cache-node-modules with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - name: Install Dependencies - run: npx install-changed --install-command="npm ci" + run: npm ci - name: Cache Composer dependencies if: ${{ env.COMPOSER_INSTALL == true }} - uses: actions/cache@v2 + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 env: cache-name: cache-composer-dependencies with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php-${{ matrix.php }}-composer- - name: Install Composer dependencies if: ${{ env.COMPOSER_INSTALL == true }} @@ -239,24 +254,33 @@ jobs: - name: Install WordPress run: npm run env:install - - name: Run PHPUnit tests - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist + - name: Run slow PHPUnit tests + if: ${{ matrix.split_slow }} + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }} - - name: Run AJAX tests - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group ajax + - name: Run PHPUnit tests for single site excluding slow tests + if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }} + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required - - name: Run tests as a multisite install - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml + - name: Run PHPUnit tests for Multisite excluding slow tests + if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }} + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers - - name: Run ms-files tests as a multisite install - run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files + - name: Run PHPUnit tests + if: ${{ matrix.php >= '7.0' }} + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} + + - name: Run AJAX tests + if: ${{ ! matrix.multisite && ! matrix.split_slow }} + run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax - name: Run external HTTP tests + if: ${{ ! matrix.multisite && ! matrix.split_slow }} run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http - name: Checkout the WordPress Test Reporter if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/master' && matrix.report }} - uses: actions/checkout@v2 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: repository: 'WordPress/phpunit-test-runner' path: 'test-runner' |