Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 52 additions & 21 deletions .github/workflows/php-qa.yml
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' ]
Comment thread
Chrico marked this conversation as resolved.
with:
PHP_VERSION: ${{ matrix.php }}
PSALM_ARGS: --output-format=github --no-suggestions --no-cache --no-diff --find-unused-psalm-suppress
120 changes: 66 additions & 54 deletions .github/workflows/php-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,72 @@
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-update
composer require "psr/container:${{ matrix.container-versions }}" --no-update
composer config --no-plugins allow-plugins.roots/wordpress-core-installer false

- 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
### Composer template
composer.phar
composer.lock
/vendor/
vendor/

# PHPUnit
.phpunit.result.cache
phpunit.xml
coverage/

# tmp files
tmp/
Expand Down
48 changes: 24 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,30 @@
"email": "hello@inpsyde.com",
"homepage": "https://inpsyde.com/",
"role": "Company"
},
{
"name": "Christian Leucht",
"email": "c.leucht@inpsyde.com",
"role": "Developer"
},
}
],
"repositories": [
{
"name": "Giuseppe Mazzapica",
"email": "g.mazzapica@inpsyde.com",
"role": "Developer"
"type": "composer",
"url": "https://github.com/ghraw/inpsyde/wp-stubs/main",
"only": [
"inpsyde/wp-stubs-versions"
]
}
],
"require": {
"php": ">=7.2",
"php": ">=7.4 <8.4",
"ext-json": "*",
"psr/container": "^1.1.0 || ^2"
},
"require-dev": {
"brain/monkey": "^2.6.1",
"inpsyde/php-coding-standards": "^1",
"mikey179/vfsstream": "^v1.6.10",
"phpunit/phpunit": "^8.5.21 || ^9.6.7",
"vimeo/psalm": "^4.13.1",
"php-stubs/wordpress-stubs": ">=5.8@stable",
"johnpbloch/wordpress-core": ">=5.8"
"inpsyde/php-coding-standards": "^2@dev",
"inpsyde/wp-stubs-versions": "dev-latest",
"roots/wordpress-no-content": "@dev",
"mikey179/vfsstream": "^v1.6.11",
"phpunit/phpunit": "^9.6.19",
"vimeo/psalm": "^5.24.0"
},
"extra": {
"branch-alias": {
Expand All @@ -55,19 +54,20 @@
"prefer-stable": true,
"scripts": {
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
"psalm": "@php ./vendor/vimeo/psalm/psalm",
"psalm": "@php ./vendor/vimeo/psalm/psalm --no-suggestions --report-show-info=false --find-unused-psalm-suppress --no-diff --no-cache --no-file-cache --output-format=compact",
"tests": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage",
"tests:coverage": "@php ./vendor/phpunit/phpunit/phpunit",
"qa": [
"@tests:no-cov",
"@cs",
"@psalm"
],
"tests": "@php ./vendor/phpunit/phpunit/phpunit",
"tests:no-cov": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
"@psalm",
"@tests"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/package-versions-deprecated": true
"composer/*": true,
"inpsyde/*": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
35 changes: 31 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
<?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>
<rule ref="Squiz.PHP.Eval">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
</ruleset>
Loading