This workflow runs PHP_CodeSniffer. It does so by
executing the binary resolved via composer config bin-dir.
Simplest possible example:
name: Coding standards analysis PHP
on:
push:
pull_request:
jobs:
coding-standards-analysis-php:
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main| Name | Default | Description |
|---|---|---|
PHP_VERSION |
'8.2' |
PHP version with which the scripts are executed |
PHP_EXTENSIONS |
'' |
PHP extensions supported by shivammathur/setup-php to be installed or disabled |
COMPOSER_ARGS |
'--prefer-dist' |
Set of arguments passed to Composer |
PHPCS_ARGS |
'--report-full --report-checkstyle=./phpcs-report.xml' |
Set of arguments passed to PHP_CodeSniffer |
CS2PR_ARGS |
'--graceful-warnings ./phpcs-report.xml' |
Set of arguments passed to cs2pr |
| Name | Description |
|---|---|
COMPOSER_AUTH_JSON |
Authentication for privately hosted packages and repositories as a JSON formatted object |
ENV_VARS |
Additional environment variables as a JSON formatted object |
Example with configuration parameters:
name: Coding standards analysis PHP
on:
push:
pull_request:
jobs:
coding-standards-analysis-php:
uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main
secrets:
COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
ENV_VARS: >-
[{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
with:
PHPCS_ARGS: '--report=summary'Note: Coding standards analysis should only be performed with the highest supported PHP version. Use the Lint PHP workflow to check code compatibility with multiple PHP versions.
This workflow runs either Psalm or PHPStan, or both, based on the existence of a supported configuration file in your repository root folder.
It does so by executing the binary resolved via composer config bin-dir.
Supported configuration files:
| Tool | Files |
|---|---|
| Psalm | psalm.xml, psalm.xml.dist |
| PHPStan | phpstan.dist.neon, phpstan.neon, phpstan.neon.dist |
Simplest possible example:
name: Static code analysis PHP
on:
push:
pull_request:
jobs:
static-code-analysis-php:
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main| Name | Default | Description |
|---|---|---|
PHP_VERSION |
'8.2' |
PHP version with which the scripts are executed |
PHP_EXTENSIONS |
'' |
PHP extensions supported by shivammathur/setup-php to be installed or disabled |
COMPOSER_ARGS |
'--prefer-dist' |
Set of arguments passed to Composer |
PSALM_ARGS |
'--output-format=github --no-cache' |
Set of arguments passed to Psalm |
PHPSTAN_ARGS |
'--no-progress --memory-limit=1G' |
Set of arguments passed to PHPStan |
| Name | Description |
|---|---|
COMPOSER_AUTH_JSON |
Authentication for privately hosted packages and repositories as a JSON formatted object |
ENV_VARS |
Additional environment variables as a JSON formatted object |
Example with configuration parameters:
name: Static code analysis PHP
on:
push:
pull_request:
jobs:
static-code-analysis-php:
uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main
secrets:
COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
ENV_VARS: >-
[{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
with:
PSALM_ARGS: '--threads=3'Note: Static code analysis can only be performed with a specific PHP version and not in a PHP matrix, as it should always be tested with the highest PHP version in use. To check compatibility with multiple PHP versions, use the Lint PHP workflow.
This workflow runs PHPUnit. It does so by executing the binary resolved via
composer config bin-dir.
Simplest possible example:
name: Unit tests PHP
on:
push:
pull_request:
jobs:
tests-unit-php:
uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-php.yml@main| Name | Default | Description |
|---|---|---|
PHP_VERSION |
'8.2' |
PHP version with which the scripts are executed |
PHP_EXTENSIONS |
'' |
PHP extensions supported by shivammathur/setup-php to be installed or disabled |
COMPOSER_ARGS |
'--prefer-dist' |
Set of arguments passed to Composer |
PHPUNIT_ARGS |
'--coverage-text' |
Set of arguments passed to PHPUnit |
| Name | Description |
|---|---|
COMPOSER_AUTH_JSON |
Authentication for privately hosted packages and repositories as a JSON formatted object |
ENV_VARS |
Additional environment variables as a JSON formatted object |
Example with configuration parameters:
name: Unit tests PHP
on:
push:
pull_request:
jobs:
tests-unit-php:
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
uses: inpsyde/reusable-workflows/.github/workflows/tests-unit-php.yml@main
with:
PHP_VERSION: ${{ matrix.php }}
PHPUNIT_ARGS: '--coverage-text --debug'This workflow runs PHP Parallel Lint.
Simplest possible example:
name: Lint PHP
on:
push:
pull_request:
jobs:
lint-php:
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main| Name | Default | Description |
|---|---|---|
PHP_VERSION |
'8.2' |
PHP version with which the scripts are executed |
PHP_EXTENSIONS |
'' |
PHP extensions supported by shivammathur/setup-php to be installed or disabled |
COMPOSER_ARGS |
'--prefer-dist' |
Set of arguments passed to Composer |
LINT_ARGS |
'-e php --colors --show-deprecated .' |
Set of arguments passed to PHP Parallel Lint |
COMPOSER_DEPS_INSTALL |
false |
Whether or not to install Composer dependencies before linting |
| Name | Description |
|---|---|
COMPOSER_AUTH_JSON |
Authentication for privately hosted packages and repositories as a JSON formatted object |
ENV_VARS |
Additional environment variables as a JSON formatted object |
Example with configuration parameters:
name: Lint PHP
on:
push:
pull_request:
jobs:
lint-php:
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main
secrets:
COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
ENV_VARS: >-
[{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
with:
PHP_VERSION: '8.1'
LINT_ARGS: '. --exclude vendor'
COMPOSER_DEPS_INSTALL: trueExample with PHP_VERSION in matrix:
name: Lint PHP
on:
push:
pull_request:
jobs:
lint-php:
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main
with:
PHP_VERSION: ${{ matrix.php }}