v5.0-alpha #7 #5
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: Run PHPUnit | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
branches: [ develop ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
WP_TESTS_DIR: ${{ github.workspace }}/wordpress-develop/tests/phpunit | |
DB_NAME: wordpress_test | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: ${{ env.DB_NAME }} | |
ports: | |
- 3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@2.26.0 | |
with: | |
php-version: '8.2.11' # Adjust to your project's PHP version | |
extensions: mbstring, dom, fileinfo, mysql # Adjust to your project's needs | |
coverage: xdebug | |
- name: Install PHPUnit | |
run: composer global require --dev phpunit/phpunit:^9.0 | |
- name: Setup WordPress Tests | |
run: | | |
git clone git://develop.git.wordpress.org/ wordpress-develop | |
cd wordpress-develop | |
cp wp-tests-config-sample.php wp-tests-config.php | |
sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php | |
sed -i "s/yourusernamehere/root/" wp-tests-config.php | |
sed -i "s/yourpasswordhere/root/" wp-tests-config.php | |
sed -i "s|localhost|127.0.0.1:3306|" wp-tests-config.php | |
composer update -W | |
- name: Create MySQL Database | |
run: | | |
sudo systemctl start mysql | |
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};' | |
- name: Run tests | |
run: ~/.composer/vendor/bin/phpunit -c ./config/phpunit.xml |