From 877168a3bf839002aeff24e926420fd98bff7cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Sep 2025 22:38:21 +0200 Subject: [PATCH 1/8] Refactor as a single-class bundle --- .gitignore | 1 + composer.json | 9 +- rector.php | 11 ++- src/DependencyInjection/Configuration.php | 36 -------- src/DependencyInjection/OpenAIExtension.php | 39 -------- src/OpenAIBundle.php | 49 ++++++++++- src/Resources/config/services.php | 28 ------ .../OpenAIExtensionTest.php | 52 ----------- tests/OpenAIBundleTest.php | 88 +++++++++++++++++++ 9 files changed, 148 insertions(+), 165 deletions(-) delete mode 100644 src/DependencyInjection/Configuration.php delete mode 100644 src/DependencyInjection/OpenAIExtension.php delete mode 100644 src/Resources/config/services.php delete mode 100644 tests/DependencyInjection/OpenAIExtensionTest.php create mode 100644 tests/OpenAIBundleTest.php diff --git a/.gitignore b/.gitignore index 8e954e3..9b27164 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ /composer.lock /phpunit.xml /vendor/ +/var/ *.swp *.swo diff --git a/composer.json b/composer.json index 7639d3a..7fdeb08 100644 --- a/composer.json +++ b/composer.json @@ -27,9 +27,10 @@ }, "require-dev": { "laravel/pint": "^1.18.1", - "phpstan/phpstan": "^1.12.6", - "rector/rector": "^0.14.8", - "symfony/phpunit-bridge": "^5.4|^6.3|^7.1.4" + "phpstan/phpstan": "^2.1.2", + "rector/rector": "^2.1.5", + "symfony/phpunit-bridge": "^5.4|^6.3|^7.1.4", + "symfony/framework-bundle": "^5.4|^6.3|^7.1" }, "autoload": { "psr-4": { @@ -53,7 +54,7 @@ "scripts": { "lint": "pint -v", "refactor": "rector --debug", - "test:lint": "pint --test -v", + "test:lint": "pint --test -v ./src ./tests", "test:types": "phpstan analyse --ansi", "test:unit": "simple-phpunit --colors=always", "test": [ diff --git a/rector.php b/rector.php index 2293079..622e4e2 100644 --- a/rector.php +++ b/rector.php @@ -4,16 +4,15 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Php81\Rector\Array_\FirstClassCallableRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ __DIR__.'/src', - ]); - - $rectorConfig->skip([ - __DIR__.'/src/Resources/config/', + __DIR__.'/tests', + __DIR__.'/rector.php', ]); $rectorConfig->rules([ @@ -28,4 +27,8 @@ SetList::TYPE_DECLARATION, SetList::PRIVATIZATION, ]); + + $rectorConfig->skip([ + FirstClassCallableRector::class, + ]); }; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php deleted file mode 100644 index b22bb5b..0000000 --- a/src/DependencyInjection/Configuration.php +++ /dev/null @@ -1,36 +0,0 @@ -getRootNode(); - - assert($rootNode instanceof ArrayNodeDefinition); - - $children = $rootNode->children(); - - assert($children instanceof NodeBuilder); - - $children->scalarNode('api_key')->defaultValue('%env(OPENAI_API_KEY)%')->end(); - $children->scalarNode('organization')->defaultValue('%env(default::OPENAI_ORGANIZATION)%')->end(); - - return $treeBuilder; - } -} diff --git a/src/DependencyInjection/OpenAIExtension.php b/src/DependencyInjection/OpenAIExtension.php deleted file mode 100644 index 36dc837..0000000 --- a/src/DependencyInjection/OpenAIExtension.php +++ /dev/null @@ -1,39 +0,0 @@ -> $configs - */ - public function load(array $configs, ContainerBuilder $container): void - { - $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.php'); - - $configuration = $this->getConfiguration($configs, $container); - - assert($configuration instanceof ConfigurationInterface); - - $config = $this->processConfiguration($configuration, $configs); - - $definition = $container->getDefinition(Factory::class); - $definition->addMethodCall('withApiKey', [$config['api_key']]); - if ($config['organization']) { - $definition->addMethodCall('withOrganization', [$config['organization']]); - } - } -} diff --git a/src/OpenAIBundle.php b/src/OpenAIBundle.php index c14715b..8cfb331 100644 --- a/src/OpenAIBundle.php +++ b/src/OpenAIBundle.php @@ -4,6 +4,51 @@ namespace OpenAI\Symfony; -use Symfony\Component\HttpKernel\Bundle\Bundle; +use OpenAI\Client; +use OpenAI\Contracts\ClientContract; +use OpenAI\Factory; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; +use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symfony\Component\HttpClient\Psr18Client; +use Symfony\Component\HttpKernel\Bundle\AbstractBundle; -final class OpenAIBundle extends Bundle {} +use function Symfony\Component\DependencyInjection\Loader\Configurator\service; + +final class OpenAIBundle extends AbstractBundle +{ + protected string $extensionAlias = 'openai'; + + public function configure(DefinitionConfigurator $definition): void + { + $root = $definition->rootNode(); + assert($root instanceof ArrayNodeDefinition); + $children = $root->children(); + $children->scalarNode('api_key')->defaultValue('%env(OPENAI_API_KEY)%'); + $children->scalarNode('organization')->defaultValue('%env(default::OPENAI_ORGANIZATION)%'); + } + + /** + * @param array{api_key: string, organization: string} $config + */ + public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void + { + $container->services() + ->set('openai.http_client', Psr18Client::class) + ->arg(0, service('http_client')) + + ->set(Factory::class) + ->factory([\OpenAI::class, 'factory']) + ->call('withHttpClient', [service('openai.http_client')]) + ->call('withHttpHeader', ['OpenAI-Beta', 'assistants=v2']) + ->call('withApiKey', [$config['api_key']]) + ->call('withOrganization', [$config['organization']]) + + ->set(Client::class) + ->factory([service(Factory::class), 'make']) + + ->alias(ClientContract::class, Client::class) + ->alias('openai', Client::class); + } +} diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php deleted file mode 100644 index 67fee2f..0000000 --- a/src/Resources/config/services.php +++ /dev/null @@ -1,28 +0,0 @@ -services() - ->set('openai.http_client', Psr18Client::class) - ->arg(0, service('http_client')) - - ->set(Factory::class) - ->factory([OpenAI::class, 'factory']) - ->call('withHttpClient', [service('openai.http_client')]) - ->call('withHttpHeader', ['OpenAI-Beta', 'assistants=v2']) - - ->set(Client::class) - ->factory([service(Factory::class), 'make']) - - ->alias(ClientContract::class, Client::class) - ->alias('openai', Client::class); -}; diff --git a/tests/DependencyInjection/OpenAIExtensionTest.php b/tests/DependencyInjection/OpenAIExtensionTest.php deleted file mode 100644 index 6514b13..0000000 --- a/tests/DependencyInjection/OpenAIExtensionTest.php +++ /dev/null @@ -1,52 +0,0 @@ - 200, - 'response_headers' => [ - 'content-type' => 'application/json', - 'x-request-id' => '0123456789abcdef0123456789abcdef', - ], - ]); - }); - - $container = new ContainerBuilder; - $container->set('http_client', $httpClient); - - $extension = new OpenAIExtension; - $extension->load([ - 'openai' => [ - 'api_key' => 'pk-123456789', - ], - ], $container); - - $openai = $container->get('openai'); - self::assertInstanceOf(Client::class, $openai); - - $response = $openai->files()->delete('file.txt'); - self::assertSame('file.txt', $response->id); - - self::assertSame($openai, $container->get(ClientContract::class), 'Alias for the ClientContract interface'); - } -} diff --git a/tests/OpenAIBundleTest.php b/tests/OpenAIBundleTest.php new file mode 100644 index 0000000..5c040ce --- /dev/null +++ b/tests/OpenAIBundleTest.php @@ -0,0 +1,88 @@ +extension('framework', [ + 'secret' => 'S0ME_SECRET', + ]); + + $container->extension('openai', [ + 'api_key' => 'pk-123456789', + 'organization' => 'org-123456789', + ]); + + $container->services() + ->set('http_client', MockHttpClient::class) + ->public() + + ->set('tested_services', \ArrayObject::class) + ->args([[ + 'openai' => service('openai'), + Client::class => service(Client::class), + ClientContract::class => service(ClientContract::class), + ]]) + ->public(); + } + }; + + // Using a mock to test the service configuration + $httpClient = new MockHttpClient(function (string $method, string $url, array $options = []): MockResponse { + self::assertSame('DELETE', $method); + self::assertSame('https://api.openai.com/v1/files/file.txt', $url); + self::assertContains('Authorization: Bearer pk-123456789', $options['headers']); + + return new MockResponse('{"id":"file.txt","object":"file","deleted":true}', [ + 'http_code' => 200, + 'response_headers' => [ + 'content-type' => 'application/json', + 'x-request-id' => '0123456789abcdef0123456789abcdef', + ], + ]); + }); + + $kernel->boot(); + $container = $kernel->getContainer(); + $container->set('http_client', $httpClient); + + $testedServices = $container->get('tested_services'); + assert($testedServices instanceof \ArrayObject); + $openai = $testedServices['openai']; + self::assertInstanceOf(Client::class, $openai); + self::assertSame($openai, $testedServices[Client::class]); + self::assertSame($openai, $testedServices[ClientContract::class]); + + $response = $openai->files()->delete('file.txt'); + self::assertSame('file.txt', $response->id); + } +} From 33264a20ae6e672b19774db6eeb8e3d952438777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Sep 2025 23:02:07 +0200 Subject: [PATCH 2/8] Drop support for unsupported Symfony versions --- .github/workflows/tests.yml | 13 ++++--------- composer.json | 16 ++++++++-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a434b17..4bcf07c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,15 +10,10 @@ jobs: fail-fast: true matrix: php: [8.2, 8.3, 8.4] - symfony: [5.4.*, 6.4.*, 7.0.*] - dependency-version: [prefer-lowest, prefer-stable] - exclude: - - php: 8.4 - symfony: 5.4.* - - php: 8.4 - symfony: 6.4.* - - php: 8.4 - symfony: 7.0.* + symfony: [6.4.*, 7.3.*] + dependency-version: [prefer-stable] + include: + - { php: 8.2, symfony: 6.4.*, dependency-version: prefer-lowest } name: Tests P${{ matrix.php }} - SF${{ matrix.symfony }} - ubuntu-latest - ${{ matrix.dependency-version }} steps: diff --git a/composer.json b/composer.json index 7fdeb08..6fa4471 100644 --- a/composer.json +++ b/composer.json @@ -20,17 +20,17 @@ "openai-php/client": "^0.17.0", "psr/http-client": "^1.0.3", "psr/http-factory": "^1.1.0", - "symfony/config": "^5.4|^6.3|^7.1.1", - "symfony/dependency-injection": "^5.4|^6.3|^7.1.5", - "symfony/http-client": "^5.4|^6.3|^7.1.5", - "symfony/http-kernel": "^5.4|^6.3|^7.1.5" + "symfony/config": "^6.4|^7.3", + "symfony/dependency-injection": "^6.4|^7.3", + "symfony/http-client": "^6.4|^7.3", + "symfony/http-kernel": "^6.4|^7.3" }, "require-dev": { - "laravel/pint": "^1.18.1", - "phpstan/phpstan": "^2.1.2", + "laravel/pint": "^1.24.0", + "phpstan/phpstan": "^2.1.22", "rector/rector": "^2.1.5", - "symfony/phpunit-bridge": "^5.4|^6.3|^7.1.4", - "symfony/framework-bundle": "^5.4|^6.3|^7.1" + "symfony/phpunit-bridge": "^6.4|^7.3", + "symfony/framework-bundle": "^6.4|^7.3" }, "autoload": { "psr-4": { From c3f8ec4afa3c9d2a9a9adba1fb31a7338b7b2604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Sep 2025 23:05:58 +0200 Subject: [PATCH 3/8] Use symfony flex to set Symfony version --- .github/workflows/tests.yml | 12 ++++-------- composer.json | 2 +- tests/OpenAIBundleTest.php | 3 +++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bcf07c..13c71c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,6 +15,9 @@ jobs: include: - { php: 8.2, symfony: 6.4.*, dependency-version: prefer-lowest } + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-version }} + name: Tests P${{ matrix.php }} - SF${{ matrix.symfony }} - ubuntu-latest - ${{ matrix.dependency-version }} steps: @@ -33,14 +36,7 @@ jobs: php-version: ${{ matrix.php }} extensions: dom, mbstring, zip coverage: none - - - name: Require Symfony Version - run: > - composer require - "symfony/config:${{ matrix.symfony }}" - "symfony/dependency-injection:${{ matrix.symfony }}" - "symfony/http-kernel:${{ matrix.symfony }}" - --no-interaction --no-update + tools: flex - name: Install Composer dependencies run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist diff --git a/composer.json b/composer.json index 6fa4471..3d73147 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "laravel/pint": "^1.24.0", "phpstan/phpstan": "^2.1.22", "rector/rector": "^2.1.5", - "symfony/phpunit-bridge": "^6.4|^7.3", + "symfony/phpunit-bridge": "^6.4.25|^7.3", "symfony/framework-bundle": "^6.4|^7.3" }, "autoload": { diff --git a/tests/OpenAIBundleTest.php b/tests/OpenAIBundleTest.php index 5c040ce..960339f 100644 --- a/tests/OpenAIBundleTest.php +++ b/tests/OpenAIBundleTest.php @@ -35,6 +35,9 @@ protected function configureContainer(ContainerConfigurator $container): void { $container->extension('framework', [ 'secret' => 'S0ME_SECRET', + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], ]); $container->extension('openai', [ From 568c0bd4921788ca0d16a42f269daecad9fbc822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Sep 2025 23:35:56 +0200 Subject: [PATCH 4/8] Update config docs --- README.md | 14 ++++++++++++++ src/OpenAIBundle.php | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3d6e4d3..e8fbc1b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ OPENAI_API_KEY=sk-... OPENAI_ORGANIZATION=... ``` +For more configuration options, take a look at the [Configuration Reference](#configuration-reference). + Finally, you may use the `openai` service to access the OpenAI API: ```php @@ -57,6 +59,18 @@ echo $result['choices'][0]['text']; // an open-source, widely-used, server-side For usage examples, take a look at the [openai-php/client](https://github.com/openai-php/client) repository. +## Configuration Reference + +The bundle provides the following configuration options, which you can set in your `config/packages/openai.yaml` file: + +```yaml +openai: + api_key: '%env(OPENAI_API_KEY)%' # Your OpenAI API key (required) + organization: '%env(OPENAI_ORGANIZATION)%' # Your OpenAI organization ID (optional) + project: 'proj_...' # The project ID (optional) + base_uri: 'api.openai.com/v1' # The base URI for the OpenAI API (optional) +``` + --- OpenAI PHP for Symfony is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**. diff --git a/src/OpenAIBundle.php b/src/OpenAIBundle.php index 8cfb331..9d78a06 100644 --- a/src/OpenAIBundle.php +++ b/src/OpenAIBundle.php @@ -25,29 +25,54 @@ public function configure(DefinitionConfigurator $definition): void $root = $definition->rootNode(); assert($root instanceof ArrayNodeDefinition); $children = $root->children(); - $children->scalarNode('api_key')->defaultValue('%env(OPENAI_API_KEY)%'); - $children->scalarNode('organization')->defaultValue('%env(default::OPENAI_ORGANIZATION)%'); + $children + ->scalarNode('api_key') + ->defaultValue('%env(OPENAI_API_KEY)%') + ->info('OpenAI API Key used to authenticate with the OpenAI API') + ->isRequired(); + $children + ->scalarNode('organization') + ->info('OpenAI API Organization used to authenticate with the OpenAI API') + ->defaultValue('%env(default::OPENAI_ORGANIZATION)%') + ->info(''); + $children + ->scalarNode('project') + ->defaultNull() + ->info('OpenAI API project'); + $children + ->scalarNode('base_uri') + ->defaultNull() + ->info('OpenAI API base URL used to make requests. Defaults to: api.openai.com/v1'); } /** - * @param array{api_key: string, organization: string} $config + * @param array{api_key: string, organization: string, project: ?string, base_uri: ?string} $config */ public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void { $container->services() ->set('openai.http_client', Psr18Client::class) - ->arg(0, service('http_client')) + ->arg(0, service('http_client')); + $factory = $container->services() ->set(Factory::class) ->factory([\OpenAI::class, 'factory']) ->call('withHttpClient', [service('openai.http_client')]) ->call('withHttpHeader', ['OpenAI-Beta', 'assistants=v2']) ->call('withApiKey', [$config['api_key']]) - ->call('withOrganization', [$config['organization']]) + ->call('withOrganization', [$config['organization']]); + if ($config['project']) { + $factory->call('withProject', [$config['project']]); + } + if ($config['base_uri']) { + $factory->call('withBaseUri', [$config['base_uri']]); + } + $container->services() ->set(Client::class) - ->factory([service(Factory::class), 'make']) + ->factory([service(Factory::class), 'make']); + $container->services() ->alias(ClientContract::class, Client::class) ->alias('openai', Client::class); } From 64216a06aa6022b909f50fd10de15921ae58f9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Sep 2025 23:39:22 +0200 Subject: [PATCH 5/8] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22f06ac..a5a932b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.17.0 +### Changed +- Refactored into a single `OpenAI\Symfony\OpenAIBundle` class +- Add `project` and `base_uri` configuration options +- Drop support for unsupported Symfony versions. Now requires Symfony 6.4 or 7.3+ + ## v0.12.0 (2025-05-06) ### Changed - Changed underlying `openai/client` package version to 0.12.0 From 52a3e685e5f3f3faed08431f55194c4a885fb24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 5 Sep 2025 09:55:53 +0200 Subject: [PATCH 6/8] Test with Symfony 8 --- .github/workflows/tests.yml | 10 +++++++--- CHANGELOG.md | 1 + composer.json | 12 ++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13c71c5..8e46e6b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,9 +11,11 @@ jobs: matrix: php: [8.2, 8.3, 8.4] symfony: [6.4.*, 7.3.*] - dependency-version: [prefer-stable] + dependency-version: [stable] include: - - { php: 8.2, symfony: 6.4.*, dependency-version: prefer-lowest } + - { php: 8.2, symfony: 6.4.*, dependency-version: lowest } + - { php: 8.3, symfony: 7.4.*, dependency-version: highest } + - { php: 8.4, symfony: 8.0.*, dependency-version: highest } env: SYMFONY_REQUIRE: ${{ matrix.symfony-version }} @@ -39,7 +41,9 @@ jobs: tools: flex - name: Install Composer dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist + uses: ramsey/composer-install@v2 + with: + dependency-versions: ${{ matrix.php }} - name: Integration Tests run: php ./vendor/bin/simple-phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a932b..2d7b52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Refactored into a single `OpenAI\Symfony\OpenAIBundle` class - Add `project` and `base_uri` configuration options - Drop support for unsupported Symfony versions. Now requires Symfony 6.4 or 7.3+ +- Add support for Symfony 8.0 ## v0.12.0 (2025-05-06) ### Changed diff --git a/composer.json b/composer.json index 3d73147..e7b26ce 100644 --- a/composer.json +++ b/composer.json @@ -20,17 +20,17 @@ "openai-php/client": "^0.17.0", "psr/http-client": "^1.0.3", "psr/http-factory": "^1.1.0", - "symfony/config": "^6.4|^7.3", - "symfony/dependency-injection": "^6.4|^7.3", - "symfony/http-client": "^6.4|^7.3", - "symfony/http-kernel": "^6.4|^7.3" + "symfony/config": "^6.4|^7.3|^8.0", + "symfony/dependency-injection": "^6.4|^7.3|^8.0", + "symfony/http-client": "^6.4|^7.3|^8.0", + "symfony/http-kernel": "^6.4|^7.3|^8.0" }, "require-dev": { "laravel/pint": "^1.24.0", "phpstan/phpstan": "^2.1.22", "rector/rector": "^2.1.5", - "symfony/phpunit-bridge": "^6.4.25|^7.3", - "symfony/framework-bundle": "^6.4|^7.3" + "symfony/phpunit-bridge": "^6.4.25|^7.3|^8.0", + "symfony/framework-bundle": "^6.4|^7.3|^8.0" }, "autoload": { "psr-4": { From 1b3ee3392e25c479d3316e081037c0ce551f8c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 5 Sep 2025 10:16:45 +0200 Subject: [PATCH 7/8] composer cache handled by ramsey/composer-install --- .github/workflows/tests.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8e46e6b..2d5040d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,27 +11,21 @@ jobs: matrix: php: [8.2, 8.3, 8.4] symfony: [6.4.*, 7.3.*] - dependency-version: [stable] + dependency: [stable] include: - - { php: 8.2, symfony: 6.4.*, dependency-version: lowest } - - { php: 8.3, symfony: 7.4.*, dependency-version: highest } - - { php: 8.4, symfony: 8.0.*, dependency-version: highest } + - { php: 8.2, symfony: 6.4.*, dependency: lowest } + - { php: 8.3, symfony: 7.4.*, dependency: highest } + - { php: 8.4, symfony: 8.0.*, dependency: highest } env: - SYMFONY_REQUIRE: ${{ matrix.symfony-version }} + SYMFONY_REQUIRE: ${{ matrix.symfony }} - name: Tests P${{ matrix.php }} - SF${{ matrix.symfony }} - ubuntu-latest - ${{ matrix.dependency-version }} + name: Tests P${{ matrix.php }} - SF${{ matrix.symfony }} - ubuntu-latest - ${{ matrix.dependency }} steps: - name: Checkout uses: actions/checkout@v5 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-SF${{ matrix.symfony }}-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} - - name: Setup PHP uses: shivammathur/setup-php@v2 with: From 1ba6912b513109ba849f28a899ab5dc4109e4f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 2 Oct 2025 15:25:23 +0200 Subject: [PATCH 8/8] Install latest Symfony when possible --- .github/workflows/tests.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2d5040d..87668e5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,12 +10,11 @@ jobs: fail-fast: true matrix: php: [8.2, 8.3, 8.4] - symfony: [6.4.*, 7.3.*] + symfony: [^6.4, false] dependency: [stable] include: - - { php: 8.2, symfony: 6.4.*, dependency: lowest } - - { php: 8.3, symfony: 7.4.*, dependency: highest } - - { php: 8.4, symfony: 8.0.*, dependency: highest } + - { php: 8.4, symfony: ^7.4, dependency: highest } + - { php: 8.4, symfony: ^8.0, dependency: highest } env: SYMFONY_REQUIRE: ${{ matrix.symfony }} @@ -37,7 +36,7 @@ jobs: - name: Install Composer dependencies uses: ramsey/composer-install@v2 with: - dependency-versions: ${{ matrix.php }} + dependency-versions: ${{ matrix.dependency }} - name: Integration Tests run: php ./vendor/bin/simple-phpunit