Skip to content

Tests: Restructure and increase coverage. #484

Tests: Restructure and increase coverage.

Tests: Restructure and increase coverage. #484

Workflow file for this run

# Based on https://github.com/wp-cli/scaffold-command/blob/f9bad3dd7224d5684d950d31c486df70905e386f/templates/plugin-github.mustache
# Thanks Josh https://github.com/Shelob9/wordpress-plugin/blob/main/.github/workflows/wordpress.yml
# Thanks https://github.com/shivammathur
# Thanks @desroj for idea to just use MySQL 8.0 with correct authentication method.
name: WordPress Tests
on:
push:
branches:
- trunk
- develop
pull_request:
branches:
- trunk
- develop
jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions:
["7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
name: PHP ${{ matrix.php-versions }} Test on ubantu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MySQL 8.0 with mysql_native_password
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.0"
my-cnf: |
bind_address=127.0.0.1
default-authentication-plugin=mysql_native_password
root-password: root
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: mysql, mysqli
tools: composer, wp-cli, phpunit-polyfills:1.0
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Composer install
run: composer install --optimize-autoloader --prefer-dist
- name: Install WP Tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest
- name: PHPUnit tests
run: |
echo "define('WP_TESTS_PHPUNIT_POLYFILLS_PATH', '$HOME/.composer/vendor/yoast/phpunit-polyfills');" >> /tmp/wordpress-tests-lib/wp-tests-config.php
phpunit --config=phpunit.xml