Skip to content

Commit d302a9d

Browse files
committed
[TASK] Refactor CI
1 parent 80152c0 commit d302a9d

File tree

14 files changed

+305
-92
lines changed

14 files changed

+305
-92
lines changed

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI with Composer scripts
2+
on:
3+
push:
4+
paths:
5+
- '**.php'
6+
- '.github/workflows/ci.yml'
7+
- 'Build/phpunit/FunctionalTests.xml'
8+
- 'Build/phpunit/UnitTests.xml'
9+
- 'composer.json'
10+
branches:
11+
- main
12+
pull_request:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
php-lint:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
strategy:
22+
fail-fast: true
23+
matrix:
24+
php: [8.2, 8.3, 8.4]
25+
26+
name: "PHP linter - ${{ matrix.php }}"
27+
28+
steps:
29+
- name: "Checkout code"
30+
uses: actions/checkout@v6
31+
32+
- name: "Setup PHP"
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: "${{ matrix.php }}"
36+
coverage: none
37+
38+
- name: "Run PHP lint"
39+
run: find .*.php *.php Classes Configuration -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l
40+
41+
code-quality:
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 5
44+
strategy:
45+
fail-fast: true
46+
matrix:
47+
command:
48+
- "composer:normalize"
49+
- "composer:psr-verify"
50+
- "php:ecs"
51+
- "php:rector"
52+
- "php:fractor"
53+
- "php:stan"
54+
php: [8.2]
55+
56+
name: "Code quality checks"
57+
58+
steps:
59+
- name: "Checkout code"
60+
uses: actions/checkout@v6
61+
62+
- name: "Setup PHP"
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: "${{ matrix.php }}"
66+
coverage: none
67+
tools: composer:v2
68+
69+
- name: "Show Composer version"
70+
run: composer --version
71+
72+
- name: "Show the Composer configuration"
73+
run: composer config --global --list
74+
75+
- name: "Cache dependencies installed with composer"
76+
uses: actions/cache@v5
77+
with:
78+
key: "php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
79+
path: ~/.cache/composer
80+
restore-keys: "php${{ matrix.php }}-composer-\n"
81+
82+
- name: "Install Composer dependencies"
83+
run: composer install --no-progress
84+
85+
- name: "List Installed Dependencies"
86+
run: composer show -D
87+
88+
- name: "Run command"
89+
run: composer ci:${{ matrix.command }}

.github/workflows/tests.yml

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

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
.Build/
2-
config/
3-
var/
4-
composer.lock
1+
/.Build/
2+
/.cache/
3+
/.idea/
4+
/config/
5+
/var/
6+
/.env
7+
/composer.lock

Build/ecs/ecs.php

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer;
6+
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
7+
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
8+
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
9+
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
10+
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
11+
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
12+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
13+
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
14+
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
15+
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
16+
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
17+
use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer;
18+
use Symplify\EasyCodingStandard\Config\ECSConfig;
19+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
20+
21+
return static function (ECSConfig $ecsConfig): void {
22+
$ecsConfig->paths([
23+
__DIR__ . '/../../Build',
24+
__DIR__ . '/../../Classes',
25+
__DIR__ . '/../../Configuration',
26+
__DIR__ . '/../../ext_emconf.php',
27+
]);
28+
29+
$ecsConfig->sets([
30+
SetList::PSR_12,
31+
SetList::CLEAN_CODE,
32+
SetList::SYMPLIFY,
33+
SetList::ARRAY,
34+
SetList::COMMON,
35+
SetList::COMMENTS,
36+
SetList::CONTROL_STRUCTURES,
37+
SetList::DOCBLOCK,
38+
SetList::NAMESPACES,
39+
SetList::PHPUNIT,
40+
SetList::SPACES,
41+
SetList::STRICT,
42+
]);
43+
44+
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
45+
'annotations' => ['author', 'package', 'group'],
46+
]);
47+
48+
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
49+
'allow_mixed' => true,
50+
]);
51+
52+
$ecsConfig->ruleWithConfiguration(CastSpacesFixer::class, [
53+
'space' => 'single',
54+
]);
55+
56+
$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
57+
'header' => <<<EOF
58+
This file is part of the TYPO3 CMS project.
59+
60+
(c) Christoph Lehmann, Simon Schaufelberger
61+
62+
It is free software; you can redistribute it and/or modify it under
63+
the terms of the GNU General Public License, either version 2
64+
of the License, or any later version.
65+
66+
For the full copyright and license information, please read the
67+
LICENSE.txt file that was distributed with this source code.
68+
69+
The TYPO3 project - inspiring people to share!
70+
EOF
71+
]);
72+
73+
// Rules that are not in a set
74+
$ecsConfig->rule(OperatorLinebreakFixer::class);
75+
$ecsConfig->rule(SingleLineEmptyBodyFixer::class);
76+
77+
$ecsConfig->skip([
78+
LineLengthFixer::class,
79+
DeclareStrictTypesFixer::class => [
80+
__DIR__ . '/../../ext_emconf.php',
81+
],
82+
NotOperatorWithSuccessorSpaceFixer::class,
83+
84+
StrictComparisonFixer::class,
85+
86+
/*HeaderCommentFixer::class => [
87+
__DIR__ . '/../ecs/ecs.php',
88+
__DIR__ . '/../fractor/fractor.php',
89+
__DIR__ . '/../rector/rector.php',
90+
__DIR__ . '/../../ext_emconf.php',
91+
],*/
92+
HeaderCommentFixer::class,
93+
94+
UnaryOperatorSpacesFixer::class,
95+
MethodChainingIndentationFixer::class,
96+
MethodChainingNewlineFixer::class,
97+
]);
98+
};

Build/fractor/fractor.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use a9f\Fractor\Configuration\FractorConfiguration;
6+
use a9f\FractorComposerJson\ChangePackageVersionComposerJsonFractor;
7+
use a9f\FractorComposerJson\ValueObject\PackageAndVersion;
8+
use a9f\Typo3Fractor\Set\Typo3LevelSetList;
9+
10+
return FractorConfiguration::configure()
11+
->withPaths([
12+
__DIR__ . '/../../Classes/',
13+
__DIR__ . '/../../Configuration/',
14+
__DIR__ . '/../../Resources/',
15+
__DIR__ . '/../../composer.json',
16+
__DIR__ . '/../../ext_emconf.php',
17+
])
18+
->withSets([
19+
Typo3LevelSetList::UP_TO_TYPO3_13,
20+
])
21+
->withConfiguredRule(
22+
ChangePackageVersionComposerJsonFractor::class,
23+
[
24+
new PackageAndVersion('typo3/cms-core', '^13.4'),
25+
new PackageAndVersion('typo3/cms-reports', '^13.4'),
26+
// require-dev
27+
new PackageAndVersion('typo3/cms-backend', '^13.4'),
28+
new PackageAndVersion('typo3/cms-fluid', '^13.4'),
29+
new PackageAndVersion('typo3/cms-frontend', '^13.4'),
30+
new PackageAndVersion('typo3/cms-install', '^13.4'),
31+
]
32+
);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
ignoreErrors: []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
define('LF', chr(10));
6+
define('CR', chr(13));

Build/phpstan/phpstan.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
#- ../../.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon
4+
5+
parameters:
6+
# Use local .cache dir instead of /tmp
7+
tmpDir: ../../.cache/phpstan
8+
9+
parallel:
10+
# Don't be overly greedy on machines with more CPU's to be a good neighbor especially on CI
11+
maximumNumberOfProcesses: 5
12+
13+
level: 6
14+
15+
bootstrapFiles:
16+
- phpstan-constants.php
17+
18+
paths:
19+
- ../../Classes
20+
- ../../Configuration

rector.php renamed to Build/rector/rector.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,44 @@
1515
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
1616
use Ssch\TYPO3Rector\Set\Typo3SetList;
1717

18-
return RectorConfig::configure()
19-
->withPaths([
20-
__DIR__ . '/Classes',
21-
__DIR__ . '/ext_emconf.php',
22-
])
23-
->withPhpVersion(PhpVersion::PHP_82)
24-
->withSets([
18+
return static function (RectorConfig $rectorConfig): void {
19+
$rectorConfig->paths([
20+
__DIR__ . '/../../Classes',
21+
__DIR__ . '/../../ext_emconf.php',
22+
]);
23+
$rectorConfig->phpVersion(PhpVersion::PHP_82);
24+
$rectorConfig->sets([
25+
// Rector sets
2526
LevelSetList::UP_TO_PHP_82,
2627
SetList::CODE_QUALITY,
27-
SetList::CODING_STYLE,
2828
SetList::DEAD_CODE,
29-
SetList::STRICT_BOOLEANS,
29+
SetList::CODING_STYLE,
30+
//SetList::STRICT_BOOLEANS,
31+
//SetList::NAMING,
32+
SetList::PRIVATIZATION,
3033
SetList::TYPE_DECLARATION,
34+
SetList::EARLY_RETURN,
3135
SetList::INSTANCEOF,
36+
37+
// TYPO3 Sets
3238
Typo3SetList::CODE_QUALITY,
3339
Typo3SetList::GENERAL,
3440
Typo3LevelSetList::UP_TO_TYPO3_13,
35-
])
36-
->withConfiguredRule(ExtEmConfRector::class, [
41+
]);
42+
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
43+
$rectorConfig->rules([
44+
AddVoidReturnTypeWhereNoReturnRector::class,
45+
ConvertImplicitVariablesToExplicitGlobalsRector::class,
46+
]);
47+
$rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [
3748
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.2.0-8.4.99',
3849
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.4.0-13.4.99',
3950
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
40-
])
41-
->withRules([
42-
ConvertImplicitVariablesToExplicitGlobalsRector::class,
43-
AddVoidReturnTypeWhereNoReturnRector::class,
44-
])
45-
# To have a better analysis from PHPStan, we teach it here some more things
46-
->withPHPStanConfigs([Typo3Option::PHPSTAN_FOR_RECTOR_PATH])
47-
->withImportNames(true, true, false, true)
48-
->withSkip([
51+
]);
52+
$rectorConfig->importNames();
53+
$rectorConfig->importShortClasses(false);
54+
$rectorConfig->skip([
4955
SimplifyBoolIdenticalTrueRector::class,
5056
NewlineAfterStatementRector::class,
5157
]);
58+
};

Classes/BinaryNotFoundException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44

55
namespace Lemming\Imageoptimizer;
66

7-
class BinaryNotFoundException extends \Exception
8-
{
9-
}
7+
class BinaryNotFoundException extends \Exception {}

0 commit comments

Comments
 (0)