Skip to content

Commit 674b380

Browse files
committed
Add ci pipeline
1 parent 1346c18 commit 674b380

8 files changed

Lines changed: 193 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
13+
jobs:
14+
test:
15+
name: PHP 8.1 - Test Suite
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Cache Composer packages
23+
uses: actions/cache@v4
24+
id: composer-cache
25+
with:
26+
path: |
27+
root-composer-cache
28+
key: ${{ runner.os }}-cache-composer-${{ hashFiles('composer.lock') }}
29+
30+
- name: Validate composer.json and composer.lock
31+
uses: php-actions/composer@v6
32+
with:
33+
php_version: 8.1
34+
version: 2.8.9
35+
command: validate
36+
args: --strict
37+
38+
- name: Install dependencies
39+
uses: php-actions/composer@v6
40+
with:
41+
php_version: 8.1
42+
version: 2.8.9
43+
command: install
44+
args: --prefer-dist --no-progress
45+
46+
- name: Run linting
47+
uses: php-actions/composer@v6
48+
with:
49+
php_version: 8.1
50+
version: 2.8.9
51+
command: run lint
52+
53+
- name: Run PHPStan
54+
uses: php-actions/composer@v6
55+
with:
56+
php_version: 8.1
57+
version: 2.8.9
58+
command: run phpstan
59+
60+
- name: Run PHPUnit tests
61+
uses: php-actions/composer@v6
62+
with:
63+
php_version: 8.1
64+
version: 2.8.9
65+
command: run phpunit

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bin
2+
Build
3+
Data
4+
Packages
5+
vendor
6+
.DS_Store
7+
.idea/
8+
.phpcs-cache
9+
.php-cs-fixer.cache
10+
.phpunit.result.cache
11+
composer.lock
12+
report.xml

.php-cs-fixer.dist.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in([__DIR__ . '/Classes', __DIR__ . '/Tests']);
5+
6+
return (new PhpCsFixer\Config())
7+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
8+
->setRules([
9+
'@PSR12' => true,
10+
'@PHP82Migration' => true,
11+
'yoda_style' => false,
12+
'concat_space' => ['spacing' => 'one'],
13+
'no_unused_imports' => false,
14+
'no_superfluous_phpdoc_tags' => false,
15+
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
16+
'class_definition' => ['multi_line_extends_each_single_line' => true],
17+
'global_namespace_import' => ['import_classes' => true],
18+
'phpdoc_annotation_without_dot' => false,
19+
'phpdoc_separation' => false,
20+
'cast_spaces' => ['space' => 'none'],
21+
'phpdoc_summary' => false,
22+
])
23+
->setFinder($finder);

Tests/Unit/Queue/AzureStorageQueueMessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Neos\Flow\Tests\UnitTestCase;
88
use Oniva\JobQueue\AzureQueueStorage\Queue\AzureQueueStorageMessage;
99

10-
class AzureQueueStorageMessageTest extends UnitTestCase
10+
class AzureStorageQueueMessageTest extends UnitTestCase
1111
{
1212
protected AzureQueueStorageMessage $obj;
1313

Tests/Unit/Queue/AzureStorageQueueTest.php

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use MicrosoftAzure\Storage\Queue\Models\CreateMessageResult;
1212
use MicrosoftAzure\Storage\Queue\Models\GetQueueMetadataResult;
1313
use MicrosoftAzure\Storage\Queue\Models\ListMessagesResult;
14+
use MicrosoftAzure\Storage\Queue\Models\PeekMessagesOptions;
1415
use MicrosoftAzure\Storage\Queue\Models\PeekMessagesResult;
1516
use MicrosoftAzure\Storage\Queue\Models\QueueMessage;
1617
use Neos\Flow\Tests\UnitTestCase;
@@ -23,7 +24,7 @@
2324
use Exception;
2425
use ReflectionClass;
2526

26-
class AzureQueueStorageTest extends UnitTestCase
27+
class AzureStorageQueueTest extends UnitTestCase
2728
{
2829
protected AzureQueueStorage $obj;
2930
protected AzureStorageClientFactory&MockObject $clientFactory;
@@ -189,12 +190,15 @@ public function setUpCreatesPriorityQueueWhenEnabled(): void
189190
{
190191
$queue = $this->createQueue('test-queue', ['usePriorityQueue' => true]);
191192

192-
$this->queueService->expects($this->exactly(2))
193+
$matcher = $this->exactly(2);
194+
$this->queueService->expects($matcher)
193195
->method('createQueue')
194-
->withConsecutive(
195-
['test-queue'],
196-
['test-queue-priority']
197-
);
196+
->willReturnCallback(function (string $queueName) use ($matcher) {
197+
match ($matcher->numberOfInvocations()) {
198+
1 => $this->assertEquals($queueName, 'test-queue'),
199+
2 => $this->assertEquals($queueName, 'test-queue-priority'),
200+
};
201+
});
198202

199203
$queue->setUp();
200204
}
@@ -682,11 +686,13 @@ public function peekReturnsMessagesFromBothQueues(): void
682686

683687
$this->queueService->expects($this->exactly(2))
684688
->method('peekMessages')
685-
->withConsecutive(
686-
['test-queue-priority', $this->anything()],
687-
['test-queue', $this->anything()]
688-
)
689-
->willReturnOnConsecutiveCalls($highPriorityResult, $normalResult);
689+
->willReturnCallback(
690+
fn (string $queueName, PeekMessagesOptions $options) =>
691+
match ($queueName) {
692+
'test-queue-priority' => $highPriorityResult,
693+
'test-queue' => $normalResult,
694+
}
695+
);
690696

691697
$messages = $queue->peek(2);
692698

@@ -744,19 +750,23 @@ public function countReadySumsBothQueuesWhenPriorityEnabled(): void
744750

745751
$this->queueService->expects($this->exactly(2))
746752
->method('peekMessages')
747-
->withConsecutive(
748-
['test-queue'],
749-
['test-queue-priority']
750-
)
751-
->willReturnOnConsecutiveCalls($normalMessages, $priorityMessages);
753+
->willReturnCallback(
754+
fn ($queueName) =>
755+
match($queueName) {
756+
'test-queue-priority' => $priorityMessages,
757+
'test-queue' => $normalMessages
758+
}
759+
);
752760

753761
$this->queueService->expects($this->exactly(2))
754762
->method('getQueueMetadata')
755-
->withConsecutive(
756-
['test-queue'],
757-
['test-queue-priority']
758-
)
759-
->willReturnOnConsecutiveCalls($normalMetadata, $priorityMetadata);
763+
->willReturnCallback(
764+
fn ($queueName) =>
765+
match($queueName) {
766+
'test-queue-priority' => $priorityMetadata,
767+
'test-queue' => $normalMetadata
768+
}
769+
);
760770

761771
$count = $queue->countReady();
762772

@@ -848,12 +858,15 @@ public function flushClearsBothQueuesWhenPriorityEnabled(): void
848858
{
849859
$queue = $this->createQueue('test-queue', ['usePriorityQueue' => true]);
850860

851-
$this->queueService->expects($this->exactly(2))
861+
$matcher = $this->exactly(2);
862+
$this->queueService->expects($matcher)
852863
->method('clearMessages')
853-
->withConsecutive(
854-
['test-queue'],
855-
['test-queue-priority']
856-
);
864+
->willReturnCallback(function (string $queueName) use ($matcher) {
865+
match ($matcher->numberOfInvocations()) {
866+
1 => $this->assertEquals($queueName, 'test-queue'),
867+
2 => $this->assertEquals($queueName, 'test-queue-priority'),
868+
};
869+
});
857870

858871
$listBlobsResult = $this->createMock(ListBlobsResult::class);
859872
$listBlobsResult->method('getBlobs')->willReturn([]);
@@ -872,12 +885,15 @@ public function flushClearsPoisonQueueWhenPoisonEnabled(): void
872885
{
873886
$queue = $this->createQueue('test-queue', ['usePoisonQueue' => true]);
874887

875-
$this->queueService->expects($this->exactly(2))
888+
$matcher = $this->exactly(2);
889+
$this->queueService->expects($matcher)
876890
->method('clearMessages')
877-
->withConsecutive(
878-
['test-queue'],
879-
['test-queue-poison']
880-
);
891+
->willReturnCallback(function (string $queueName) use ($matcher) {
892+
match ($matcher->numberOfInvocations()) {
893+
1 => $this->assertEquals($queueName, 'test-queue'),
894+
2 => $this->assertEquals($queueName, 'test-queue-poison'),
895+
};
896+
});
881897

882898
$listBlobsResult = $this->createMock(ListBlobsResult::class);
883899
$listBlobsResult->method('getBlobs')->willReturn([]);

composer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
{
22
"description": "A Flowpack.JobQueue.Common implementation to support Azure Queue Storage as backend",
33
"type": "neos-package",
4+
"license": "MIT",
45
"name": "oniva/jobqueue-azurequeuestorage",
56
"require": {
7+
"php": ">=8.1",
8+
"neos/flow": "^8.0",
69
"flowpack/jobqueue-common": "^3.0",
710
"microsoft/azure-storage-queue": "^1.3",
811
"microsoft/azure-storage-blob": "^1.5"
912
},
13+
"require-dev": {
14+
"phpunit/phpunit": "^10.5",
15+
"friendsofphp/php-cs-fixer": "^3.75",
16+
"phpstan/phpstan": "^2.1",
17+
"neos/buildessentials": "^9.0",
18+
"mikey179/vfsstream": "^1.6"
19+
},
20+
"scripts": {
21+
"phpstan": "bin/phpstan analyse -c phpstan.neon --memory-limit=-1 --level=4",
22+
"phpunit": "bin/phpunit -c phpunit.xml",
23+
"lint": "./bin/php-cs-fixer fix --dry-run -vvv",
24+
"lint:fix": "./bin/php-cs-fixer fix"
25+
},
1026
"autoload": {
1127
"psr-4": {
1228
"Oniva\\JobQueue\\AzureQueueStorage\\": "Classes/"
@@ -18,6 +34,8 @@
1834
}
1935
},
2036
"config": {
37+
"vendor-dir": "Packages/Libraries",
38+
"bin-dir": "bin",
2139
"allow-plugins": {
2240
"neos/composer-plugin": true
2341
}

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: max
3+
reportUnmatchedIgnoredErrors: false
4+
paths:
5+
- Classes

phpunit.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
beStrictAboutChangesToGlobalState="true"
4+
beStrictAboutOutputDuringTests="true"
5+
bootstrap="Build/BuildEssentials/PhpUnit/UnitTestBootstrap.php"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true" convertWarningsToExceptions="true" timeoutForSmallTests="0"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
9+
<coverage includeUncoveredFiles="true">
10+
<include>
11+
<directory>Classes</directory>
12+
</include>
13+
</coverage>
14+
<testsuites>
15+
<testsuite name="Zoon">
16+
<directory>Tests/Unit</directory>
17+
</testsuite>
18+
</testsuites>
19+
<logging>
20+
<junit outputFile="report.xml"/>
21+
</logging>
22+
</phpunit>

0 commit comments

Comments
 (0)