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
182 changes: 182 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: 🔎 code quality

on:
pull_request:
push:
branches:
- main

jobs:
compute:
uses: ./.github/workflows/compute.yml

lint:
name: 'Lint PHP ${{ matrix.php }}'

needs: [ compute ]

strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.compute.outputs.os) }}
php: ${{ fromJson(needs.compute.outputs.php) }}

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-check-lint-${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-check-lint-
${{ runner.os }}-composer-check-
${{ runner.os }}-composer-

- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: xdebug, mbstring, posix
tools: composer:v2

- name: Environment Check
run: |
php -v
php -m
composer --version

- name: Validate composer.json
run: composer validate

- name: Composer install
run: composer update --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Lint PHP
run: php vendor/bin/parallel-lint --exclude .git --exclude var --exclude vendor .


test:
name: PHPUnit tests ${{ matrix.php }}

needs: [ compute, lint ]

strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.compute.outputs.php) }}

env:
php: ${{ matrix.php }}

runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-check-analyse-${{ env.php }}-${{ matrix.typo3 }}
restore-keys: |
${{ runner.os }}-composer-check-analyse-
${{ runner.os }}-composer-check-
${{ runner.os }}-composer-

- name: Set up PHP Version ${{ env.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php }}
extensions: xdebug, mbstring, posix
tools: composer:v2

- name: Environment Check
run: |
php -v
php -m
composer --version

- name: Composer install
run: composer update --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Run PHPStan
run: php vendor/bin/phpunit tests/Unit

fix:
name: PHP CS Fixer

needs: [ compute, lint ]

env:
php: ${{ fromJson(needs.compute.outputs.php-single) }}

runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Store Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-check-fix-${{ env.php }}
restore-keys: |
${{ runner.os }}-composer-check-fix-
${{ runner.os }}-composer-check-
${{ runner.os }}-composer-

- name: Set up PHP Version ${{ env.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php }}
extensions: xdebug, mbstring, posix
tools: composer:v2

- name: Environment Check
run: |
php -v
php -m
composer --version

- name: Composer install
run: composer update --no-interaction

- name: Save composer cache
uses: actions/cache/save@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}

- name: Run PHP CS Fixer
run: php vendor/bin/php-cs-fixer check --diff --no-interaction --show-progress=none
73 changes: 73 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: ✏️ matrix

env:
OS: |
"ubuntu-latest"
PHP: |
"7.4"
"8.0"
"8.1"
"8.2"
"8.4"
"8.3"
EXCLUDE: |
{
}
on:
workflow_call:
outputs:
os:
value: ${{ jobs.compute.outputs.os }}
os-single:
value: ${{ jobs.compute.outputs.os-single }}
php:
value: ${{ jobs.compute.outputs.php }}
php-single:
value: ${{ jobs.compute.outputs.php-single }}
exclude:
value: ${{ jobs.compute.outputs.exclude }}

jobs:
compute:
name: Compute outputs

outputs:
os: ${{ steps.build-matrix.outputs.os }}
os-single: ${{ steps.build-matrix.outputs.os-single }}
php: ${{ steps.build-matrix.outputs.php }}
php-single: ${{ steps.build-matrix.outputs.php-single }}
exclude: ${{ steps.build-matrix.outputs.exclude }}

runs-on: ubuntu-latest

steps:
- name: Build matrix
id: build-matrix
run: |
echo ""
echo "::group::OS"
os=$(echo $OS | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "os = $os"
echo "os=$os" >> "$GITHUB_OUTPUT"
echo "os-single = $(echo $os | jq '.'[0])"
echo "os-single=$(echo $os | jq '.'[0])" >> "$GITHUB_OUTPUT"
echo "::endgroup::"

echo ""
echo "::group::PHP"
php=$(echo $PHP | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
echo "php = $php"
echo "php=$php" >> "$GITHUB_OUTPUT"
echo "php-single = $(echo $php | jq '.'[-1])"
echo "php-single=$(echo $php | jq '.'[-1])" >> "$GITHUB_OUTPUT"
echo "::endgroup::"

echo ""
echo "::group::EXCLUDE"
exclude=$(cat <<EOF | jq -nc -f /dev/stdin | jq -c 'to_entries | map_values(.value)'
$EXCLUDE
EOF
)
echo "exclude = $exclude"
echo "exclude=$exclude)" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/vendor
/composer.lock
/.php_cs.cache
/.php-cs-fixer.cache
64 changes: 64 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src/');

$configFinder = PhpCsFixer\Finder::create()
->in(__DIR__)
->depth('0');

$finder->append($configFinder);

// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailfing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return (new PhpCsFixer\Config)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@DoctrineAnnotation' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'no_blank_lines_after_phpdoc' => true,
'array_syntax' => ['syntax' => 'short'],
'whitespace_after_comma_in_array' => true,
'function_typehint_space' => true,
'no_alias_functions' => true,
'lowercase_cast' => true,
'no_leading_namespace_whitespace' => true,
'native_function_casing' => true,
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true,
'no_empty_phpdoc' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_trim' => true,
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'cast_spaces' => ['space' => 'none'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
])
->setFinder($finder);
Loading
Loading