Skip to content

Commit 399917f

Browse files
authored
chore: phpunit setup (#32)
1 parent 48d65fb commit 399917f

File tree

11 files changed

+158
-18
lines changed

11 files changed

+158
-18
lines changed

.github/workflows/pipeline.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: pipeline
22
on: pull_request
33

44
jobs:
5-
pipeline:
5+
tests:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
@@ -28,6 +28,29 @@ jobs:
2828
- name: Install PHP Dependencies
2929
run: composer install --no-scripts
3030

31+
- name: Tests
32+
run: vendor/bin/phpunit
33+
34+
qa:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup PHP
41+
uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: '8.2'
44+
45+
- name: Install Composer
46+
uses: "ramsey/composer-install@v3"
47+
48+
- name: Composer Validation
49+
run: composer validate --strict
50+
51+
- name: Install PHP Dependencies
52+
run: composer install --no-scripts
53+
3154
- name: Code Style PHP
3255
run: vendor/bin/php-cs-fixer fix --dry-run
3356

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
vendor
22
composer.lock
33
.php-cs-fixer.cache
4+
.phpunit.cache
5+
coverage

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@ qa:
22
composer update --prefer-stable
33
vendor/bin/php-cs-fixer fix
44
vendor/bin/phpstan
5+
vendor/bin/phpunit
56

67
qa-lowest:
78
composer update --prefer-lowest
89
vendor/bin/php-cs-fixer fix
910
vendor/bin/phpstan
11+
vendor/bin/phpunit
12+
13+
qa-dev:
14+
composer require php-llm/llm-chain:dev-main
15+
vendor/bin/php-cs-fixer fix
16+
vendor/bin/phpstan
17+
vendor/bin/phpunit
18+
# revert
19+
git restore composer.json
20+
21+
coverage:
22+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage

composer.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "php-llm/llm-chain-bundle",
3+
"type": "symfony-bundle",
34
"description": "Symfony integration bundle for php-llm/llm-chain",
45
"license": "MIT",
5-
"type": "symfony-bundle",
66
"authors": [
77
{
88
"name": "Christopher Hertel",
@@ -18,13 +18,22 @@
1818
},
1919
"require-dev": {
2020
"php-cs-fixer/shim": "^3.64",
21-
"phpstan/phpstan": "^1.12"
21+
"phpstan/phpstan": "^1.12",
22+
"phpunit/phpunit": "^11.3"
23+
},
24+
"config": {
25+
"sort-packages": true
2226
},
23-
"minimum-stability": "dev",
24-
"prefer-stable": true,
2527
"autoload": {
2628
"psr-4": {
2729
"PhpLlm\\LlmChainBundle\\": "src/"
2830
}
29-
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"PhpLlm\\LlmChainBundle\\Tests\\": "tests/"
35+
}
36+
},
37+
"minimum-stability": "dev",
38+
"prefer-stable": true
3039
}

phpunit.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
colors="true"
7+
executionOrder="depends,defects"
8+
requireCoverageMetadata="true"
9+
beStrictAboutCoverageMetadata="true"
10+
beStrictAboutOutputDuringTests="true"
11+
failOnRisky="true"
12+
failOnWarning="true">
13+
<testsuites>
14+
<testsuite name="default">
15+
<directory>tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
20+
<include>
21+
<directory>src</directory>
22+
</include>
23+
</source>
24+
</phpunit>

src/DependencyInjection/LlmChainExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
use PhpLlm\LlmChain\Store\StoreInterface;
1919
use PhpLlm\LlmChain\Store\VectorStoreInterface;
2020
use PhpLlm\LlmChain\ToolBox\AsTool;
21-
use PhpLlm\LlmChainBundle\DataCollector;
22-
use PhpLlm\LlmChainBundle\TraceableLanguageModel;
23-
use PhpLlm\LlmChainBundle\TraceableToolBox;
21+
use PhpLlm\LlmChainBundle\Profiler\DataCollector;
22+
use PhpLlm\LlmChainBundle\Profiler\TraceableLanguageModel;
23+
use PhpLlm\LlmChainBundle\Profiler\TraceableToolBox;
2424
use Symfony\Component\Config\FileLocator;
2525
use Symfony\Component\DependencyInjection\ChildDefinition;
2626
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/DataCollector.php renamed to src/Profiler/DataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpLlm\LlmChainBundle;
5+
namespace PhpLlm\LlmChainBundle\Profiler;
66

77
use PhpLlm\LlmChain\ToolBox\Metadata;
88
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
@@ -17,7 +17,7 @@
1717
final class DataCollector extends AbstractDataCollector
1818
{
1919
/**
20-
* @var list<TraceableLanguageModel>
20+
* @var TraceableLanguageModel[]
2121
*/
2222
private readonly array $llms;
2323

@@ -27,7 +27,7 @@ final class DataCollector extends AbstractDataCollector
2727
public function __construct(
2828
#[AutowireIterator('llm_chain.traceable_llm')]
2929
iterable $llms,
30-
private TraceableToolBox $toolBox,
30+
private readonly TraceableToolBox $toolBox,
3131
) {
3232
$this->llms = $llms instanceof \Traversable ? iterator_to_array($llms) : $llms;
3333
}

src/TraceableLanguageModel.php renamed to src/Profiler/TraceableLanguageModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpLlm\LlmChainBundle;
5+
namespace PhpLlm\LlmChainBundle\Profiler;
66

77
use PhpLlm\LlmChain\LanguageModel;
88
use PhpLlm\LlmChain\Message\MessageBag;

src/TraceableToolBox.php renamed to src/Profiler/TraceableToolBox.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace PhpLlm\LlmChainBundle;
5+
namespace PhpLlm\LlmChainBundle\Profiler;
66

77
use PhpLlm\LlmChain\Response\ToolCall;
8-
use PhpLlm\LlmChain\ToolBox\ToolBox;
98
use PhpLlm\LlmChain\ToolBox\ToolBoxInterface;
109

1110
/**
@@ -22,7 +21,7 @@ final class TraceableToolBox implements ToolBoxInterface
2221
public array $calls = [];
2322

2423
public function __construct(
25-
private ToolBox $toolRegistry,
24+
private ToolBoxInterface $toolRegistry,
2625
) {
2726
}
2827

src/Resources/config/services.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
use PhpLlm\LlmChain\ToolBox\ToolAnalyzer;
2626
use PhpLlm\LlmChain\ToolBox\ToolBox;
2727
use PhpLlm\LlmChain\ToolBox\ToolBoxInterface;
28-
use PhpLlm\LlmChainBundle\DataCollector;
29-
use PhpLlm\LlmChainBundle\TraceableToolBox;
28+
use PhpLlm\LlmChainBundle\Profiler\DataCollector;
29+
use PhpLlm\LlmChainBundle\Profiler\TraceableToolBox;
3030

3131
return static function (ContainerConfigurator $container) {
3232
$container->services()

0 commit comments

Comments
 (0)