diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml new file mode 100644 index 00000000..7df6b01c --- /dev/null +++ b/.github/workflows/general.yml @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: Copyright 2023 Move Agency Group B.V., Zwolle, The Netherlands +# SPDX-License-Identifier: CC0-1.0 + +name: General Tests +on: [push, pull_request, workflow_dispatch] + +jobs: + reuse: + uses: lunr-php/actions-templates/.github/workflows/reuse.yml@master diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 33b846cc..19d2fba2 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: uopz - - - 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 -l6 --configuration tests/phpstan.neon.dist + php-tests: + uses: lunr-php/actions-templates/.github/workflows/php-composer.yml@master + with: + phpstan-level: 6 + allow-style-failures: false + allow-phpstan-failures: false + phpcs-whitelist: 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"]' diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml deleted file mode 100644 index 7ac7d5e3..00000000 --- a/.github/workflows/reuse.yml +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2023 Move Agency Group B.V., Zwolle, The Netherlands -# SPDX-License-Identifier: CC0-1.0 - -name: REUSE Compliance Check -on: [push, pull_request] - -jobs: - reuse: - runs-on: ubuntu-latest - name: "REUSE Lint" - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: REUSE lint - uses: fsfe/reuse-action@v1 - with: - args: --include-submodules lint diff --git a/tests/phpstan.autoload.inc.php b/tests/phpstan.autoload.inc.php index 191d1069..b35fd357 100644 --- a/tests/phpstan.autoload.inc.php +++ b/tests/phpstan.autoload.inc.php @@ -14,22 +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 { - // 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'; + $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 d191a171..4e3cf7f3 100644 --- a/tests/test.bootstrap.inc.php +++ b/tests/test.bootstrap.inc.php @@ -12,26 +12,29 @@ $base = __DIR__ . '/..'; +// Define application config lookup path +$paths = [ + get_include_path(), + $base . '/src', +]; + set_include_path( - $base . '/src:' . - $base . '/config:' . - $base . '/system:' . - $base . '/tests/statics:' . - $base . '/tests/statics/Core:' . - get_include_path() + implode(':', $paths) ); 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 autoloader. - require_once $base . '/decomposer.autoload.inc.php'; + $autoload_file = $base . '/decomposer.autoload.inc.php'; } +require_once $autoload_file; + if (defined('TEST_STATICS') === FALSE) { define('TEST_STATICS', __DIR__ . '/statics');