Skip to content

Commit

Permalink
Test PHP 8.2 and 8.3 with GitHub Actions
Browse files Browse the repository at this point in the history
Upgrade PHPUnit
  • Loading branch information
kylekatarnls committed Sep 16, 2023
1 parent f340c55 commit 6375925
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4']
php: ['8.2']
setup: ['stable']

name: PHP

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: pcov

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-${{ matrix.setup }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-${{ matrix.setup }}-coverage-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.setup }}-php-${{ matrix.php }}-
${{ runner.os }}-${{ matrix.setup }}-coverage-${{ matrix.php }}-
- name: Code Climate Test Reporter Preparation
run: |
Expand All @@ -48,12 +49,16 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer config version 1.9.0
${{ matrix.php >= 8 && 'composer require --no-update phpunit/phpunit:^8.5.26 phpunit/php-file-iterator:^2.0.5 --no-interaction;' || '' }}
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }}
${{ matrix.php >= 8 && matrix.php < 8.2 && 'composer require --no-update phpunit/phpunit:^8.5.33 phpunit/php-file-iterator:^2.0.5 --dev --no-interaction;' || '' }}
${{ matrix.php >= 8.2 && 'composer require --no-update phpunit/phpunit:^9.6.12 phpunit/php-file-iterator:^3.0.6 --dev --dev --no-interaction;' || '' }}
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress
- name: Run test suite
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Coverage
uses: codecov/codecov-action@v3

- name: Code Climate Test Reporter
if: ${{ env.CC_TEST_REPORTER_ID != '' }}
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
setup: ['lowest', 'stable', 'next']

name: PHP ${{ matrix.php }} - ${{ matrix.setup }}
Expand All @@ -40,8 +40,8 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer config version 1.9.0
${{ matrix.php >= 7.2 && matrix.php < 8 && matrix.setup == 'lowest' && 'composer require --no-update "phpunit/phpunit:^5.7.27||^6.5.14||^7.5.20" --no-interaction;' || '' }}
${{ matrix.php >= 8 && 'composer require --no-update phpunit/phpunit:^8.5.26 phpunit/php-file-iterator:^2.0.5 phug/phug:^1.9.0 --no-interaction;' || '' }}
${{ matrix.php >= 7.2 && matrix.php < 8 && matrix.setup == 'lowest' && 'composer require --no-update "phpunit/phpunit:^5.7.27||^6.5.14||^7.5.20" --dev --no-interaction;' || '' }}
${{ matrix.php >= 8 && 'composer require --no-update phpunit/phpunit:^8.5.33 phpunit/php-file-iterator:^2.0.5 --dev --no-interaction && composer require --no-update phug/phug:^1.9.0 --no-interaction;' || '' }}
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }} --no-interaction
env:
MULTI_TESTER_LABELS: install
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}
},
"require-dev": {
"phpunit/phpunit": ">=4.8.35 <9.0"
"phpunit/phpunit": ">=4.8.35 <10.0"
},
"bin": ["pug"],
"autoload": {
Expand Down
6 changes: 5 additions & 1 deletion example/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace Pug;

include_once __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
error_reporting(
PHP_VERSION >= 8.2 && !property_exists(Lexer::class, 'disallow')
? (E_ALL & ~E_DEPRECATED)
: E_ALL
);
ini_set('display_errors', 1);

class Application
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
<testsuite name="Facade">
<file>tests/features/facade.php</file>
</testsuite>
<testsuite name="Compiler">
<directory suffix=".php">tests/nodes</directory>
<directory suffix=".php">tests/compiler</directory>
</testsuite>
<testsuite name="Performance">
<directory suffix=".php">tests/performance</directory>
</testsuite>
Expand Down
5 changes: 4 additions & 1 deletion tests/features/issues.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ public function testIssue90()
data-b="$test"
data-c=\'#{$test}\'
data-d="#{$test}"
data-e="#${test}"
data-e="#' . (PHP_VERSION >= 8.2
? '{$test}' // Dropping ${test} support with PHP >= 8.2
: '${test}'
) . '"
) test', array(
'test' => 'foo',
))));
Expand Down
7 changes: 6 additions & 1 deletion tests/lib/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use JsPhpize\Lexer\Lexer;
use PHPUnit\Framework\TestCase;
use Pug\Pug;

Expand Down Expand Up @@ -106,7 +107,11 @@ function get_html_code($name)

function init_tests()
{
error_reporting(E_ALL);
error_reporting(
PHP_VERSION >= 8.2 && !property_exists(Lexer::class, 'disallow')
? (E_ALL & ~E_DEPRECATED)
: E_ALL
);
setup_autoload();
}

Expand Down

0 comments on commit 6375925

Please sign in to comment.