Changeset 58597 for branches/5.8/.github/workflows/phpunit-tests.yml
- Timestamp:
- 06/28/2024 06:40:36 PM (20 months ago)
- Location:
- branches/5.8
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
.github/workflows/phpunit-tests.yml (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
- Property svn:mergeinfo changed
/trunk merged: 52179,53552,53895,56113-56114,57124-57125,57249,57918,58157
- Property svn:mergeinfo changed
-
branches/5.8/.github/workflows/phpunit-tests.yml
r55517 r58597 27 27 cancel-in-progress: true 28 28 29 env: 30 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} 31 # Controls which npm script to use for running PHPUnit tests. Options ar `php` and `php-composer`. 32 PHPUNIT_SCRIPT: php 33 LOCAL_PHP_MEMCACHED: ${{ false }} 34 SLOW_TESTS: 'external-http,media,restapi' 29 # Disable permissions for all available scopes by default. 30 # Any needed permissions should be configured at the job level. 31 permissions: {} 35 32 36 33 jobs: 37 # Runs the PHPUnit tests for WordPress. 38 # 39 # Performs the following steps: 40 # - Sets environment variables. 41 # - Sets up the environment variables needed for testing with memcached (if desired). 42 # - Installs Node.js. 43 # - Installs npm dependencies 44 # - Configures caching for Composer. 45 # - Installs Composer dependencies. 46 # - Logs Docker debug information (about the Docker installation within the runner). 47 # - Starts the WordPress Docker container. 48 # - Starts the Memcached server after the Docker network has been created (if desired). 49 # - Logs general debug information about the runner. 50 # - Logs the running Docker containers. 51 # - Logs debug information from inside the WordPress Docker container. 52 # - Logs debug information about what's installed within the WordPress Docker containers. 53 # - Install WordPress within the Docker container. 54 # - Run the PHPUnit tests. 55 # - Ensures version-controlled files are not modified or deleted. 56 # - Checks out the WordPress Test reporter repository. 57 # - Reconnect the directory to the Git repository. 58 # - Submit the test results to the WordPress.org host test results. 34 # Creates PHPUnit test jobs. 59 35 test-php: 60 name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }} 61 runs-on: ${{ matrix.os }} 62 timeout-minutes: 20 36 name: PHP ${{ matrix.php }} 37 uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v2.yml@trunk 38 permissions: 39 contents: read 40 secrets: inherit 63 41 if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} 64 42 strategy: 65 43 fail-fast: false 66 44 matrix: 45 os: [ ubuntu-latest ] 67 46 php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ] 68 os: [ ubuntu-latest ] 47 multisite: [ false, true ] 48 split_slow: [ false ] 69 49 memcached: [ false ] 70 split_slow: [ false ]71 multisite: [ false, true ]72 50 include: 73 51 # Additional "slow" jobs for PHP 5.6. … … 97 75 multisite: false 98 76 report: true 99 env: 100 LOCAL_PHP: ${{ matrix.php }}-fpm 101 LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }} 102 PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }} 103 104 steps: 105 - name: Configure environment variables 106 run: | 107 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV 108 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV 109 110 - name: Checkout repository 111 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 112 113 - name: Install Node.js 114 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 115 with: 116 node-version-file: '.nvmrc' 117 cache: npm 118 119 - name: Install npm dependencies 120 run: npm ci 121 122 - name: Get composer cache directory 123 id: composer-cache 124 run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT 125 126 - name: Cache Composer dependencies 127 uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 128 env: 129 cache-name: cache-composer-dependencies 130 with: 131 path: ${{ steps.composer-cache.outputs.composer_dir }} 132 key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} 133 134 - name: Install Composer dependencies 135 run: | 136 docker-compose run --rm php composer --version 137 138 # The PHPUnit 7.x phar is not compatible with PHP 8 and won't be updated, 139 # as PHPUnit 7 is no longer supported. The Composer-installed PHPUnit should be 140 # used for PHP 8 testing instead. 141 if [ ${{ env.LOCAL_PHP }} == '8.0-fpm' ]; then 142 docker-compose run --rm php composer install --ignore-platform-reqs 143 echo "PHPUNIT_SCRIPT=php-composer" >> $GITHUB_ENV 144 elif [ ${{ env.LOCAL_PHP }} == '7.1-fpm' ]; then 145 docker-compose run --rm php composer update 146 git checkout -- composer.lock 147 elif [[ ${{ env.LOCAL_PHP }} == '5.6-fpm' || ${{ env.LOCAL_PHP }} == '7.0-fpm' ]]; then 148 docker-compose run --rm php composer require --dev phpunit/phpunit:"^5.7" --update-with-dependencies 149 git checkout -- composer.lock composer.json 150 else 151 docker-compose run --rm php composer install 152 fi 153 154 - name: Docker debug information 155 run: | 156 docker -v 157 docker-compose -v 158 159 - name: Start Docker environment 160 run: | 161 npm run env:start 162 163 # The memcached server needs to start after the Docker network has been set up with `npm run env:start`. 164 - name: Start the Memcached server. 165 if: ${{ matrix.memcached }} 166 run: | 167 cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php 168 docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached 169 170 - name: General debug information 171 run: | 172 npm --version 173 node --version 174 curl --version 175 git --version 176 svn --version 177 178 - name: Log running Docker containers 179 run: docker ps -a 180 181 - name: WordPress Docker container debug information 182 run: | 183 docker-compose run --rm mysql mysql --version 184 docker-compose run --rm php php --version 185 docker-compose run --rm php php -m 186 docker-compose run --rm php php -i 187 docker-compose run --rm php locale -a 188 189 - name: Install WordPress 190 run: npm run env:install 191 192 - name: Run slow PHPUnit tests 193 if: ${{ matrix.split_slow }} 194 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }} 195 196 - name: Run PHPUnit tests for single site excluding slow tests 197 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }} 198 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required 199 200 - name: Run PHPUnit tests for Multisite excluding slow tests 201 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }} 202 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers 203 204 - name: Run PHPUnit tests 205 if: ${{ matrix.php >= '7.0' }} 206 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} 207 208 - name: Run AJAX tests 209 if: ${{ ! matrix.split_slow }} 210 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax 211 212 - name: Run ms-files tests as a multisite install 213 if: ${{ matrix.multisite && ! matrix.split_slow }} 214 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --group ms-files 215 216 - name: Run external HTTP tests 217 if: ${{ ! matrix.multisite && ! matrix.split_slow }} 218 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http 219 220 # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist. 221 - name: Run (xDebug) tests 222 if: ${{ ! matrix.split_slow }} 223 run: LOCAL_PHP_XDEBUG=true npm run test:${{ env.PHPUNIT_SCRIPT }} -- -v --group xdebug --exclude-group __fakegroup__ 224 225 - name: Ensure version-controlled files are not modified or deleted 226 run: git diff --exit-code 227 228 - name: Checkout the WordPress Test Reporter 229 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }} 230 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 231 with: 232 repository: 'WordPress/phpunit-test-runner' 233 path: 'test-runner' 234 235 - name: Submit test results to the WordPress.org host test results 236 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }} 237 env: 238 WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}" 239 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 77 with: 78 os: ${{ matrix.os }} 79 php: ${{ matrix.php }} 80 multisite: ${{ matrix.multisite }} 81 split_slow: ${{ matrix.split_slow }} 82 memcached: ${{ matrix.memcached }} 83 phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }} 84 report: ${{ matrix.report || false }} 240 85 241 86 slack-notifications: 242 87 name: Slack Notifications 243 88 uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk 89 permissions: 90 actions: read 91 contents: read 244 92 needs: [ test-php ] 245 93 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} 246 94 with: 247 calling_status: ${{ needs.test-php.result == 'success' && 'success' || needs.test-php.result == 'cancelled' && 'cancelled' || 'failure' }}95 calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} 248 96 secrets: 249 97 SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} … … 255 103 name: Failed workflow tasks 256 104 runs-on: ubuntu-latest 257 needs: [ test-php, slack-notifications ] 105 permissions: 106 actions: write 107 needs: [ slack-notifications ] 258 108 if: | 259 109 always() && … … 262 112 github.run_attempt < 2 && 263 113 ( 264 needs.test-php.result == 'cancelled' || needs.test-php.result == 'failure' 114 contains( needs.*.result, 'cancelled' ) || 115 contains( needs.*.result, 'failure' ) 265 116 ) 266 117 267 118 steps: 268 119 - name: Dispatch workflow run 269 uses: actions/github-script@ 98814c53be79b1d30f795b907e553d8679345975 # v6.4.0120 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 270 121 with: 271 122 retries: 2
Note: See TracChangeset
for help on using the changeset viewer.