ci: support php 8.0 later #51
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WordPress Plugin Unit test | |
on: | |
push: | |
branches: | |
- '**' | |
- '!svn-trunk' | |
- '!test-matrix' | |
tags-ignore: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
phpunit: | |
name: WordPress ${{ matrix.wordpress }} * PHP v${{ matrix.php }} * ${{ matrix.os }} * Multisite ${{ matrix.multisite }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-20.04 ] | |
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] | |
wordpress: [ latest, nightly ] | |
multisite: [ 0 ] | |
env: | |
PHP_VERSION: ${{ matrix.php }} | |
WP_VERSION: ${{ matrix.wordpress }} | |
WP_MULTISITE: ${{ matrix.multisite }} | |
services: | |
database: | |
image: mysql:5.7 | |
ports: | |
- 3306:3306 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup PHP v${{ matrix.php }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: mbstring, intl, php-mysql | |
- name: apt --fix-broken install for PHP 7.0 | |
run: sudo apt --fix-broken install | |
if: ${{ matrix.php == '7.0' }} | |
- name: Install mbstring library for PHP 7.0 | |
# require ext-mbstring * -> it is missing from your system. Install or enable PHP's mbstring extension. | |
run: sudo apt-get install php7.0-mbstring | |
if: ${{ matrix.php == '7.0' }} | |
- name: Install PHPUnit | |
run: | | |
# for PHP Compatibility - https://phpunit.de/supported-versions.html | |
if [[ ${PHP_VERSION:0:1} == "8" ]] ; then | |
composer global require "phpunit/phpunit=8.*" | |
elif [[ $PHP_VERSION == "7.0" ]] ; then | |
composer global require "phpunit/phpunit=5.7.*|6.*" | |
# for WP_VERSION < 4.6 due to PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found | |
elif [[ ${PHP_VERSION:0:1} == "7" ]] && [[ "$WP_VERSION" < 4.6* ]] ; then | |
composer global require "phpunit/phpunit=5.7.*" | |
# for WP_VERSION < 5.0 due to Fatal error: Class PHPUnit_Util_Test may not inherit from final class (PHPUnit\Util\Test) | |
elif [[ ${PHP_VERSION:0:1} == "7" ]] && [[ "$WP_VERSION" < 5.0* ]] ; then | |
composer global require "phpunit/phpunit=5.7.*|6.*" | |
else | |
composer global require "phpunit/phpunit=4.8.*|5.4.*|5.7.*|6.*|7.*" | |
fi | |
- name: Install PHPUnit Polyfills library | |
run: composer global require "yoast/phpunit-polyfills=1.0.3" | |
- name: Install wp tests | |
run: bash bin/install-wp-tests.sh wordpress_test root root 0.0.0.0:3306 $WP_VERSION | |
- name: Install twentysixteen WordPress theme | |
run: | | |
if [[ ! -d "/tmp/wordpress/wp-content/themes/twentysixteen" ]] ; then | |
git clone https://github.com/WordPress/twentysixteen.git /tmp/wordpress/wp-content/themes/twentysixteen | |
fi | |
- name: Run PHPUnit - WordPress ${{ matrix.wordpress }} * Multisite ${{ matrix.multisite }} | |
run: | | |
if [[ $PHP_VERSION == "5.6" ]] || [[ $PHP_VERSION == "7.0" ]] ; then | |
phpunit --configuration phpunit-legacy.xml | |
else | |
phpunit | |
fi | |
phpcs: | |
name: PHP CodeSniffer | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-20.04 ] | |
php: [ '7.4' ] | |
wordpress: [ latest ] | |
multisite: [ 0 ] | |
env: | |
PHP_VERSION: ${{ matrix.php }} | |
WP_VERSION: ${{ matrix.wordpress }} | |
WP_MULTISITE: ${{ matrix.multisite }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup PHP v${{ matrix.php }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: mbstring, intl, php-mysql | |
- name: Install php_codesniffer library and PHP_CodeSniffer rules | |
run: | | |
composer global require "squizlabs/php_codesniffer=3.*" | |
composer global require "wp-coding-standards/wpcs=2.*" | |
composer global require "phpcompatibility/phpcompatibility-wp=*" | |
- name: phpcs --config-set | |
run: | | |
phpcs --config-set installed_paths /home/runner/.composer/vendor/wp-coding-standards/wpcs,/home/runner/.composer/vendor/phpcompatibility/php-compatibility,/home/runner/.composer/vendor/phpcompatibility/phpcompatibility-paragonie,/home/runner/.composer/vendor/phpcompatibility/phpcompatibility-wp | |
phpcs -i | |
- name: Run phpcs | |
run: phpcs -p -s -v ./ --standard=./phpcs.ruleset.xml --extensions=php |