11name : Unit Tests
22
33on :
4- # Run on all pushes and on all pull requests.
5- # Prevent the build from running when there are only irrelevant changes.
64 push :
75 paths-ignore :
86 - ' **.md'
119 paths-ignore :
1210 - ' **.md'
1311 - ' **.txt'
14- # Allow manually triggering the workflow.
1512 workflow_dispatch :
1613
1714jobs :
@@ -21,100 +18,72 @@ jobs:
2118 strategy :
2219 fail-fast : false
2320 matrix :
24- # Notes regarding supported versions in WP:
25- # Testing against stable PHP versions with WordPress 6.6+
2621 php : ['7.4', '8.1', '8.2', '8.3']
2722 wp : ['latest']
28- experimental : [false ]
23+ mysql : ['8.0' ]
2924
3025 include :
31- # Test against older supported WordPress version
3226 - php : ' 8.3'
3327 wp : ' 6.6'
34- # Experimental builds for upcoming PHP versions
35- - php : ' 8.5 '
28+ mysql : ' 8.0 '
29+ - php : ' 8.4 '
3630 wp : ' latest'
31+ mysql : ' 8.0'
3732 experimental : true
38- - php : ' 8.4 '
33+ - php : ' 8.5 '
3934 wp : ' latest'
35+ mysql : ' 8.0'
4036 experimental : true
4137
42- name : " PHP ${{ matrix.php }} - WP ${{ matrix.wp }}"
43-
38+ name : " PHP ${{ matrix.php }} - WP ${{ matrix.wp }} - MySQL ${{ matrix.mysql }}"
4439 continue-on-error : ${{ matrix.experimental == true }}
4540
46- services :
47- mysql :
48- # WP 5.4 is the first WP version which largely supports MySQL 8.0.
49- # See: https://core.trac.wordpress.org/ticket/49344
50- # During the setting up of these tests, it became clear that MySQL 8.0
51- # in combination with PHP < 7.4 is not properly/sufficiently supported
52- # within WP Core.
53- # See: https://core.trac.wordpress.org/ticket/52496
54- image : mysql:${{ ( matrix.wp == 5.3 && '5.6' ) || ( (matrix.wp < 5.4 || matrix.php < 7.4) && '5.7' ) || '8.0' }}
55- env :
56- MYSQL_ALLOW_EMPTY_PASSWORD : false
57- ports :
58- - 3306:3306
59- options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
60-
6141 steps :
6242 - name : Checkout code
6343 uses : actions/checkout@v4
6444
45+ - name : Setup MySQL
46+ uses : ankane/setup-mysql@v1
47+ with :
48+ mysql-version : ${{ matrix.mysql }}
49+
6550 - name : Install PHP
6651 uses : shivammathur/setup-php@v2
6752 with :
6853 php-version : ${{ matrix.php }}
69- extensions : mysqli, mysql
54+ extensions : mysqli
7055 coverage : none
7156
72- # On WP 5.2, PHPUnit 5.x, 6.x and 7.x are supported.
73- # On PHP >= 8.0, PHPUnit 7.5+ is needed, no matter what.
74- - name : Determine supported PHPUnit version
75- id : set_phpunit
57+ - name : Set PHPUnit version
7658 run : |
7759 if [[ "${{ matrix.php }}" > "8.0" ]]; then
7860 echo "PHPUNIT=9.*" >> $GITHUB_ENV
7961 else
8062 echo "PHPUNIT=5.7.*||6.*||7.5.*||8.5.*" >> $GITHUB_ENV
8163 fi
8264
83- - name : ' Composer: set up PHPUnit'
84- env :
85- PHPUNIT : ${{ env.PHPUNIT }}
86- run : composer require --no-update phpunit/phpunit:"${{ env.PHPUNIT }}"
65+ - name : Set up PHPUnit
66+ run : composer require --no-update phpunit/phpunit:"$PHPUNIT"
8767
88- # Install dependencies and handle caching in one go.
89- # @link https://github.com/marketplace/actions/install-composer-dependencies
90- - name : Install Composer dependencies for PHP < 8.0
68+ - name : Install dependencies for PHP < 8.0
9169 if : ${{ matrix.php < 8.0 }}
92- uses : " ramsey/composer-install@v2 "
70+ uses : ramsey/composer-install@v3
9371
94- # For the PHP 8.0 and above, we need to install with ignore platform reqs as not all dependencies allow it yet.
95- - name : Install Composer dependencies for PHP >= 8.0
72+ - name : Install dependencies for PHP >= 8.0
9673 if : ${{ matrix.php >= 8.0 }}
97- uses : " ramsey/composer-install@v2 "
74+ uses : ramsey/composer-install@v3
9875 with :
9976 composer-options : --ignore-platform-reqs
10077
101- - name : Install Subversion
102- run : sudo apt-get install subversion
103-
104- - name : Set up WordPress
105- run : phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}
106-
107- - name : Tool versions
78+ - name : Set up WordPress test environment
10879 run : |
109- php --version
110- composer --version
111- ./vendor/bin/phpunit --version
112- which ./vendor/bin/phpunit
80+ sudo apt-get install -y subversion
81+ bash phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}
11382
114- - name : Run the unit tests - single site
115- run : ./ vendor/bin/phpunit
83+ - name : Run tests ( single site)
84+ run : vendor/bin/phpunit
11685
117- - name : Run the unit tests - multisite
86+ - name : Run tests ( multisite)
11887 env :
11988 WP_MULTISITE : 1
120- run : ./ vendor/bin/phpunit
89+ run : vendor/bin/phpunit
0 commit comments