Skip to content

Commit 39ea657

Browse files
committed
TASK: Add linting and testing to ci ... no tets yet
1 parent 6924ced commit 39ea657

File tree

6 files changed

+8928
-11
lines changed

6 files changed

+8928
-11
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
test:
13+
name: "Test (PHP ${{ matrix.php-versions }}, Neos ${{ matrix.flow-versions }})"
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
php-versions: ["8.2", "8.3"]
19+
neos-versions: ["8.3"]
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
with:
27+
path: ${{ env.FLOW_FOLDER }}
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-versions }}
33+
extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite
34+
ini-values: date.timezone="Africa/Tunis", opcache.fast_shutdown=0, apc.enable_cli=on
35+
36+
- name: Set Neos Version
37+
run: composer require neos/neos ^${{ matrix.neos-versions }} --no-progress --no-interaction
38+
39+
- name: Run Linter
40+
run: composer lint
41+
42+
- name: Run Test
43+
run: composer test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
Packages
3+
vendor

Classes/Command/NodetypeObjectsCommandController.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace PackageFactory\NodeTypeObjects\Command;
56

67
use Neos\ContentRepository\Domain\Model\NodeType;
78
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
89
use Neos\Flow\Cli\CommandController;
10+
use Neos\Flow\Core\Bootstrap;
911
use Neos\Flow\Package\FlowPackageInterface;
1012
use Neos\Flow\Package\PackageManager;
1113
use Neos\Utility\Files;
@@ -18,7 +20,7 @@ class NodetypeObjectsCommandController extends CommandController
1820

1921
public function injectNodeTypeManager(NodeTypeManager $nodeTypeManager): void
2022
{
21-
$this->nodeTypeManager = $nodeTypeManager;
23+
$this->nodeTypeManager = $nodeTypeManager;
2224
}
2325

2426
public function injectPackageManager(PackageManager $packageManager): void
@@ -32,9 +34,9 @@ public function injectPackageManager(PackageManager $packageManager): void
3234
* @param string $packageKey PackageKey to store the classes in
3335
* @return void
3436
*/
35-
public function cleanCommand(string $packageKey):void
37+
public function cleanCommand(string $packageKey): void
3638
{
37-
if($this->packageManager->isPackageAvailable($packageKey)) {
39+
if ($this->packageManager->isPackageAvailable($packageKey)) {
3840
$package = $this->packageManager->getPackage($packageKey);
3941
} else {
4042
$this->output->outputLine("Unknown package " . $packageKey);
@@ -62,9 +64,9 @@ public function cleanCommand(string $packageKey):void
6264
*
6365
* @param string $packageKey PackageKey
6466
*/
65-
public function buildCommand(string $packageKey):void
67+
public function buildCommand(string $packageKey): void
6668
{
67-
if($this->packageManager->isPackageAvailable($packageKey)) {
69+
if ($this->packageManager->isPackageAvailable($packageKey)) {
6870
$package = $this->packageManager->getPackage($packageKey);
6971
} else {
7072
$this->output->outputLine("Unknown package " . $packageKey);
@@ -81,7 +83,7 @@ public function buildCommand(string $packageKey):void
8183
if (!str_starts_with($nodeType->getName(), $packageKey . ':')) {
8284
continue;
8385
}
84-
$localNameParts = explode('.', str_replace( $packageKey . ':','', $nodeType->getName()));
86+
$localNameParts = explode('.', str_replace($packageKey . ':', '', $nodeType->getName()));
8587
$localName = array_pop($localNameParts);
8688
$localNamespace = implode('.', $localNameParts);
8789

@@ -91,10 +93,10 @@ public function buildCommand(string $packageKey):void
9193
. '/' . $localName;
9294
$fileName = $localName . 'NodeObject.php';
9395

94-
$classNamespace = str_replace('.', '\\' , $packageKey)
96+
$classNamespace = str_replace('.', '\\', $packageKey)
9597
. '\\NodeTypes'
96-
. '\\' . str_replace('.', '\\' , $localNamespace)
97-
. '\\' . str_replace('.', '\\' , $localName);
98+
. '\\' . str_replace('.', '\\', $localNamespace)
99+
. '\\' . str_replace('.', '\\', $localName);
98100

99101
$className = $localName . 'NodeObject';
100102

@@ -111,7 +113,7 @@ public function buildCommand(string $packageKey):void
111113
}
112114
}
113115

114-
private function buildOne(FlowPackageInterface $package, NodeType $nodeType, string $classNamespace, string $className, string $filePath, string $fileName):void
116+
private function buildOne(FlowPackageInterface $package, NodeType $nodeType, string $classNamespace, string $className, string $filePath, string $fileName): void
115117
{
116118

117119
$propertyAccesssors = '';
@@ -130,7 +132,7 @@ private function buildOne(FlowPackageInterface $package, NodeType $nodeType, str
130132
$annotationType = $type;
131133
$phpType = 'array';
132134
} elseif (str_starts_with($type, 'array<') && str_ends_with($type, '>')) {
133-
$annotationType = substr($type , 6 ,-1) . '[]';
135+
$annotationType = substr($type, 6, -1) . '[]';
134136
$phpType = 'array';
135137
} elseif ($type === 'boolean') {
136138
$phpType = 'bool';

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,44 @@
1212
"PackageFactory\\NodeTypeObjects\\": "Classes/"
1313
}
1414
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^10.0",
17+
"phpstan/phpstan": "^1.10",
18+
"squizlabs/php_codesniffer": "^3.7"
19+
},
20+
"scripts": {
21+
"fix:code-style": [
22+
"phpcbf --extensions=php --colors --standard=PSR12 ./Classes",
23+
"phpcbf --extensions=php --colors --standard=PSR12 ./Tests"
24+
],
25+
"fix": [
26+
"@install",
27+
"@fix:code-style"
28+
],
29+
"lint:code-style": [
30+
"phpcs --extensions=php --colors --standard=PSR12 --exclude=Generic.Files.LineLength ./Classes",
31+
"phpcs --extensions=php --colors --standard=PSR12 --exclude=Generic.Files.LineLength ./Tests"
32+
],
33+
"lint:static-analysis": "phpstan analyse",
34+
"lint": [
35+
"@install",
36+
"@lint:code-style",
37+
"@lint:static-analysis"
38+
],
39+
"test:unit": "vendor/bin/phpunit Tests/Unit",
40+
"test": [
41+
"@install",
42+
"@test:unit"
43+
]
44+
},
1545
"extra": {
1646
"neos": {
1747
"package-key": "PackageFactory.NodeTypeObjects"
1848
}
49+
},
50+
"config": {
51+
"allow-plugins": {
52+
"neos/composer-plugin": true
53+
}
1954
}
2055
}

0 commit comments

Comments
 (0)