Changeset 58644 for branches/4.1/.github/workflows/phpunit-tests.yml
- Timestamp:
- 07/03/2024 03:38:50 PM (12 months ago)
- Location:
- branches/4.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.1
- Property svn:mergeinfo changed
/trunk merged: 51673,53552,56464,57124-57125,57249,57918,58157
- Property svn:mergeinfo changed
-
branches/4.1/.github/workflows/phpunit-tests.yml
r55535 r58644 22 22 # Cancels all previous workflow runs for pull requests that have not completed. 23 23 concurrency: 24 25 24 # The concurrency group contains the workflow name and the branch name for pull requests 25 # or the commit hash for any other events. 26 26 group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} 27 27 cancel-in-progress: true 28 28 29 env: 30 LOCAL_DIR: build 31 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} 32 COMPOSER_INSTALL: ${{ false }} 33 # Controls which npm script to use for running PHPUnit tests. Options ar `php` and `php-composer`. 34 PHPUNIT_SCRIPT: php 35 LOCAL_PHP_MEMCACHED: ${{ false }} 29 # Disable permissions for all available scopes by default. 30 # Any needed permissions should be configured at the job level. 31 permissions: {} 36 32 37 33 jobs: 38 # Sets up WordPress for testing or development use.39 34 # 40 # Performs the following steps: 41 # - Cancels all previous workflow runs for pull requests that have not completed. 42 # - Checks out the repository. 43 # - Logs debug information about the GitHub Action runner. 44 # - Installs NodeJS. 45 # _ Installs npm dependencies. 46 # - Builds WordPress to run from the `build` directory. 47 # - Creates a ZIP file of compiled WordPress. 48 # - Uploads ZIP file as an artifact. 49 setup-wordpress: 50 name: Setup WordPress 51 runs-on: ubuntu-latest 35 # Creates a PHPUnit test job for each PHP combination. 36 # 37 test-php: 38 name: PHP ${{ matrix.php }} 39 uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v1.yml@trunk 40 permissions: 41 contents: read 42 secrets: inherit 52 43 if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} 53 54 steps:55 - name: Checkout repository56 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.057 58 - name: Log debug information59 run: |60 echo "$GITHUB_REF"61 echo "$GITHUB_EVENT_NAME"62 npm --version63 node --version64 curl --version65 git --version66 svn --version67 php --version68 php -i69 locale -a70 71 - name: Set up Node.js72 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.073 with:74 node-version-file: '.nvmrc'75 cache: npm76 77 - name: Install Dependencies78 run: npm ci79 80 - name: Build WordPress81 run: npm run build82 83 - name: Create ZIP artifact84 uses: thedoctor0/zip-release@a24011d8d445e4da5935a7e73c1f98e22a439464 # v0.7.185 with:86 filename: built-wp-${{ github.sha }}.zip87 exclusions: '*.git* /*node_modules/* packagehash.txt'88 89 - name: Upload build artifact90 uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.291 with:92 name: built-wp-${{ github.sha }}93 path: built-wp-${{ github.sha }}.zip94 if-no-files-found: error95 96 # Runs the PHPUnit tests for WordPress.97 #98 # Performs the following steps:99 # - Sets environment variables.100 # - Sets up the environment variables needed for testing with memcached (if desired).101 # - Downloads the built WordPress artifact from the previous job.102 # - Unzips the artifact.103 # - Installs NodeJS.104 # _ Installs npm dependencies.105 # - Configures caching for Composer.106 # _ Installs Composer dependencies (if desired).107 # - Logs Docker debug information (about the Docker installation within the runner).108 # - Starts the WordPress Docker container.109 # - Starts the Memcached server after the Docker network has been created (if desired).110 # - Logs general debug information about the runner.111 # - Logs the running Docker containers.112 # - Logs debug information from inside the WordPress Docker container.113 # - Logs debug information about what's installed within the WordPress Docker containers.114 # - Install WordPress within the Docker container.115 # - Run the PHPUnit tests.116 # - Checks out the WordPress Test reporter repository.117 # - Reconnect the directory to the Git repository.118 # - Submit the test results to the WordPress.org host test results.119 test-php:120 name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}121 needs: setup-wordpress122 runs-on: ${{ matrix.os }}123 timeout-minutes: 20124 44 strategy: 125 45 fail-fast: false 126 46 matrix: 47 os: [ ubuntu-latest ] 127 48 php: [ '5.3', '5.4', '5.5' ] 128 os: [ ubuntu-latest ]129 49 split_slow: [ false, true ] 130 50 multisite: [ false, true ] … … 155 75 multisite: true 156 76 memcached: false 157 env: 158 LOCAL_PHP: ${{ matrix.php }}-fpm 159 LOCAL_PHPUNIT: ${{ matrix.phpunit && matrix.phpunit || matrix.php }}-fpm 160 LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }} 161 PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }} 162 SLOW_TESTS: 'external-http,media' 163 164 steps: 165 - name: Configure environment variables 166 run: | 167 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV 168 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV 169 170 - name: Download the built WordPress artifact 171 uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 172 with: 173 name: built-wp-${{ github.sha }} 174 175 - name: Unzip built artifact 176 run: unzip built-wp-${{ github.sha }}.zip 177 178 - name: Set up Node.js 179 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 180 with: 181 node-version-file: '.nvmrc' 182 cache: npm 183 184 - name: Install Dependencies 185 run: npm ci 186 187 - name: Cache Composer dependencies 188 if: ${{ env.COMPOSER_INSTALL == true }} 189 uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6 190 env: 191 cache-name: cache-composer-dependencies 192 with: 193 path: ${{ steps.composer-cache.outputs.dir }} 194 key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} 195 196 - name: Install Composer dependencies 197 if: ${{ env.COMPOSER_INSTALL == true }} 198 run: | 199 docker-compose run --rm php composer --version 200 docker-compose run --rm php composer install 201 202 - name: Docker debug information 203 run: | 204 docker -v 205 docker-compose -v 206 207 - name: Start Docker environment 208 run: | 209 npm run env:start 210 211 # The memcached server needs to start after the Docker network has been set up with `npm run env:start`. 212 - name: Start the Memcached server. 213 if: ${{ matrix.memcached }} 214 run: | 215 cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php 216 docker run --name memcached --net $(basename "$PWD")_wpdevnet -d memcached 217 218 - name: General debug information 219 run: | 220 npm --version 221 node --version 222 curl --version 223 git --version 224 svn --version 225 226 - name: Log running Docker containers 227 run: docker ps -a 228 229 - name: WordPress Docker container debug information 230 run: | 231 docker-compose run --rm mysql mysql --version 232 docker-compose run --rm php php --version 233 docker-compose run --rm php php -m 234 docker-compose run --rm php php -i 235 docker-compose run --rm php locale -a 236 237 - name: Install WordPress 238 run: npm run env:install 239 240 - name: Run slow PHPUnit tests 241 if: ${{ matrix.split_slow }} 242 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }} 243 244 - name: Run PHPUnit tests for single site excluding slow tests 245 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }} 246 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required 247 248 - name: Run PHPUnit tests for Multisite excluding slow tests 249 if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }} 250 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers 251 252 - name: Run PHPUnit tests 253 if: ${{ matrix.php >= '7.0' }} 254 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} 255 256 - name: Run AJAX tests 257 if: ${{ ! matrix.multisite && ! matrix.split_slow }} 258 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax 259 260 - name: Run external HTTP tests 261 if: ${{ ! matrix.multisite && ! matrix.split_slow }} 262 run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --group external-http 263 264 - name: Checkout the WordPress Test Reporter 265 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }} 266 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 267 with: 268 repository: 'WordPress/phpunit-test-runner' 269 path: 'test-runner' 270 271 - name: Set up the Git repository 272 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }} 273 run: | 274 git init 275 git remote add origin https://github.com/WordPress/wordpress-develop.git 276 git fetch 277 git reset origin/trunk 278 279 - name: Submit test results to the WordPress.org host test results 280 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }} 281 env: 282 WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}" 283 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 phpunit: ${{ matrix.phpunit && matrix.phpunit || matrix.php }} 81 multisite: ${{ matrix.multisite }} 82 split_slow: ${{ matrix.split_slow }} 83 memcached: ${{ matrix.memcached }} 84 phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }} 284 85 285 86 slack-notifications: 286 87 name: Slack Notifications 287 88 uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk 288 needs: [ setup-wordpress, test-php ] 89 permissions: 90 actions: read 91 contents: read 92 needs: [ test-php ] 289 93 if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} 290 94 with: … … 299 103 name: Failed workflow tasks 300 104 runs-on: ubuntu-latest 105 permissions: 106 actions: write 301 107 needs: [ test-php, slack-notifications ] 302 108 if: | … … 311 117 steps: 312 118 - name: Dispatch workflow run 313 uses: actions/github-script@ 98814c53be79b1d30f795b907e553d8679345975 # v6.4.0119 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 314 120 with: 315 121 retries: 2
Note: See TracChangeset
for help on using the changeset viewer.