Skip to content

Commit 9df6849

Browse files
committed
new workflow files and phpcs errors
Signed-off-by: sergiu <[email protected]>
1 parent c0b339f commit 9df6849

20 files changed

+229
-141
lines changed

.github/workflows/codecov.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on:
2+
- push
3+
4+
name: Run Codecov checks
5+
6+
jobs:
7+
code-coverage:
8+
name: Code Coverage
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: "${{ matrix.php }}"
30+
coverage: pcov
31+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
32+
tools: composer:v2, cs2pr
33+
34+
- name: Determine composer cache directory
35+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
36+
37+
- name: Cache dependencies installed with composer
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ env.COMPOSER_CACHE_DIR }}
41+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: |
43+
php${{ matrix.php }}-composer-
44+
45+
- name: Install dependencies with composer
46+
env:
47+
COMPOSER_DEV_MODE: 1
48+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
49+
50+
- name: Collect code coverage with PHPUnit
51+
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
52+
53+
- name: Send code coverage report to Codecov.io
54+
uses: codecov/codecov-action@v3
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,8 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- '[0-9]+.[0-9]+.x'
8-
- 'refs/pull/*'
97
tags:
108

119
jobs:
12-
matrix:
13-
name: Generate job matrix
14-
runs-on: ubuntu-latest
15-
outputs:
16-
matrix: ${{ steps.matrix.outputs.matrix }}
17-
steps:
18-
- name: Gather CI configuration
19-
id: matrix
20-
uses: laminas/laminas-ci-matrix-action@v1
21-
22-
qa:
23-
name: QA Checks
24-
needs: [matrix]
25-
runs-on: ${{ matrix.operatingSystem }}
26-
strategy:
27-
fail-fast: false
28-
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
29-
steps:
30-
- name: ${{ matrix.name }}
31-
uses: laminas/laminas-continuous-integration-action@v1
32-
with:
33-
job: ${{ matrix.job }}
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/[email protected]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Qodana
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'main'
8+
9+
jobs:
10+
qodana:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
checks: write
16+
strategy:
17+
matrix:
18+
php-versions: [ '8.2', '8.3', '8.4']
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
23+
fetch-depth: 0 # a full history is required for pull request analysis
24+
- name: Install PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-versions }}
28+
coverage: pcov
29+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
30+
tools: composer:v2, cs2pr
31+
32+
- name: Determine composer cache directory
33+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ env.COMPOSER_CACHE_DIR }}
39+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
php${{ matrix.php }}-composer-
42+
43+
- name: Install dependencies with composer
44+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
45+
- name: 'Qodana Scan'
46+
uses: JetBrains/[email protected]
47+
env:
48+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

composer.json

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"symfony/redis-messenger": "^v7.2.3"
5454
},
5555
"require-dev": {
56+
"laminas/laminas-coding-standard": "^3.0",
5657
"phpunit/phpunit": "^10.5.45",
5758
"psalm/plugin-phpunit": "^0.19.2",
5859
"roave/security-advisories": "dev-master",
@@ -66,39 +67,18 @@
6667
},
6768
"autoload-dev": {
6869
"psr-4": {
70+
"DotTest\\Mail\\": "test/"
6971
}
7072
},
7173
"scripts": {
72-
"development-disable": "laminas-development-mode disable",
73-
"development-enable": "laminas-development-mode enable",
74-
"development-status": "laminas-development-mode status",
75-
"mezzio": "laminas --ansi",
7674
"check": [
7775
"@cs-check",
7876
"@test"
7977
],
80-
"clear-config-cache": "php bin/clear-config-cache.php",
81-
"enable-codestandard": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
82-
"cs-check": [
83-
"@enable-codestandard",
84-
"phpcs -s"
85-
],
86-
"cs-fix": [
87-
"@enable-codestandard",
88-
"phpcbf"
89-
],
90-
"serve": [
91-
"Composer\\Config::disableProcessTimeout",
92-
"php -S 0.0.0.0:8080 -t public/"
93-
],
94-
"static-analysis": "psalm --stats",
95-
"static-analysis-update-baseline": "psalm --stats --update-baseline",
78+
"cs-check": "phpcs",
79+
"cs-fix": "phpcbf",
9680
"test": "phpunit --colors=always",
97-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
98-
},
99-
"scripts-descriptions": {
100-
"clear-config-cache": "Clears merged config cache. Required for config changes to be applied.",
101-
"static-analysis": "Run static analysis tool Psalm.",
102-
"static-analysis-update-baseline": "Run static analysis tool Psalm and update baseline."
81+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
82+
"static-analysis": "psalm --shepherd --stats"
10383
}
10484
}

config/autoload/cli.global.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Dot\Cli\FileLockerInterface;
6+
use Queue\Swoole\Command\StartCommand;
7+
use Queue\Swoole\Command\StopCommand;
8+
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
9+
use Symfony\Component\Messenger\Command\DebugCommand;
410

511
return [
612
'dot_cli' => [
713
'version' => '1.0.0',
814
'name' => 'DotKernel CLI',
915
'commands' => [
10-
"swoole:start" => \Queue\Swoole\Command\StartCommand::class,
11-
"swoole:stop" => \Queue\Swoole\Command\StopCommand::class,
12-
"messenger:start" => \Symfony\Component\Messenger\Command\ConsumeMessagesCommand::class,
13-
"messenger:debug" => \Symfony\Component\Messenger\Command\DebugCommand::class
16+
"swoole:start" => StartCommand::class,
17+
"swoole:stop" => StopCommand::class,
18+
"messenger:start" => ConsumeMessagesCommand::class,
19+
"messenger:debug" => DebugCommand::class,
1420
],
1521
],
1622
FileLockerInterface::class => [
1723
'enabled' => false,
1824
'dirPath' => getcwd() . '/data/lock',
1925
],
20-
];
26+
];

config/pipeline.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
// - $app->pipe('/docs', $apiDocMiddleware);
3535
// - $app->pipe('/files', $filesMiddleware);
3636

37-
3837
// The following handle routing failures for common conditions:
3938
// - HEAD request but no routes answer that method
4039
// - OPTIONS request but no routes answer that method
@@ -53,9 +52,7 @@
5352

5453
// Register the dispatch middleware in the middleware pipeline
5554

56-
5755
// At this point, if no Response is returned by any middleware, the
5856
// NotFoundHandler kicks in; alternately, you can provide other fallback
5957
// middleware to execute.
60-
6158
};

src/App/ConfigProvider.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Queue\App;
46

5-
use Laminas\ServiceManager\Factory\InvokableFactory;
67
use Netglue\PsrContainer\Messenger\Container\MessageBusStaticFactory;
78
use Netglue\PsrContainer\Messenger\Container\Middleware\BusNameStampMiddlewareStaticFactory;
89
use Netglue\PsrContainer\Messenger\Container\Middleware\MessageHandlerMiddlewareStaticFactory;
@@ -15,40 +16,40 @@
1516

1617
class ConfigProvider
1718
{
18-
public function __invoke()
19+
public function __invoke(): array
1920
{
2021
return [
2122
"dependencies" => $this->getDependencies(),
22-
'symfony' => [
23+
'symfony' => [
2324
'messenger' => [
2425
'buses' => $this->busConfig(),
2526
],
2627
],
2728
];
2829
}
2930

30-
31-
private function getDependencies()
31+
private function getDependencies(): array
3232
{
3333
return [
3434
"factories" => [
35-
"message_bus" => [MessageBusStaticFactory::class, "message_bus"],
36-
"message_bus_stamp_middleware" => [BusNameStampMiddlewareStaticFactory::class, "message_bus"],
37-
"message_bus_sender_middleware" => [MessageSenderMiddlewareStaticFactory::class, "message_bus"],
35+
"message_bus" => [MessageBusStaticFactory::class, "message_bus"],
36+
"message_bus_stamp_middleware" => [BusNameStampMiddlewareStaticFactory::class, "message_bus"],
37+
"message_bus_sender_middleware" => [MessageSenderMiddlewareStaticFactory::class, "message_bus"],
3838
"message_bus_handler_middleware" => [MessageHandlerMiddlewareStaticFactory::class, "message_bus"],
39-
ExampleMessageHandler::class => ExampleMessageHandlerFactory::class
39+
ExampleMessageHandler::class => ExampleMessageHandlerFactory::class,
40+
],
41+
"aliases" => [
42+
MessageBusInterface::class => "message_bus",
4043
],
41-
"aliases" => [
42-
MessageBusInterface::class => "message_bus"
43-
]
4444
];
4545
}
4646

47-
private function busConfig()
47+
private function busConfig(): array
4848
{
4949
return [
5050
"message_bus" => [
51-
'allows_zero_handlers' => false, // Means that it's an error if no handlers are defined for a given message
51+
// Means that it's an error if no handlers are defined for a given message
52+
'allows_zero_handlers' => false,
5253

5354
/**
5455
* Each bus needs middleware to do anything useful.
@@ -67,10 +68,9 @@ private function busConfig()
6768
*
6869
* Two locators are shipped, 1 message type to 1 handler and 1 message type to many handlers.
6970
* Both locators operate on the basis that handlers are available in the container.
70-
*
7171
*/
7272
'handler_locator' => OneToManyFqcnContainerHandlerLocator::class,
73-
'handlers' => [
73+
'handlers' => [
7474
ExampleMessage::class => [ExampleMessageHandler::class],
7575
],
7676

@@ -89,7 +89,7 @@ private function busConfig()
8989
'routes' => [
9090
ExampleMessage::class => ["redis_transport"],
9191
],
92-
]
92+
],
9393
];
9494
}
95-
}
95+
}

src/App/Message/ExampleMessage.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Queue\App\Message;
46

57
class ExampleMessage
68
{
79
public function __construct(
810
private array $payload,
9-
)
10-
{
11+
) {
1112
}
1213

1314
public function getPayload(): array
1415
{
1516
return $this->payload;
1617
}
17-
18-
}
18+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Queue\App\Message;
46

57
use Dot\Log\Logger;
68
use Psr\Container\ContainerInterface;
9+
710
class ExampleMessageHandler
811
{
912
public function __construct(private readonly ContainerInterface $container)
@@ -12,10 +15,9 @@ public function __construct(private readonly ContainerInterface $container)
1215

1316
public function __invoke(ExampleMessage $message)
1417
{
15-
1618
/** @var Logger $logger */
1719
$logger = $this->container->get("dot-log.queue-log");
1820

1921
$logger->info("message: " . $message->getPayload()['foo'] ?? null);
2022
}
21-
}
23+
}

0 commit comments

Comments
 (0)