Skip to content

Commit 2291867

Browse files
committed
Update PHP and PHPUnit versions, fix test workflow and improve build process
1 parent 0fd0d74 commit 2291867

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

.github/workflows/cs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install PHP
2727
uses: shivammathur/setup-php@v2
2828
with:
29-
php-version: '7.4'
29+
php-version: '8.0'
3030
tools: cs2pr
3131
coverage: none
3232

@@ -50,4 +50,4 @@ jobs:
5050
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
5151

5252
- name: Show PHPCS results in PR
53-
run: cs2pr --graceful-warnings ./phpcs-report.xml
53+
run: cs2pr --graceful-warnings ./phpcs-report.xml

.github/workflows/unit-tests.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ jobs:
3737
- php: '8.2'
3838
wp: 'latest'
3939
experimental: true
40-
- php: '8.0'
40+
- php: '8.2'
4141
wp: '6.3'
4242
experimental: true
43+
- php: '8.0'
44+
wp: '5.9'
45+
experimental: true
4346

4447
name: "PHP ${{ matrix.php }} - WP ${{ matrix.wp }}"
4548

@@ -68,23 +71,18 @@ jobs:
6871
uses: shivammathur/setup-php@v2
6972
with:
7073
php-version: ${{ matrix.php }}
71-
tools: phpunit-polyfills
74+
extensions: mysqli, mysql
7275
coverage: none
73-
# The PHP 5.6 and 7.0 images don't include mysql[i] by default.
74-
extensions: mysqli
75-
76-
- name: Set up WordPress
77-
run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}
7876

7977
# On WP 5.2, PHPUnit 5.x, 6.x and 7.x are supported.
8078
# On PHP >= 8.0, PHPUnit 7.5+ is needed, no matter what.
8179
- name: Determine supported PHPUnit version
8280
id: set_phpunit
8381
run: |
84-
if [[ "${{ matrix.php }}" > "7.4" ]]; then
85-
echo "PHPUNIT=8.5.*" >> $GITHUB_ENV
82+
if [[ "${{ matrix.php }}" > "8.0" ]]; then
83+
echo "PHPUNIT=9.*" >> $GITHUB_ENV
8684
else
87-
echo "PHPUNIT=5.7.*||6.*||7.5.*" >> $GITHUB_ENV
85+
echo "PHPUNIT=5.7.*||6.*||7.5.*||8.5.*" >> $GITHUB_ENV
8886
fi
8987
9088
- name: 'Composer: set up PHPUnit'
@@ -96,30 +94,32 @@ jobs:
9694
# @link https://github.com/marketplace/actions/install-composer-dependencies
9795
- name: Install Composer dependencies for PHP < 8.0
9896
if: ${{ matrix.php < 8.0 }}
99-
uses: "ramsey/composer-install@v3"
97+
uses: "ramsey/composer-install@v2"
10098

10199
# For the PHP 8.0 and above, we need to install with ignore platform reqs as not all dependencies allow it yet.
102100
- name: Install Composer dependencies for PHP >= 8.0
103101
if: ${{ matrix.php >= 8.0 }}
104-
uses: "ramsey/composer-install@v3"
102+
uses: "ramsey/composer-install@v2"
105103
with:
106104
composer-options: --ignore-platform-reqs
107105

108-
- name: 'Run Composer Update'
109-
run: |
110-
composer update --ignore-platform-reqs
106+
- name: Install Subversion
107+
run: sudo apt-get install subversion
108+
109+
- name: Set up WordPress
110+
run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}
111111

112112
- name: Tool versions
113113
run: |
114114
php --version
115115
composer --version
116-
phpunit --version
117-
which phpunit
116+
./vendor/bin/phpunit --version
117+
which ./vendor/bin/phpunit
118118
119119
- name: Run the unit tests - single site
120-
run: vendor/bin/phpunit
120+
run: ./vendor/bin/phpunit
121121

122122
- name: Run the unit tests - multisite
123-
run: vendor/bin/phpunit
124123
env:
125124
WP_MULTISITE: 1
125+
run: ./vendor/bin/phpunit

.github/workflows/zipitup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ jobs:
2929
- name: Create artifact
3030
uses: montudor/action-zip@v1
3131
with:
32-
args: zip -X -r build/knowledgebase.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml composer.* dev-helpers** build** wporg-assets** phpunit**
32+
args: zip -X -r build/${{ github.event.repository.name }}.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml *.neon composer.* package.json dev-helpers** build** wporg-assets** phpunit**
3333
- name: Upload artifact
3434
uses: actions/upload-artifact@v4
3535
with:
36-
name: knowledgebase
37-
path: build/knowledgebase.zip
36+
name: ${{ github.event.repository.name }}
37+
path: build/${{ github.event.repository.name }}.zip
3838
- name: Upload to release
3939
uses: JasonEtco/upload-to-release@master
4040
with:
41-
args: build/knowledgebase.zip application/zip
41+
args: build/${{ github.event.repository.name }}.zip application/zip
4242
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

phpunit/bootstrap.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?php
22
/**
3-
* PHPUnit bootstrap file for WebberZone Knowledge Base.
4-
*
5-
* This file sets up the testing environment for PHPUnit.
6-
*
7-
* @package WebberZone\Knowledge_Base
3+
* PHPUnit bootstrap file.
84
*/
95

10-
require_once dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/.composer/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
11-
126
$_tests_dir = getenv( 'WP_TESTS_DIR' );
137

148
// Check if we're installed in a src checkout.
@@ -34,5 +28,8 @@ function _manually_load_plugin() {
3428
}
3529
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
3630

31+
// Include the PHPUnit Polyfills autoloader.
32+
require dirname( __DIR__ ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
33+
3734
// Start up the WP testing environment.
3835
require $_tests_dir . '/includes/bootstrap.php';

phpunit/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ install_db() {
8181
}
8282

8383
install_wp_and_test_suite
84-
install_db
84+
install_db

0 commit comments

Comments
 (0)