@@ -30,14 +30,14 @@ jobs:
3030 - name : Checkout including last 2 commits
3131 # Fetch last 2 commits if it's not a PR, so that we can determine the list of modified files.
3232 if : ${{ github.base_ref == null }}
33- uses : actions/checkout@v2
33+ uses : actions/checkout@v3
3434 with :
3535 fetch-depth : 2
3636
3737 - name : Checkout
3838 # Do usual checkout if it's a PR.
3939 if : ${{ github.base_ref != null }}
40- uses : actions/checkout@v2
40+ uses : actions/checkout@v3
4141
4242 - name : Fetch base branch
4343 # Only fetch base ref if it's a PR.
8787 runs-on : ubuntu-latest
8888 steps :
8989 - name : Checkout
90- uses : actions/checkout@v2
90+ uses : actions/checkout@v3
9191
9292 - name : Setup Node
9393 uses : actions/setup-node@v3.0.0
@@ -112,7 +112,7 @@ jobs:
112112 runs-on : ubuntu-latest
113113 steps :
114114 - name : Checkout
115- uses : actions/checkout@v2
115+ uses : actions/checkout@v3
116116
117117 - name : Setup Node
118118 uses : actions/setup-node@v3.0.0
@@ -161,7 +161,7 @@ jobs:
161161 runs-on : ubuntu-latest
162162 steps :
163163 - name : Checkout
164- uses : actions/checkout@v2
164+ uses : actions/checkout@v3
165165
166166 - name : Setup PHP
167167 uses : shivammathur/setup-php@v2
@@ -206,7 +206,7 @@ jobs:
206206 if : needs.pre-run.outputs.changed-php-count > 0
207207 steps :
208208 - name : Checkout
209- uses : actions/checkout@v2
209+ uses : actions/checkout@v3
210210
211211 - name : Setup PHP
212212 uses : shivammathur/setup-php@v2
@@ -246,7 +246,7 @@ jobs:
246246
247247 steps :
248248 - name : Checkout
249- uses : actions/checkout@v2
249+ uses : actions/checkout@v3
250250
251251 - name : Setup Node
252252 uses : actions/setup-node@v3.0.0
@@ -285,7 +285,7 @@ jobs:
285285
286286 steps :
287287 - name : Checkout
288- uses : actions/checkout@v2
288+ uses : actions/checkout@v3
289289
290290 - name : Setup PHP
291291 uses : shivammathur/setup-php@v2
@@ -343,7 +343,6 @@ jobs:
343343 name : " Unit test${{ matrix.coverage && ' (with coverage)' || '' }}: PHP ${{ matrix.php }}, WP ${{ matrix.wp }}"
344344 runs-on : ubuntu-latest
345345 needs : pre-run
346- if : needs.pre-run.outputs.changed-file-count > 0
347346 env :
348347 WP_CORE_DIR : /tmp/wordpress
349348 services :
@@ -400,10 +399,20 @@ jobs:
400399 coverage : false
401400
402401 steps :
402+ # Note: The repeated `needs.pre-run.outputs.changed-php-count > 0` checks would be avoided if a step could short-
403+ # circuit per <https://github.com/actions/runner/issues/662>. The reason why the if statement can't be put on the
404+ # job as a whole is because the name is variable based on the matrix, and if the condition is not met then the
405+ # name won't be interpolated in order to match the required jobs set up in branch protection.
406+ - name : Notice
407+ if : needs.pre-run.outputs.changed-php-count == 0
408+ run : echo "No PHP files were changed so no PHP unit tests will run"
409+
403410 - name : Checkout
404- uses : actions/checkout@v2
411+ if : needs.pre-run.outputs.changed-php-count > 0
412+ uses : actions/checkout@v3
405413
406414 - name : Setup PHP
415+ if : needs.pre-run.outputs.changed-php-count > 0
407416 uses : shivammathur/setup-php@v2
408417 with :
409418 php-version : ${{ matrix.php }}
@@ -412,25 +421,30 @@ jobs:
412421 ini-values : pcov.directory=.
413422
414423 - name : Shutdown default MySQL service
424+ if : needs.pre-run.outputs.changed-php-count > 0
415425 run : sudo service mysql stop
416426
417427 - name : Verify MariaDB connection
428+ if : needs.pre-run.outputs.changed-php-count > 0
418429 run : |
419430 while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do
420431 sleep 1
421432 done
422433
423434 - name : Setup Node
435+ if : needs.pre-run.outputs.changed-php-count > 0
424436 uses : actions/setup-node@v3.0.0
425437 with :
426438 node-version-file : ' .nvmrc'
427439 cache : npm
428440
429441 - name : Get Composer Cache Directory
442+ if : needs.pre-run.outputs.changed-php-count > 0
430443 id : composer-cache
431444 run : echo "::set-output name=dir::$(composer config cache-files-dir)"
432445
433446 - name : Configure Composer cache
447+ if : needs.pre-run.outputs.changed-php-count > 0
434448 uses : actions/cache@v2
435449 with :
436450 path : ${{ steps.composer-cache.outputs.dir }}
@@ -439,29 +453,35 @@ jobs:
439453 ${{ runner.os }}-composer-
440454
441455 - name : Install Composer dependencies
456+ if : needs.pre-run.outputs.changed-php-count > 0
442457 run : composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction
443458
444459 - name : Install Node dependencies
460+ if : needs.pre-run.outputs.changed-php-count > 0
445461 run : npm ci
446462 env :
447463 CI : true
448464
449465 - name : Build plugin
466+ if : needs.pre-run.outputs.changed-php-count > 0
450467 run : npm run build:js
451468
452469 # Scan the logs for failing tests and surface that information by creating annotations and log file decorations.
453470 - name : Setup problem matcher to provide annotations for PHPUnit
471+ if : needs.pre-run.outputs.changed-php-count > 0
454472 # The JSON file is provided by the `shivammathur/setup-php` action. See https://github.com/shivammathur/setup-php#problem-matchers.
455473 run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
456474
457475 - name : Install WP tests
476+ if : needs.pre-run.outputs.changed-php-count > 0
458477 run : bash bin/ci/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true
459478
460479 - name : Post install of WP tests
480+ if : needs.pre-run.outputs.changed-php-count > 0
461481 run : bash bin/ci/after-wp-install.sh ${{ matrix.wp }} ${{ matrix.install-pwa-plugin == true }} /tmp/wordpress-tests
462482
463483 - name : Setup PCOV
464- if : ${{ matrix.coverage == true }}
484+ if : ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
465485 # phpdocumentor/reflection has to be removed as it makes use of an outdated dependency, making pcov/clobber
466486 # unable to be installed.
467487 run : |
@@ -470,25 +490,26 @@ jobs:
470490 vendor/bin/pcov clobber
471491
472492 - name : Copy plugin to WP plugins directory
493+ if : needs.pre-run.outputs.changed-php-count > 0
473494 run : cp -r "$PWD" "$WP_CORE_DIR/src/wp-content/plugins/amp"
474495
475496 - name : Run tests
476- if : ${{ matrix.coverage == false }}
497+ if : ${{ matrix.coverage == false && needs.pre-run.outputs.changed-php-count > 0 }}
477498 run : vendor/bin/phpunit --verbose
478499 working-directory : ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
479500
480501 - name : Run tests with coverage
481- if : ${{ matrix.coverage == true }}
502+ if : ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
482503 run : vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml
483504 working-directory : ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
484505
485506 - name : Run external HTTP tests
486- if : ${{ matrix.external-http == true }}
507+ if : ${{ matrix.external-http == true && needs.pre-run.outputs.changed-php-count > 0 }}
487508 run : vendor/bin/phpunit --testsuite external-http
488509 working-directory : ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
489510
490511 - name : Upload code coverage report
491- if : ${{ matrix.coverage == true }}
512+ if : ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
492513 uses : codecov/codecov-action@v2.1.0
493514 with :
494515 file : ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp/build/logs/clover.xml
@@ -500,7 +521,7 @@ jobs:
500521 feature-test-php :
501522 name : " Feature test${{ matrix.coverage && ' (with coverage)' || '' }}: PHP ${{ matrix.php }}, WP ${{ matrix.wp }}"
502523 needs : pre-run
503- if : needs.pre-run.outputs.changed-file -count > 0
524+ if : needs.pre-run.outputs.changed-php -count > 0
504525 runs-on : ubuntu-latest
505526 env :
506527 WP_VERSION : ${{ matrix.wp }}
@@ -550,7 +571,7 @@ jobs:
550571
551572 steps :
552573 - name : Checkout
553- uses : actions/checkout@v2
574+ uses : actions/checkout@v3
554575
555576 - name : Setup PHP
556577 uses : shivammathur/setup-php@v2
@@ -662,7 +683,7 @@ jobs:
662683
663684 steps :
664685 - name : Check out source files
665- uses : actions/checkout@v2
686+ uses : actions/checkout@v3
666687
667688 - name : Setup PHP
668689 uses : shivammathur/setup-php@v2
0 commit comments