Skip to content

Commit

Permalink
Merge pull request #836 from Codeinwp/testing-improvements
Browse files Browse the repository at this point in the history
GHA improvements
  • Loading branch information
selul authored Sep 24, 2024
2 parents 40a7cba + 7c10de2 commit dad4b3b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 55 deletions.
72 changes: 21 additions & 51 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
cancel-in-progress: true
jobs:
phplint:
name: Phplint
name: PHPCS on PHP 8.0
runs-on: ubuntu-latest
steps:
- name: Setup PHP version
Expand All @@ -17,62 +17,43 @@ jobs:
php-version: '8.0'
extensions: simplexml
- name: Checkout source code
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
uses: actions/checkout@v4
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run PHPCS
run: composer run lint
run: composer phpcs
phpunit:
name: Phpunit
name: PHPUnit tests on ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
services:
mysql:
image: mysql:5.7
database:
image: mysql:latest
env:
MYSQL_DATABASE: wordpress_tests
MYSQL_ROOT_PASSWORD: root
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
- 3306:3306
steps:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: ${{ matrix.php-version }}
extensions: simplexml, mysql
tools: phpunit-polyfills
tools: phpunit-polyfills:1.1
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install WordPress Test Suite
run: |
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
run: bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
- name: Run phpunit
run: phpunit
phpstan:
name: PHPStan
name: PHPStan on PHP 8.0
runs-on: ubuntu-latest
steps:
- name: Setup PHP version
Expand All @@ -81,19 +62,8 @@ jobs:
php-version: '8.0'
extensions: simplexml, mysql
- name: Checkout source code
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
uses: actions/checkout@v4
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: PHPStan Static Analysis
run: composer phpstan
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
},
"scripts": {
"format": "phpcbf --standard=phpcs.xml --report-summary --report-source",
"phpcs": "phpcs --standard=phpcs.xml --extensions=php -s",
"phpcs": "phpcs --standard=phpcs.xml --extensions=php -s -d memory_limit=-1",
"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",
"lint": "composer run-script phpcs",
"phpstan": "phpstan analyse --memory-limit 2G",
"phpstan": "phpstan analyse --memory-limit=-1",
"install-wp-tests": "bash bin/install-wp-tests.sh wordpress_test root '' localhost latest"
},
"require": {
Expand Down
2 changes: 1 addition & 1 deletion optimole-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function optml_deactivate() {
}

/**
* Shows a notice for sites running PHP less than 5.4.
* Shows a notice for sites running PHP less than 7.4.
*/
function optml_php_notice() {
?>
Expand Down

0 comments on commit dad4b3b

Please sign in to comment.