Skip to content

Commit dad4b3b

Browse files
authored
Merge pull request #836 from Codeinwp/testing-improvements
GHA improvements
2 parents 40a7cba + 7c10de2 commit dad4b3b

File tree

3 files changed

+24
-55
lines changed

3 files changed

+24
-55
lines changed

.github/workflows/test-php.yml

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ concurrency:
88
cancel-in-progress: true
99
jobs:
1010
phplint:
11-
name: Phplint
11+
name: PHPCS on PHP 8.0
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Setup PHP version
@@ -17,62 +17,43 @@ jobs:
1717
php-version: '8.0'
1818
extensions: simplexml
1919
- name: Checkout source code
20-
uses: actions/checkout@v2
21-
- name: Get Composer Cache Directory
22-
id: composer-cache
23-
run: |
24-
echo "::set-output name=dir::$(composer config cache-files-dir)"
25-
- name: Setup Composer cache
26-
uses: actions/cache@v1
27-
with:
28-
path: ${{ steps.composer-cache.outputs.dir }}
29-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
30-
restore-keys: |
31-
${{ runner.os }}-composer-
32-
- name: Install composer
20+
uses: actions/checkout@v4
21+
- name: Install Composer dependencies
3322
run: composer install --prefer-dist --no-progress --no-suggest
3423
- name: Run PHPCS
35-
run: composer run lint
24+
run: composer phpcs
3625
phpunit:
37-
name: Phpunit
26+
name: PHPUnit tests on ${{ matrix.php-versions }}
3827
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
3932
services:
40-
mysql:
41-
image: mysql:5.7
33+
database:
34+
image: mysql:latest
4235
env:
36+
MYSQL_DATABASE: wordpress_tests
4337
MYSQL_ROOT_PASSWORD: root
4438
ports:
45-
- 3306/tcp
46-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
39+
- 3306:3306
4740
steps:
4841
- name: Setup PHP version
4942
uses: shivammathur/setup-php@v2
5043
with:
51-
php-version: '8.0'
44+
php-version: ${{ matrix.php-version }}
5245
extensions: simplexml, mysql
53-
tools: phpunit-polyfills
46+
tools: phpunit-polyfills:1.1
5447
- name: Checkout source code
55-
uses: actions/checkout@v2
48+
uses: actions/checkout@v4
5649
- name: Install WordPress Test Suite
57-
run: |
58-
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
59-
- name: Get Composer Cache Directory
60-
id: composer-cache
61-
run: |
62-
echo "::set-output name=dir::$(composer config cache-files-dir)"
63-
- name: Setup Composer cache
64-
uses: actions/cache@v1
65-
with:
66-
path: ${{ steps.composer-cache.outputs.dir }}
67-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
68-
restore-keys: |
69-
${{ runner.os }}-composer-
70-
- name: Install composer
50+
run: bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
51+
- name: Install Composer dependencies
7152
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
7253
- name: Run phpunit
7354
run: phpunit
7455
phpstan:
75-
name: PHPStan
56+
name: PHPStan on PHP 8.0
7657
runs-on: ubuntu-latest
7758
steps:
7859
- name: Setup PHP version
@@ -81,19 +62,8 @@ jobs:
8162
php-version: '8.0'
8263
extensions: simplexml, mysql
8364
- name: Checkout source code
84-
uses: actions/checkout@v2
85-
- name: Get Composer Cache Directory
86-
id: composer-cache
87-
run: |
88-
echo "::set-output name=dir::$(composer config cache-files-dir)"
89-
- name: Setup Composer cache
90-
uses: actions/cache@v1
91-
with:
92-
path: ${{ steps.composer-cache.outputs.dir }}
93-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
94-
restore-keys: |
95-
${{ runner.os }}-composer-
96-
- name: Install composer
65+
uses: actions/checkout@v4
66+
- name: Install Composer dependencies
9767
run: composer install --prefer-dist --no-progress --no-suggest
9868
- name: PHPStan Static Analysis
9969
run: composer phpstan

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@
4646
},
4747
"scripts": {
4848
"format": "phpcbf --standard=phpcs.xml --report-summary --report-source",
49-
"phpcs": "phpcs --standard=phpcs.xml --extensions=php -s",
49+
"phpcs": "phpcs --standard=phpcs.xml --extensions=php -s -d memory_limit=-1",
5050
"test": "[ -z \"$WP_TESTS_DIR\" ] || [ -z \"$WP_CORE_DIR\" ] && echo 'Error: Both WP_TESTS_DIR and WP_CORE_DIR must be defined.' && exit 1 || phpunit --configuration=phpunit.xml",
51-
"lint": "composer run-script phpcs",
52-
"phpstan": "phpstan analyse --memory-limit 2G",
51+
"phpstan": "phpstan analyse --memory-limit=-1",
5352
"install-wp-tests": "bash bin/install-wp-tests.sh wordpress_test root '' localhost latest"
5453
},
5554
"require": {

optimole-wp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function optml_deactivate() {
5050
}
5151

5252
/**
53-
* Shows a notice for sites running PHP less than 5.4.
53+
* Shows a notice for sites running PHP less than 7.4.
5454
*/
5555
function optml_php_notice() {
5656
?>

0 commit comments

Comments
 (0)