Skip to content

Commit 066a2b6

Browse files
committed
Restructure ci workflows
1 parent 3aa1fa0 commit 066a2b6

9 files changed

Lines changed: 326 additions & 128 deletions

File tree

.github/workflows/check.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: 🔎 code quality
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
compute:
11+
uses: ./.github/workflows/compute.yml
12+
13+
lint:
14+
name: 'Lint PHP ${{ matrix.php }}'
15+
16+
needs: [ compute ]
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: ${{ fromJson(needs.compute.outputs.os) }}
22+
php: ${{ fromJson(needs.compute.outputs.php) }}
23+
24+
runs-on: ${{ matrix.os }}
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Store Composer cache directory
31+
id: composer-cache
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
33+
34+
- uses: actions/cache/restore@v4
35+
id: restore-composer-cache
36+
with:
37+
path: ${{ steps.composer-cache.outputs.dir }}
38+
key: ${{ runner.os }}-composer-check-lint-${{ matrix.php }}
39+
restore-keys: |
40+
${{ runner.os }}-composer-check-lint-
41+
${{ runner.os }}-composer-check-
42+
${{ runner.os }}-composer-
43+
44+
- name: Set up PHP Version ${{ matrix.php }}
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php }}
48+
extensions: xdebug, mbstring, posix
49+
tools: composer:v2
50+
51+
- name: Environment Check
52+
run: |
53+
php -v
54+
php -m
55+
composer --version
56+
57+
- name: Validate composer.json
58+
run: composer validate
59+
60+
- name: Composer install
61+
run: composer update --no-interaction
62+
63+
- name: Save composer cache
64+
uses: actions/cache/save@v4
65+
with:
66+
path: ${{ steps.composer-cache.outputs.dir }}
67+
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}
68+
69+
- name: Lint PHP
70+
run: php vendor/bin/parallel-lint --exclude .git --exclude var --exclude vendor .
71+
72+
73+
test:
74+
name: PHPUnit tests ${{ matrix.php }}
75+
76+
needs: [ compute, lint ]
77+
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
php: ${{ fromJson(needs.compute.outputs.php) }}
82+
83+
env:
84+
php: ${{ matrix.php }}
85+
86+
runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}
87+
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
92+
- name: Store Composer cache directory
93+
id: composer-cache
94+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
95+
96+
- uses: actions/cache/restore@v4
97+
id: restore-composer-cache
98+
with:
99+
path: ${{ steps.composer-cache.outputs.dir }}
100+
key: ${{ runner.os }}-composer-check-analyse-${{ env.php }}-${{ matrix.typo3 }}
101+
restore-keys: |
102+
${{ runner.os }}-composer-check-analyse-
103+
${{ runner.os }}-composer-check-
104+
${{ runner.os }}-composer-
105+
106+
- name: Set up PHP Version ${{ env.php }}
107+
uses: shivammathur/setup-php@v2
108+
with:
109+
php-version: ${{ env.php }}
110+
extensions: xdebug, mbstring, posix
111+
tools: composer:v2
112+
113+
- name: Environment Check
114+
run: |
115+
php -v
116+
php -m
117+
composer --version
118+
119+
- name: Composer install
120+
run: composer update --no-interaction
121+
122+
- name: Save composer cache
123+
uses: actions/cache/save@v4
124+
with:
125+
path: ${{ steps.composer-cache.outputs.dir }}
126+
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}
127+
128+
- name: Run PHPStan
129+
run: php vendor/bin/phpunit test/Unit
130+
131+
fix:
132+
name: PHP CS Fixer
133+
134+
needs: [ compute, lint ]
135+
136+
env:
137+
php: ${{ fromJson(needs.compute.outputs.php-single) }}
138+
139+
runs-on: ${{ fromJson(needs.compute.outputs.os-single) }}
140+
141+
steps:
142+
- name: Checkout
143+
uses: actions/checkout@v4
144+
145+
- name: Store Composer cache directory
146+
id: composer-cache
147+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
148+
149+
- uses: actions/cache/restore@v4
150+
id: restore-composer-cache
151+
with:
152+
path: ${{ steps.composer-cache.outputs.dir }}
153+
key: ${{ runner.os }}-composer-check-fix-${{ env.php }}
154+
restore-keys: |
155+
${{ runner.os }}-composer-check-fix-
156+
${{ runner.os }}-composer-check-
157+
${{ runner.os }}-composer-
158+
159+
- name: Set up PHP Version ${{ env.php }}
160+
uses: shivammathur/setup-php@v2
161+
with:
162+
php-version: ${{ env.php }}
163+
extensions: xdebug, mbstring, posix
164+
tools: composer:v2
165+
166+
- name: Environment Check
167+
run: |
168+
php -v
169+
php -m
170+
composer --version
171+
172+
- name: Composer install
173+
run: composer update --no-interaction
174+
175+
- name: Save composer cache
176+
uses: actions/cache/save@v4
177+
with:
178+
path: ${{ steps.composer-cache.outputs.dir }}
179+
key: ${{ steps.restore-composer-cache.outputs.cache-primary-key }}
180+
181+
- name: Run PHP CS Fixer
182+
run: php vendor/bin/php-cs-fixer check --diff --no-interaction --show-progress=none

.github/workflows/ci.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/compute.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: ✏️ matrix
2+
3+
env:
4+
OS: |
5+
"ubuntu-latest"
6+
PHP: |
7+
"7.4"
8+
"8.0"
9+
"8.1"
10+
"8.2"
11+
"8.4"
12+
"8.3"
13+
EXCLUDE: |
14+
{
15+
}
16+
on:
17+
workflow_call:
18+
outputs:
19+
os:
20+
value: ${{ jobs.compute.outputs.os }}
21+
os-single:
22+
value: ${{ jobs.compute.outputs.os-single }}
23+
php:
24+
value: ${{ jobs.compute.outputs.php }}
25+
php-single:
26+
value: ${{ jobs.compute.outputs.php-single }}
27+
exclude:
28+
value: ${{ jobs.compute.outputs.exclude }}
29+
30+
jobs:
31+
compute:
32+
name: Compute outputs
33+
34+
outputs:
35+
os: ${{ steps.build-matrix.outputs.os }}
36+
os-single: ${{ steps.build-matrix.outputs.os-single }}
37+
php: ${{ steps.build-matrix.outputs.php }}
38+
php-single: ${{ steps.build-matrix.outputs.php-single }}
39+
exclude: ${{ steps.build-matrix.outputs.exclude }}
40+
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Build matrix
45+
id: build-matrix
46+
run: |
47+
echo ""
48+
echo "::group::OS"
49+
os=$(echo $OS | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
50+
echo "os = $os"
51+
echo "os=$os" >> "$GITHUB_OUTPUT"
52+
echo "os-single = $(echo $os | jq '.'[0])"
53+
echo "os-single=$(echo $os | jq '.'[0])" >> "$GITHUB_OUTPUT"
54+
echo "::endgroup::"
55+
56+
echo ""
57+
echo "::group::PHP"
58+
php=$(echo $PHP | jq --compact-output --raw-input --raw-output '.' | jq --compact-output --slurp '.')
59+
echo "php = $php"
60+
echo "php=$php" >> "$GITHUB_OUTPUT"
61+
echo "php-single = $(echo $php | jq '.'[-1])"
62+
echo "php-single=$(echo $php | jq '.'[-1])" >> "$GITHUB_OUTPUT"
63+
echo "::endgroup::"
64+
65+
echo ""
66+
echo "::group::EXCLUDE"
67+
exclude=$(cat <<EOF | jq -nc -f /dev/stdin | jq -c 'to_entries | map_values(.value)'
68+
$EXCLUDE
69+
EOF
70+
)
71+
echo "exclude = $exclude"
72+
echo "exclude=$exclude)" >> "$GITHUB_OUTPUT"
73+
echo "::endgroup::"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/vendor
22
/composer.lock
3-
/.php_cs.cache
3+
/.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
if (PHP_SAPI !== 'cli') {
3+
die('This script supports command line usage only. Please check your command.');
4+
}
5+
// Define in which folders to search and which folders to exclude
6+
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
7+
$finder = PhpCsFixer\Finder::create()
8+
->in(__DIR__ . '/src/');
9+
10+
$configFinder = PhpCsFixer\Finder::create()
11+
->in(__DIR__)
12+
->depth('0');
13+
14+
$finder->append($configFinder);
15+
16+
// Return a Code Sniffing configuration using
17+
// all sniffers needed for PSR-2
18+
// and additionally:
19+
// - Remove leading slashes in use clauses.
20+
// - PHP single-line arrays should not have trailfing comma.
21+
// - Single-line whitespace before closing semicolon are prohibited.
22+
// - Remove unused use statements in the PHP source code
23+
// - Ensure Concatenation to have at least one whitespace around
24+
// - Remove trailing whitespace at the end of blank lines.
25+
return (new PhpCsFixer\Config)
26+
->setRiskyAllowed(true)
27+
->setRules([
28+
'@PSR2' => true,
29+
'@DoctrineAnnotation' => true,
30+
'no_leading_import_slash' => true,
31+
'no_trailing_comma_in_singleline_array' => true,
32+
'no_singleline_whitespace_before_semicolons' => true,
33+
'no_unused_imports' => true,
34+
'concat_space' => ['spacing' => 'one'],
35+
'no_whitespace_in_blank_line' => true,
36+
'ordered_imports' => true,
37+
'single_quote' => true,
38+
'no_empty_statement' => true,
39+
'no_extra_blank_lines' => true,
40+
'phpdoc_no_package' => true,
41+
'phpdoc_scalar' => true,
42+
'no_blank_lines_after_phpdoc' => true,
43+
'array_syntax' => ['syntax' => 'short'],
44+
'whitespace_after_comma_in_array' => true,
45+
'function_typehint_space' => true,
46+
'no_alias_functions' => true,
47+
'lowercase_cast' => true,
48+
'no_leading_namespace_whitespace' => true,
49+
'native_function_casing' => true,
50+
'no_short_bool_cast' => true,
51+
'no_unneeded_control_parentheses' => true,
52+
'no_empty_phpdoc' => true,
53+
'phpdoc_no_empty_return' => true,
54+
'phpdoc_trim' => true,
55+
'no_superfluous_elseif' => true,
56+
'no_useless_else' => true,
57+
'phpdoc_types' => true,
58+
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
59+
'return_type_declaration' => ['space_before' => 'none'],
60+
'cast_spaces' => ['space' => 'none'],
61+
'declare_equal_normalize' => ['space' => 'none'],
62+
'dir_constant' => true,
63+
])
64+
->setFinder($finder);

0 commit comments

Comments
 (0)