From 6375925f46c3fc9c2817a7e9798a7ff13e505e34 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Sat, 16 Sep 2023 23:14:32 +0200 Subject: [PATCH] Test PHP 8.2 and 8.3 with GitHub Actions Upgrade PHPUnit --- .github/workflows/coverage.yml | 19 ++++++++++++------- .github/workflows/tests.yml | 6 +++--- composer.json | 2 +- example/bootstrap.php | 6 +++++- phpunit.xml | 4 ---- tests/features/issues.php | 5 ++++- tests/lib/bootstrap.php | 7 ++++++- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index cc7afff2..836d40ee 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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: | @@ -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: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef22cb4a..4e833b04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 }} @@ -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 diff --git a/composer.json b/composer.json index f7556ce4..c513d1fa 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ } }, "require-dev": { - "phpunit/phpunit": ">=4.8.35 <9.0" + "phpunit/phpunit": ">=4.8.35 <10.0" }, "bin": ["pug"], "autoload": { diff --git a/example/bootstrap.php b/example/bootstrap.php index 9a0b4a23..a2277d6f 100644 --- a/example/bootstrap.php +++ b/example/bootstrap.php @@ -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 diff --git a/phpunit.xml b/phpunit.xml index 16d4ec04..4c36435c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -29,10 +29,6 @@ tests/features/facade.php - - tests/nodes - tests/compiler - tests/performance diff --git a/tests/features/issues.php b/tests/features/issues.php index 18ad87a5..99960816 100644 --- a/tests/features/issues.php +++ b/tests/features/issues.php @@ -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', )))); diff --git a/tests/lib/bootstrap.php b/tests/lib/bootstrap.php index de08cc7f..cbb1a376 100644 --- a/tests/lib/bootstrap.php +++ b/tests/lib/bootstrap.php @@ -1,5 +1,6 @@ = 8.2 && !property_exists(Lexer::class, 'disallow') + ? (E_ALL & ~E_DEPRECATED) + : E_ALL + ); setup_autoload(); }