Skip to content

Commit

Permalink
Update unit-tests.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Jan 11, 2025
1 parent 863c9b9 commit 19c6c87
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,53 +50,37 @@ jobs:

services:
mysql:
image: mysql:5.7
# WP 5.4 is the first WP version which largely supports MySQL 8.0.
# See: https://core.trac.wordpress.org/ticket/49344
# During the setting up of these tests, it became clear that MySQL 8.0
# in combination with PHP < 7.4 is not properly/sufficiently supported
# within WP Core.
# See: https://core.trac.wordpress.org/ticket/52496
image: mysql:${{ ( matrix.wp == 5.3 && '5.6' ) || ( (matrix.wp < 5.4 || matrix.php < 7.4) && '5.7' ) || '8.0' }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Subversion
run: sudo apt-get update && sudo apt-get install -y subversion

- name: Setup PHP
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mysql, mysqli
coverage: none
tools: composer, phpunit

- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Remove composer.lock
run: rm -f composer.lock
# The PHP 5.6 and 7.0 images don't include mysql[i] by default.
extensions: mysqli

- name: Install dependencies
run: |
composer install --no-interaction --prefer-dist --no-progress
- name: Install WordPress Test Suite
env:
WP_VERSION: ${{ matrix.wp }}
run: |
bash phpunit/install.sh wordpress_test root root localhost ${{ matrix.wp }}
- name: Set up WordPress
run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}

# On WP 5.2, PHPUnit 5.x, 6.x and 7.x are supported.
# On PHP >= 8.0, PHPUnit 7.5+ is needed, no matter what.
- name: Determine supported PHPUnit version
id: set_phpunit
run: |
Expand Down Expand Up @@ -135,9 +119,7 @@ jobs:
phpunit --version
which phpunit
- name: Run PHPUnit
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib
- name: Run the unit tests - single site
run: vendor/bin/phpunit

- name: Run the unit tests - multisite
Expand Down

0 comments on commit 19c6c87

Please sign in to comment.