From ae16d73e16be8bc99e26d084074d3031fa2139e6 Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Wed, 31 Jan 2024 15:20:34 +0100 Subject: [PATCH 1/5] CI: Remove phpstan workaround Reviewed at https://reviews.lunr.nl/r/1108/ --- tests/phpstan.autoload.inc.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/phpstan.autoload.inc.php b/tests/phpstan.autoload.inc.php index 191d106..37365ac 100644 --- a/tests/phpstan.autoload.inc.php +++ b/tests/phpstan.autoload.inc.php @@ -18,14 +18,6 @@ } else { - // workaround for https://github.com/phpstan/phpstan/issues/7526 - function phpstan_issue_7526_workaround($class) - { - autoload_psr($class); - } - - spl_autoload_register('phpstan_issue_7526_workaround'); - // Load decomposer autoloade. require_once $base . '/decomposer.autoload.inc.php'; } From 8778433fb0cd683681882be2c5a50f2a1a5a766d Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Wed, 31 Jan 2024 15:28:47 +0100 Subject: [PATCH 2/5] CI: Adjust autoload include so it's no longer conditional Reviewed at https://reviews.lunr.nl/r/1109/ --- tests/phpstan.autoload.inc.php | 6 ++++-- tests/test.bootstrap.inc.php | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/phpstan.autoload.inc.php b/tests/phpstan.autoload.inc.php index 37365ac..b35fd35 100644 --- a/tests/phpstan.autoload.inc.php +++ b/tests/phpstan.autoload.inc.php @@ -14,14 +14,16 @@ if (file_exists($base . '/vendor/autoload.php') == TRUE) { // Load composer autoloader. - require_once $base . '/vendor/autoload.php'; + $autoload_file = $base . '/vendor/autoload.php'; } else { // Load decomposer autoloade. - require_once $base . '/decomposer.autoload.inc.php'; + $autoload_file = $base . '/decomposer.autoload.inc.php'; } +require_once $autoload_file; + // Define application config lookup path $paths = [ get_include_path(), diff --git a/tests/test.bootstrap.inc.php b/tests/test.bootstrap.inc.php index 9301397..c1d6ffb 100644 --- a/tests/test.bootstrap.inc.php +++ b/tests/test.bootstrap.inc.php @@ -23,14 +23,16 @@ if (file_exists($base . '/vendor/autoload.php') == TRUE) { // Load composer autoloader. - require_once $base . '/vendor/autoload.php'; + $autoload_file = $base . '/vendor/autoload.php'; } else { - // Load decomposer autoloade. - require_once $base . '/decomposer.autoload.inc.php'; + // Load decomposer autoloader. + $autoload_file = $base . '/decomposer.autoload.inc.php'; } +require_once $autoload_file; + define('REFLECTION_BUG_72194', (PHP_MAJOR_VERSION > 5)); if (defined('TEST_STATICS') === FALSE) From 5355cc96e8778733251ea0f52afed4bf1399f623 Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Wed, 31 Jan 2024 15:31:54 +0100 Subject: [PATCH 3/5] CI: Clean up include path construction for tests Reviewed at https://reviews.lunr.nl/r/1110/ --- tests/phpstan.autoload.inc.php | 1 - tests/test.bootstrap.inc.php | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/phpstan.autoload.inc.php b/tests/phpstan.autoload.inc.php index b35fd35..889f99c 100644 --- a/tests/phpstan.autoload.inc.php +++ b/tests/phpstan.autoload.inc.php @@ -27,7 +27,6 @@ // Define application config lookup path $paths = [ get_include_path(), - $base . '/config', $base . '/src', ]; diff --git a/tests/test.bootstrap.inc.php b/tests/test.bootstrap.inc.php index c1d6ffb..b371de8 100644 --- a/tests/test.bootstrap.inc.php +++ b/tests/test.bootstrap.inc.php @@ -12,12 +12,14 @@ $base = __DIR__ . '/..'; +// Define application config lookup path +$paths = [ + get_include_path(), + $base . '/src', +]; + set_include_path( - $base . '/src:' . - $base . '/config:' . - $base . '/tests:' . - $base . '/tests/statics:' . - get_include_path() + implode(':', $paths) ); if (file_exists($base . '/vendor/autoload.php') == TRUE) From 6c7f5371380e08e034bb6c5837144182ef8378e4 Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Wed, 31 Jan 2024 15:36:30 +0100 Subject: [PATCH 4/5] CI: Fix style in phan config file --- tests/phan.config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phan.config.php b/tests/phan.config.php index a2ae269..b0871d9 100644 --- a/tests/phan.config.php +++ b/tests/phan.config.php @@ -80,3 +80,5 @@ 'PhanTypeObjectUnsetDeclaredProperty', ], ]; + +?> From c9bdc7e7a1a7049e0fa0d2b809475bc73bea84dd Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Wed, 31 Jan 2024 15:37:59 +0100 Subject: [PATCH 5/5] CI: Use shared github action templates Reviewed at https://reviews.lunr.nl/r/1111/ --- .github/workflows/php-tests.yml | 95 ++++----------------------------- 1 file changed, 11 insertions(+), 84 deletions(-) diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 16029ce..39bf15d 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -3,89 +3,16 @@ # SPDX-License-Identifier: CC0-1.0 name: PHP Tests -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: - phpunit: - runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} - name: "PHP-${{ matrix.php-versions }}: PHPUnit" - strategy: - matrix: - php-versions: ['8.1'] - experimental: [false] - include: - - php-versions: 8.2 - experimental: true - - php-versions: 8.3 - experimental: true - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpunit:9.5.x - extensions: http, msgpack, gettext, mysqli, uopz, xdebug, uuid - - - name: Setup problem matchers for PHP - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - - name: Install dependencies - run: composer update - - - name: Run PHPunit - run: phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml - - - name: Collect code coverage - uses: codecov/codecov-action@v3 - with: - files: ./coverage.xml - - phpcs: - runs-on: ubuntu-latest - continue-on-error: false - name: "PHPCS" - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Codestyle checkout - uses: actions/checkout@v3 - with: - repository: 'lunr-php/lunr-coding-standard' - - # Relative path under $GITHUB_WORKSPACE to place the repository - path: 'codestyle' - - - name: Setup PHPCS - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: cs2pr, phpcs - - - name: Run PHPCS - run: phpcs -q --report=checkstyle src --standard=$GITHUB_WORKSPACE/codestyle/Lunr | cs2pr - - phpstan: - runs-on: ubuntu-latest - continue-on-error: false - name: "PHPStan" - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHPStan - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phpstan - extensions: uopz - - - name: Install dependencies - run: composer update - - - name: Run PHPStan - run: phpstan analyze src -l9 --configuration tests/phpstan.neon.dist + php-tests: + uses: lunr-php/actions-templates/.github/workflows/php-composer.yml@master + with: + phpstan-level: 9 + allow-style-failures: false + allow-phpstan-failures: false + phpcs-whitelist: tests/phan.config.php tests/phpstan.autoload.inc.php tests/test.bootstrap.inc.php + php-extensions: uopz + stable-php-versions: '["8.1"]' + experimental-php-versions: '["8.2","8.3"]'