Skip to content

Commit

Permalink
Merge pull request #240 from eliashaeussler/task/separate-cgl
Browse files Browse the repository at this point in the history
[TASK] Separate CGL tools from root composer.json
  • Loading branch information
eliashaeussler committed Jun 6, 2024
2 parents 8051e31 + b3ab061 commit 736e937
Show file tree
Hide file tree
Showing 24 changed files with 8,826 additions and 3,228 deletions.
8 changes: 8 additions & 0 deletions .ddev/commands/web/cgl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

## Description: Run CGL script for the package files
## Usage: cgl [command] [options]
## Example: ddev cgl lint\nddev cgl fix\nddev cgl migration\nddev cgl sca\nddev cgl lint:composer\nddev cgl fix:composer

composer -d /var/www/html/Tests/CGL "$@"
15 changes: 15 additions & 0 deletions .ddev/commands/web/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e

## Description: Run tests for the package files
## Usage: test [command] [options]
## Example: ddev test\nddev test functional\nddev test unit

if [ $# -ge 1 ]; then
script="test:${1}"
shift
else
script="test"
fi

composer -d /var/www/html "${script}" "$@"
5 changes: 0 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@
/Resources/Private/Libs export-ignore
/Tests export-ignore
/.editorconfig export-ignore
/.editorconfig-lint.php export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CODEOWNERS export-ignore
/composer.lock export-ignore
/CONTRIBUTING.md export-ignore
/docker-compose.yml export-ignore
/ext_localconf.php export-ignore
/packaging_exclude.php export-ignore
/phpstan.php export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.functional.xml export-ignore
/phpunit.unit.xml export-ignore
/rector.php export-ignore
/renovate.json export-ignore
10 changes: 5 additions & 5 deletions .github/workflows/cgl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ jobs:

# Linting
- name: Lint composer.json
run: composer lint:composer
run: composer cgl lint:composer
- name: Lint Editorconfig
run: composer lint:editorconfig
run: composer cgl lint:editorconfig
- name: Lint PHP
run: composer lint:php -- --format=checkstyle | cs2pr
run: composer cgl lint:php -- --format=checkstyle | cs2pr

# SCA
- name: SCA PHP
run: composer sca:php -- --error-format github
run: composer cgl sca:php -- --error-format github

# Install Frontend dependencies
- name: Install Frontend dependencies
Expand All @@ -80,4 +80,4 @@ jobs:

# Migration
- name: Rector migration
run: composer migration:rector -- --dry-run
run: composer cgl migration:rector -- --dry-run
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/var
/Resources/Private/Libs/Build/vendor
/Resources/Private/Libs/vendors.phar
/.php-cs-fixer.cache
/.phpunit.result.cache
2 changes: 1 addition & 1 deletion Classes/Formatter/WebStreamFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function filterPendingChoices(array $choices): array
{
return array_filter(
$choices,
static fn (Responses\Chat\CreateResponseChoice $choice): bool => $choice->finishReason === null,
static fn(Responses\Chat\CreateResponseChoice $choice): bool => $choice->finishReason === null,
);
}
}
4 changes: 2 additions & 2 deletions Classes/ProblemSolving/Solution/Solution.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function fromArray(array $solution): self
{
$choices = array_map(
/* @phpstan-ignore-next-line */
static fn (array $choice): Responses\Chat\CreateResponseChoice => Responses\Chat\CreateResponseChoice::from($choice),
static fn(array $choice): Responses\Chat\CreateResponseChoice => Responses\Chat\CreateResponseChoice::from($choice),
$solution['choices'],
);

Expand Down Expand Up @@ -137,7 +137,7 @@ public function toArray(): array
{
return [
'choices' => array_map(
static fn (Responses\Chat\CreateResponseChoice $choice): array => $choice->toArray(),
static fn(Responses\Chat\CreateResponseChoice $choice): array => $choice->toArray(),
$this->choices,
),
'model' => $this->model,
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/MarkdownToHtmlViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static function replaceLineNumbersInCodeSnippets(string $html): string
'</span><span',
preg_replace_callback(
'/<pre><code>(.*?)<\/code><\/pre>/s',
static fn (array $matches): string => self::replaceLineNumbersInCodeSnippet($matches[1]),
static fn(array $matches): string => self::replaceLineNumbersInCodeSnippet($matches[1]),
$html,
) ?? $html,
) ?? $html;
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

use Symfony\Component\DependencyInjection;

return static function(
return static function (
DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator,
DependencyInjection\ContainerBuilder $containerBuilder,
): void {
Expand Down
34 changes: 17 additions & 17 deletions Documentation/Contributing/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,26 @@ TYPO3
.. code-block:: bash
# All linters
ddev composer lint
ddev cgl lint
# Specific linters
ddev composer lint:composer
ddev composer lint:editorconfig
ddev composer lint:php
ddev cgl lint:composer
ddev cgl lint:editorconfig
ddev cgl lint:php
# Fix all CGL issues
ddev composer fix
ddev cgl fix
# Fix specific CGL issues
ddev composer fix:composer
ddev composer fix:editorconfig
ddev composer fix:php
ddev cgl fix:composer
ddev cgl fix:editorconfig
ddev cgl fix:php
# All static code analyzers
ddev composer sca
ddev cgl sca
# Specific static code analyzers
ddev composer sca:php
ddev cgl sca:php
.. _cgl-frontend:

Expand Down Expand Up @@ -139,21 +139,21 @@ Run tests
.. code-block:: bash
# All tests
ddev composer test
ddev test
# Specific tests
ddev composer test:functional
ddev composer test:unit
ddev test functional
ddev test unit
# All tests with code coverage
ddev composer test:coverage
ddev test coverage
# Specific tests with code coverage
ddev composer test:coverage:functional
ddev composer test:coverage:unit
ddev test coverage:functional
ddev test coverage:unit
# Merge code coverage of all test suites
ddev composer test:coverage:merge
ddev test coverage:merge
Code coverage reports are written to :file:`.build/coverage`. You can
open the last merged HTML report like follows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

return \Symfony\Component\Finder\Finder::create()
->files()
->in(__DIR__)
->in(dirname(__DIR__, 2))
->ignoreVCSIgnored(true)
->exclude([
'Resources/Public/JavaScript',
Expand Down
2 changes: 2 additions & 0 deletions Tests/CGL/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor
/.php-cs-fixer.cache
2 changes: 1 addition & 1 deletion .php-cs-fixer.php → Tests/CGL/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
;

$finder = $config->getFinder()
->in(__DIR__)
->in(dirname(__DIR__, 2))
->ignoreVCSignored(true)
;

Expand Down
52 changes: 52 additions & 0 deletions Tests/CGL/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"require-dev": {
"armin/editorconfig-cli": "^1.5 || ^2.0",
"eliashaeussler/phpstan-config": "^2.0",
"eliashaeussler/rector-config": "^3.0",
"ergebnis/composer-normalize": "^2.29",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-symfony": "^1.2",
"saschaegerer/phpstan-typo3": "^1.8",
"typo3/coding-standards": "^0.8.0@dev"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true,
"typo3/class-alias-loader": false,
"typo3/cms-composer-installers": false
},
"sort-packages": true
},
"scripts": {
"fix": [
"@fix:composer",
"@fix:editorconfig",
"@fix:php"
],
"fix:composer": [
"@composer normalize",
"@composer normalize ../../composer.json",
"@composer normalize ../../Resources/Private/Libs/Build/composer.json",
"@composer normalize ../Functional/Fixtures/Extensions/middleware_bridge/composer.json"
],
"fix:editorconfig": "@lint:editorconfig --fix",
"fix:php": "php-cs-fixer fix",
"lint": [
"@lint:composer",
"@lint:editorconfig",
"@lint:php"
],
"lint:composer": "@fix:composer --dry-run",
"lint:editorconfig": "ec --finder-config .editorconfig-lint.php",
"lint:php": "@fix:php --dry-run",
"migration": [
"@migration:rector"
],
"migration:rector": "rector process",
"sca": [
"@sca:php"
],
"sca:php": "phpstan analyse -c phpstan.php"
}
}
Loading

0 comments on commit 736e937

Please sign in to comment.