@@ -367,67 +367,16 @@ jobs:
367367 unit :
368368 needs : prepare-unit
369369 if : ${{ needs.prepare-unit.outputs.matrix != '' }}
370- name : Unit test - PHP ${{ matrix.php }}${{ matrix.coverage && ' (with coverage)' || '' }} ${{ startsWith( matrix.os, 'windows' ) && '(Windows)' || '' }} ${{ startsWith( matrix.os, 'macos' ) && '(macOS)' || '' }}
370+ name : Unit
371371 strategy :
372372 fail-fast : false
373373 matrix : ${{ fromJson(needs.prepare-unit.outputs.matrix) }}
374- runs-on : ${{ matrix.os || 'ubuntu-22.04' }}
375-
376- continue-on-error : ${{ matrix.php == 'nightly' }}
377-
378- steps :
379- - name : Check out source code
380- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
381-
382- - name : Set up PHP environment
383- uses : shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
384- with :
385- php-version : ' ${{ matrix.php }}'
386- ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
387- extensions : zip
388- coverage : ${{ matrix.coverage && 'xdebug' || 'none' }}
389- tools : composer,cs2pr
390- env :
391- COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
392-
393- - name : Install Composer dependencies & cache dependencies
394- uses : " ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3
395- env :
396- COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
397- with :
398- # Bust the cache at least once a month - output format: YYYY-MM.
399- custom-cache-suffix : $(date -u "+%Y-%m")
400-
401- # PHPUnit 10+ may fail a test run when the "old" configuration format is used.
402- # Luckily, there is a build-in migration tool since PHPUnit 9.3.
403- - name : Migrate PHPUnit configuration for PHPUnit 10+
404- if : ${{ matrix.php >= 8.2 || matrix.php == 'nightly' }}
405- continue-on-error : true
406- run : composer phpunit -- --migrate-configuration
407-
408- - name : Setup problem matcher to provide annotations for PHPUnit
409- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
410-
411- - name : Run PHPUnit with coverage
412- if : ${{ matrix.coverage }}
413- run : |
414- composer phpunit -- --coverage-clover build/logs/unit-coverage.xml
415-
416- - name : Run PHPUnit
417- if : ${{ ! matrix.coverage }}
418- # For example TestBehatTags.php in wp-cli-tests depends on the db type.
419- env :
420- WP_CLI_TEST_DBTYPE : ' sqlite'
421- run : |
422- composer phpunit
423-
424- - name : Upload code coverage report
425- if : ${{ matrix.coverage }}
426- uses : codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
427- with :
428- directory : build/logs
429- flags : unit
430- token : ${{ secrets.CODECOV_TOKEN }}
374+ uses : ./.github/workflows/reusable-unit.yml
375+ secrets : inherit
376+ with :
377+ php : ${{ matrix.php }}
378+ coverage : ${{ matrix.coverage }}
379+ os : ${{ matrix.os }}
431380
432381 prepare-functional :
433382 name : Prepare matrix for functional tests
@@ -486,119 +435,17 @@ jobs:
486435 functional :
487436 needs : prepare-functional
488437 if : ${{ needs.prepare-functional.outputs.matrix != '' }}
489- name : PHP ${{ matrix.php }} - WP ${{ matrix.wp }} on ${{ matrix.dbtype != 'sqlite' && matrix.mysql || 'SQLite' }}${{ matrix.object_cache == 'sqlite' && ' (SQLite Object Cache)' || '' }}${{ matrix.coverage && ' (with coverage)' || '' }} ${{ startsWith( matrix.os, 'windows' ) && '(Windows)' || '' }} ${{ startsWith( matrix.os, 'macos' ) && '(macOS)' || '' }}
438+ name : Functional
490439 strategy :
491440 fail-fast : false
492441 matrix : ${{ fromJson(needs.prepare-functional.outputs.matrix) }}
493- runs-on : ${{ matrix.os || 'ubuntu-22.04' }}
494-
495- continue-on-error : ${{ matrix.dbtype == 'sqlite' || matrix.dbtype == 'mariadb' || matrix.php == 'nightly' }}
496-
497- env :
498- MYSQL_HOST : 127.0.0.1
499- MYSQL_TCP_PORT : 3306
500- WP_CLI_TEST_DBROOTUSER : root
501- WP_CLI_TEST_DBROOTPASS : root
502- WP_CLI_TEST_DBNAME : wp_cli_test
503- WP_CLI_TEST_DBUSER : wp_cli_test
504- WP_CLI_TEST_DBPASS : password1
505- WP_CLI_TEST_DBHOST : 127.0.0.1:3306
506- WP_CLI_TEST_OBJECT_CACHE : ${{ matrix.object_cache }}
507-
508- steps :
509- - name : Check out source code
510- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
511-
512- - name : Install Ghostscript
513- if : ${{ matrix.os == 'ubuntu-22.04' || matrix.os == '' }}
514- run : |
515- sudo apt-get update
516- sudo apt-get install ghostscript -y
517-
518- - name : Set up PHP environment
519- uses : shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
520- with :
521- php-version : ' ${{ matrix.php }}'
522- ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
523- extensions : gd, imagick, mysql, zip, pdo_sqlite
524- coverage : ${{ matrix.coverage && 'xdebug' || 'none' }}
525- tools : composer
526- env :
527- COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
528-
529- - name : Change ImageMagick policy to allow pdf->png conversion.
530- if : ${{ matrix.os == 'ubuntu-22.04' || matrix.os == '' }}
531- run : |
532- sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
533-
534- - name : Install Composer dependencies & cache dependencies
535- uses : " ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v3
536- env :
537- COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
538- with :
539- # Bust the cache at least once a month - output format: YYYY-MM.
540- custom-cache-suffix : $(date -u "+%Y-%m")
541-
542- # MySQL 8.4 requires explicit loading of mysql_native_password plugin
543- - name : Determine MySQL authentication configuration
544- id : mysql-config
545- if : ${{ matrix.dbtype != 'sqlite' && matrix.mysql == 'mysql-8.4' }}
546- run : |
547- echo "auth-config<<EOF" >> $GITHUB_OUTPUT
548- echo "mysql_native_password=ON" >> $GITHUB_OUTPUT
549- echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT
550- echo "EOF" >> $GITHUB_OUTPUT
551-
552- - name : Setup MySQL Server
553- id : setup-mysql
554- if : ${{ matrix.dbtype != 'sqlite' }}
555- uses : shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1
556- with :
557- mysql-version : ${{ matrix.mysql }}
558- auto-start : true
559- root-password : ${{ env.WP_CLI_TEST_DBROOTPASS }}
560- user : ${{ env.WP_CLI_TEST_DBUSER}}
561- password : ${{ env.WP_CLI_TEST_DBPASS}}
562- # Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB.
563- my-cnf : |
564- ${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }}
565- ${{ matrix.dbtype == 'mariadb' && '[client]' || '' }}
566- ${{ matrix.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}
567-
568- - name : Prepare test database
569- if : ${{ matrix.dbtype != 'sqlite' }}
570- run : composer prepare-tests
571-
572- - name : Check Behat environment
573- env :
574- WP_VERSION : ' ${{ matrix.wp }}'
575- WP_CLI_TEST_DBTYPE : ${{ matrix.dbtype || 'mysql' }}
576- WP_CLI_TEST_DBSOCKET : ' ${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
577- WP_CLI_TEST_DEBUG_BEHAT_ENV : 1
578- run : composer behat
579-
580- - name : Run Behat
581- env :
582- WP_VERSION : ' ${{ matrix.wp }}'
583- WP_CLI_TEST_DBTYPE : ${{ matrix.dbtype || 'mysql' }}
584- WP_CLI_TEST_DBSOCKET : ' ${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
585- WP_CLI_TEST_COVERAGE : ${{ matrix.coverage }}
586- BEHAT_ARGS : ${{ format( '{0}', runner.debug && '--format=pretty' ) }}
587- run : |
588- composer behat -- $BEHAT_ARGS || composer behat-rerun -- $BEHAT_ARGS
589-
590- - name : Retrieve list of coverage files
591- id : coverage_files
592- if : ${{ matrix.coverage }}
593- run : |
594- FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
595- echo "files=$FILES" >> $GITHUB_OUTPUT
596-
597- - name : Upload code coverage report
598- if : ${{ matrix.coverage }}
599- uses : codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
600- with :
601- # Because somehow providing `directory: build/logs` doesn't work for these files
602- files : ${{ steps.coverage_files.outputs.files }}
603- flags : feature
604- token : ${{ secrets.CODECOV_TOKEN }}
442+ uses : ./.github/workflows/reusable-functional.yml
443+ secrets : inherit
444+ with :
445+ php : ${{ matrix.php }}
446+ wp : ${{ matrix.wp }}
447+ dbtype : ${{ matrix.dbtype }}
448+ mysql : ${{ matrix.mysql }}
449+ object_cache : ${{ matrix.object_cache }}
450+ coverage : ${{ matrix.coverage }}
451+ os : ${{ matrix.os }}
0 commit comments