-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- PHPCS was not checked due to wrong configuration. Fix config (to latest Inpsyde CS) and the fix code - Use typed properties when possible - Use doc bloc consistently, delete unnecessary comments - Update dependencies and GHA workflow (no need to support PHPUnit 8) - Added Package::STATUS_BOOTING constant to alias Package::STATUS_MODULES_ADDED for clarity
- Loading branch information
Showing
34 changed files
with
916 additions
and
966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,60 @@ | ||
name: Quality assurance PHP | ||
|
||
on: ['pull_request', 'push', 'workflow_dispatch'] | ||
on: | ||
push: | ||
paths: | ||
- '**workflows/php-qa.yml' | ||
- '**.php' | ||
- '**phpcs.xml.dist' | ||
- '**psalm.xml' | ||
- '**composer.json' | ||
pull_request: | ||
paths: | ||
- '**workflows/php-qa.yml' | ||
- '**.php' | ||
- '**phpcs.xml.dist' | ||
- '**psalm.xml' | ||
- '**composer.json' | ||
workflow_dispatch: | ||
inputs: | ||
jobs: | ||
required: true | ||
type: choice | ||
default: 'Run all' | ||
description: 'Choose jobs to run' | ||
options: | ||
- 'Run all' | ||
- 'Run PHPCS only' | ||
- 'Run Psalm only' | ||
- 'Run lint only' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint-php: | ||
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip lint')) }} | ||
strategy: | ||
matrix: | ||
php: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] | ||
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main | ||
with: | ||
PHP_VERSION: ${{ matrix.php }} | ||
lint: | ||
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run lint only')) }} | ||
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main | ||
strategy: | ||
matrix: | ||
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] | ||
with: | ||
PHP_VERSION: ${{ matrix.php }} | ||
LINT_ARGS: '-e php --colors --show-deprecated ./src' | ||
|
||
coding-standards-analysis-php: | ||
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip cs')) }} | ||
needs: lint-php | ||
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main | ||
with: | ||
PHPCS_ARGS: '--report=summary' | ||
coding-standards-analysis: | ||
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run PHPCS only')) }} | ||
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main | ||
with: | ||
PHP_VERSION: '8.3' | ||
|
||
static-analysis-php: | ||
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip sa')) }} | ||
needs: lint-php | ||
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main | ||
static-code-analysis: | ||
if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run Psalm only')) }} | ||
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main | ||
strategy: | ||
matrix: | ||
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] | ||
with: | ||
PHP_VERSION: ${{ matrix.php }} | ||
PSALM_ARGS: --output-format=github --no-suggestions --no-cache --no-diff --find-unused-psalm-suppress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,71 @@ | ||
name: PHP unit tests | ||
|
||
on: ['pull_request', 'push', 'workflow_dispatch'] | ||
on: | ||
push: | ||
paths: | ||
- '**workflows/php-unit-tests.yml' | ||
- '**.php' | ||
- '**phpunit.xml.dist' | ||
- '**composer.json' | ||
pull_request: | ||
paths: | ||
- '**workflows/php-unit-tests.yml' | ||
- '**.php' | ||
- '**phpunit.xml.dist' | ||
- '**composer.json' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests-unit-php: | ||
runs-on: ubuntu-latest | ||
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip tests')) }} | ||
|
||
env: | ||
USE_COVERAGE: 'no' | ||
|
||
strategy: | ||
matrix: | ||
php-versions: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ] | ||
dependency-versions: [ 'lowest', 'highest' ] | ||
container-versions: [ '^1.1.0', '^2' ] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use coverage? | ||
if: ${{ (matrix.php-versions == '8.0') && (matrix.dependency-versions == 'highest') && (matrix.container-versions == '^2') }} | ||
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On | ||
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }} | ||
|
||
- name: Setup dependencies for PSR-11 target version | ||
run: | | ||
composer remove inpsyde/php-coding-standards inpsyde/wp-stubs-versions vimeo/psalm --dev --no-install | ||
composer require "psr/container:${{ matrix.container-versions }}" --no-install | ||
- name: Install Composer dependencies | ||
uses: ramsey/composer-install@v2 | ||
with: | ||
dependency-versions: ${{ matrix.dependency-versions }} | ||
|
||
- name: Run unit tests | ||
run: | | ||
./vendor/bin/phpunit --atleast-version 9 && ./vendor/bin/phpunit --migrate-configuration || echo 'Config does not need updates.' | ||
./vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-clover coverage.xml') || '--no-coverage' }} | ||
- name: Update coverage | ||
if: ${{ env.USE_COVERAGE == 'yes' }} | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml | ||
flags: unittests | ||
verbose: true | ||
tests-unit-php: | ||
runs-on: ubuntu-latest | ||
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.event.head_commit.message, 'skip tests')) }} | ||
|
||
env: | ||
USE_COVERAGE: 'no' | ||
|
||
strategy: | ||
matrix: | ||
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] | ||
dependency-versions: [ 'lowest', 'highest' ] | ||
container-versions: [ '^1.1.0', '^2' ] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use coverage? | ||
if: ${{ (matrix.php-versions == '8.2') && (matrix.dependency-versions == 'highest') && (matrix.container-versions == '^2') }} | ||
run: echo "USE_COVERAGE=yes" >> $GITHUB_ENV | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On | ||
coverage: ${{ ((env.USE_COVERAGE == 'yes') && 'xdebug') || 'none' }} | ||
|
||
- name: Setup dependencies for PSR-11 target version | ||
run: | | ||
composer remove inpsyde/php-coding-standards inpsyde/wp-stubs-versions vimeo/psalm --dev --no-install | ||
composer require "psr/container:${{ matrix.container-versions }}" --no-install | ||
- name: Install Composer dependencies | ||
uses: ramsey/composer-install@v3 | ||
with: | ||
dependency-versions: ${{ matrix.dependency-versions }} | ||
|
||
- name: Run unit tests | ||
run: /vendor/bin/phpunit ${{ ((env.USE_COVERAGE == 'yes') && '--coverage-clover coverage.xml') || '--no-coverage' }} | ||
|
||
- name: Update coverage | ||
if: ${{ env.USE_COVERAGE == 'yes' }} | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.xml | ||
flags: unittests | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
<?xml version="1.0"?> | ||
<ruleset> | ||
<file>./src/</file> | ||
<file>./tests/</file> | ||
<file>./src</file> | ||
<file>./tests</file> | ||
|
||
<arg value="sp"/> | ||
<arg name="colors"/> | ||
<config name="testVersion" value="7.2-"/> | ||
<config name="testVersion" value="7.4-"/> | ||
<config name="ignore_warnings_on_exit" value="1"/> | ||
|
||
<rule ref="Inpsyde"> | ||
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" /> | ||
</rule> | ||
|
||
<rule ref="Inpsyde.CodeQuality.Psr4"> | ||
<properties> | ||
<property | ||
name="psr4" | ||
type="array" | ||
value="Inpsyde\Modularity=>src,Inpsyde\Modularity\Tests=>tests/src,Inpsyde\Modularity\Tests\Unit=>tests/unit"/> | ||
value=" | ||
Inpsyde\Modularity=>src, | ||
Inpsyde\Modularity\Tests=>tests/src, | ||
Inpsyde\Modularity\Tests\Unit=>tests/unit" | ||
/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Inpsyde.CodeQuality.FunctionLength"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
</rule> | ||
<rule ref="Inpsyde.CodeQuality.ForbiddenPublicProperty"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
</rule> | ||
<rule ref="WordPress.PHP.DevelopmentFunctions"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
</rule> | ||
<rule ref="WordPress.PHP.DiscouragedPHPFunctions"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
</rule> | ||
<rule ref="WordPress.Security.EscapeOutput"> | ||
<exclude-pattern>*/tests/*</exclude-pattern> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd" | ||
bootstrap="./tests/boot.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertDeprecationsToExceptions="false" | ||
backupGlobals="false" | ||
stopOnFailure="false"> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<?xml version="1.0"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="./tests/boot.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertDeprecationsToExceptions="false" | ||
backupGlobals="false" | ||
stopOnFailure="false"> | ||
|
||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
<exclude> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</include> | ||
<exclude> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
<report> | ||
<html outputDirectory="coverage"/> | ||
</report> | ||
</coverage> | ||
|
||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/unit/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging> | ||
<log type="coverage-html" target="tmp"/> | ||
</logging> | ||
|
||
</phpunit> |
Oops, something went wrong.