diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af71020..647454b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.4', '8.5'] + php-versions: ['8.3', '8.4', '8.5'] mode: ['high-deps', 'low-deps'] fail-fast: false name: PHP ${{ matrix.php-versions }} tests with ${{ matrix.mode }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 16a7446..c085e1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ # Changelog -All releases have their changelog published in the [Releases section](https://github.com/Yousign/zdd-message-bundle/releases). +All releases have their changelog published in the [Releases section](https://github.com/Youtrust/zdd-message-bundle/releases). diff --git a/LICENSE b/LICENSE index 43123ba..065fafe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Yousign +Copyright (c) 2023-2026 Youtrust Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a91f1f2..74998dd 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,47 @@ A Symfony Bundle to use when you want to assert that messages used with Message brokers such like RabbitMQ are compliant with the Zero Downtime Deployment. +## Upgrading from `yousign/zdd-message-bundle` + +This bundle was published as `yousign/zdd-message-bundle` up to v3.3.0, under the +`Yousign\ZddMessageBundle\` namespace. Following the company rename to Youtrust, v4.0.0 moves to +`youtrust/zdd-message-bundle` and the `Youtrust\ZddMessageBundle\` namespace. There is no functional +change between v3.3.0 and v4.0.0. + +``` +$ composer remove yousign/zdd-message-bundle +$ composer require youtrust/zdd-message-bundle:^4.0 +``` + +Then replace every `Yousign\ZddMessageBundle\` prefix with `Youtrust\ZddMessageBundle\`. Beyond your PHP +code, three spots live in configuration and are easy to miss: + +- the bundle class in `config/bundles.php` +- the serializer service in `messenger.yaml`, if you use `ZddMessageMessengerSerializer` +- your own implementations of `ZddMessageConfigInterface` and `CustomMessageGeneratorInterface` + +The console commands are renamed to `youtrust:zdd-message:*`, with **no alias kept for the old names**. +They are typically invoked from CI pipelines rather than from PHP, so unlike the namespace change this one +fails at run time rather than at autoload time — update your pipelines as part of the upgrade. + +`yousign/zdd-message-bundle` is abandoned and no longer maintained. It will receive no further release of +any kind, security fixes included. + ## Requirements -- PHP 8.4 and above +- PHP 8.3 and above - Symfony 7.4 or 8 ## Getting started ### Installation First, install the bundle with composer: ``` -$ composer require yousign/zdd-message-bundle +$ composer require youtrust/zdd-message-bundle ``` Then, verify that the bundle has been registered in `config/bundles.php`: ```php -Yousign\ZddMessageBundle\ZddMessageBundle::class => ['all' => true], +Youtrust\ZddMessageBundle\ZddMessageBundle::class => ['all' => true], ``` ### Configuration @@ -27,8 +53,8 @@ Create a class to configure the messages to assert and how to create them: namespace App\Message; -use Yousign\ZddMessageBundle\Config\CustomMessageGeneratorInterface; -use Yousign\ZddMessageBundle\Config\ZddMessageConfigInterface; +use Youtrust\ZddMessageBundle\Config\CustomMessageGeneratorInterface; +use Youtrust\ZddMessageBundle\Config\ZddMessageConfigInterface; class MessageConfig implements ZddMessageConfigInterface, CustomMessageGeneratorInterface { @@ -99,9 +125,9 @@ Finish by updating the configuration with this new service in `config/packages/z Option to use different serializer. Possible options: -- `Yousign\ZddMessageBundle\Serializer\ZddMessageMessengerSerializer` (default, already configured for messenger serialization in messenger.yaml) +- `Youtrust\ZddMessageBundle\Serializer\ZddMessageMessengerSerializer` (default, already configured for messenger serialization in messenger.yaml) - Define your own serializer - - Create a service that implement `Yousign\ZddMessageBundle\Serializer\SerializerInterface` + - Create a service that implement `Youtrust\ZddMessageBundle\Serializer\SerializerInterface` - Use it in the configuration ```yaml # config/packages/zdd_message.yaml @@ -138,29 +164,29 @@ zdd_message: The bundle comes with commands to assert that your messages are compliant with the Zero Downtime Deployment: ```bash -$ bin/console yousign:zdd-message:generate # Generate serialized messages in files. -$ bin/console yousign:zdd-message:validate # Assert that the messages are compliant by deserializing them from files and call the properties. -$ bin/console yousign:zdd-message:debug # Output all tracked messages. +$ bin/console youtrust:zdd-message:generate # Generate serialized messages in files. +$ bin/console youtrust:zdd-message:validate # Assert that the messages are compliant by deserializing them from files and call the properties. +$ bin/console youtrust:zdd-message:debug # Output all tracked messages. ``` -💡 You should run `bin/console yousign:zdd-message:generate` with the production version code and `bin/console yousign:zdd-message:validate` with the version code you want to merge. +💡 You should run `bin/console youtrust:zdd-message:generate` with the production version code and `bin/console youtrust:zdd-message:validate` with the version code you want to merge. #### Example from the version you want to merge: ```bash $ git checkout [production_version] -$ bin/console yousign:zdd-message:generate +$ bin/console youtrust:zdd-message:generate $ git checkout - # Go back to the version you want to merge -$ bin/console yousign:zdd-message:validate +$ bin/console youtrust:zdd-message:validate ``` 💡 Use verbose mode to see error details ``` -$ bin/console yousign:zdd-message:validate -vv +$ bin/console youtrust:zdd-message:validate -vv --- ------------------------------------------------------------------- ---------------- # Message ZDD Compliant? --- ------------------------------------------------------------------- ---------------- -1 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage No ❌ +1 Youtrust\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage No ❌ --- ------------------------------------------------------------------- ---------------- ! [NOTE] 1 error(s) triggered. @@ -168,7 +194,7 @@ $ bin/console yousign:zdd-message:validate -vv ------------------------------------------------------------------- -------------- Message Error ------------------------------------------------------------------- -------------- -Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage Syntax error +Youtrust\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage Syntax error ------------------------------------------------------------------- -------------- ``` @@ -187,7 +213,7 @@ $ make all If you want to use your local fork to develop in your projects, you can use the link command to replace the vendor installation by your local version. ```bash -$ ./link /home/yousign/dev/my-project +$ ./link /home/youtrust/dev/my-project ``` ## Authors diff --git a/composer.json b/composer.json index 00f5f86..c5d2d7e 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { "type": "library", - "name": "yousign/zdd-message-bundle", + "name": "youtrust/zdd-message-bundle", "description": "Assert Zero Downtime Deployment compliance for messages", "license": "MIT", "keywords": ["dev", "zdd"], "minimum-stability": "stable", "prefer-stable": true, "require": { - "php": "^8.4", + "php": "^8.3", "symfony/console": "^7.4|^8.0" }, "require-dev": { @@ -21,12 +21,12 @@ }, "autoload": { "psr-4": { - "Yousign\\ZddMessageBundle\\": "src/" + "Youtrust\\ZddMessageBundle\\": "src/" } }, "autoload-dev": { "psr-4": { - "Yousign\\ZddMessageBundle\\Tests\\": "tests/" + "Youtrust\\ZddMessageBundle\\Tests\\": "tests/" } } } diff --git a/link b/link index de3e59d..d884e8f 100755 --- a/link +++ b/link @@ -11,7 +11,7 @@ require __DIR__.'/vendor/autoload.php'; use Symfony\Component\Filesystem\Filesystem; /** - * Links dependencies to components to a local clone of the Yousign/zdd-message-bundle GitHub repository. + * Links dependencies to components to a local clone of the Youtrust/zdd-message-bundle GitHub repository. * Inspired by symfony/symfony and async-aws/aws */ @@ -19,8 +19,8 @@ $copy = false !== $k = array_search('--copy', $argv, true); $copy && array_splice($argv, $k, 1); $pathToProject = $argv[1] ?? getcwd(); -if (!is_dir("$pathToProject/vendor/yousign/zdd-message-bundle")) { - echo 'Link (or copy) dependencies to components to a local clone of the main Yousign/zdd-message-bundle GitHub repository.'.PHP_EOL.PHP_EOL; +if (!is_dir("$pathToProject/vendor/youtrust/zdd-message-bundle")) { + echo 'Link (or copy) dependencies to components to a local clone of the main Youtrust/zdd-message-bundle GitHub repository.'.PHP_EOL.PHP_EOL; echo "Usage: $argv[0] /path/to/the/project".PHP_EOL; echo ' Use `--copy` to copy dependencies instead of symlink'.PHP_EOL.PHP_EOL; echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL; @@ -31,9 +31,9 @@ $filesystem = new Filesystem(); $packages[json_decode(file_get_contents(__DIR__.'/composer.json'))->name] = __DIR__; -$dir = "$pathToProject/vendor/yousign/zdd-message-bundle"; +$dir = "$pathToProject/vendor/youtrust/zdd-message-bundle"; -$package = 'yousign/zdd-message-bundle'; +$package = 'youtrust/zdd-message-bundle'; if (!$copy && is_link($dir)) { echo "\"$package\" is already a symlink, skipping.".PHP_EOL; exit; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d379603..99a4580 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,7 @@ - + diff --git a/src/Assert/ZddMessageAsserter.php b/src/Assert/ZddMessageAsserter.php index c0ea89c..0015980 100644 --- a/src/Assert/ZddMessageAsserter.php +++ b/src/Assert/ZddMessageAsserter.php @@ -1,11 +1,11 @@ new Locale('fr'), - 'Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Input\Status' => Status::DRAFT, + 'Youtrust\ZddMessageBundle\Tests\Fixtures\App\Messages\Input\Status' => Status::DRAFT, DummyMessageWithNullableNumberProperty::class => new DummyMessageWithNullableNumberProperty('content'), default => null, }; diff --git a/tests/Fixtures/App/Messages/DummyCustomMessage.php b/tests/Fixtures/App/Messages/DummyCustomMessage.php index b614e4f..340a2f6 100644 --- a/tests/Fixtures/App/Messages/DummyCustomMessage.php +++ b/tests/Fixtures/App/Messages/DummyCustomMessage.php @@ -1,6 +1,6 @@ command = new CommandTester((new Application($kernel))->find('yousign:zdd-message:generate')); + $this->command = new CommandTester((new Application($kernel))->find('youtrust:zdd-message:generate')); $customBasePathFile = $kernel->getContainer()->getParameter('custom_path_file'); - $this->serializedMessagesDir = $customBasePathFile.'/Yousign/ZddMessageBundle/Tests/Fixtures/App/Messages'; + $this->serializedMessagesDir = $customBasePathFile.'/Youtrust/ZddMessageBundle/Tests/Fixtures/App/Messages'; } protected function tearDown(): void @@ -42,16 +42,16 @@ public function testThatCommandIsSuccessful(): void $this->assertSerializedFilesExist($this->serializedMessagesDir); $expectedResult = <<assertSame(trim($expectedResult), trim($this->command->getDisplay())); diff --git a/tests/Func/ListZddMessageCommandTest.php b/tests/Func/ListZddMessageCommandTest.php index a2681e4..3198905 100644 --- a/tests/Func/ListZddMessageCommandTest.php +++ b/tests/Func/ListZddMessageCommandTest.php @@ -1,6 +1,6 @@ command = new CommandTester((new Application($kernel))->find('yousign:zdd-message:debug')); + $this->command = new CommandTester((new Application($kernel))->find('youtrust:zdd-message:debug')); } public function testCommandIsSuccess(): void @@ -23,16 +23,16 @@ public function testCommandIsSuccess(): void $this->command->execute([]); $expectedResult = <<assertSame(trim($expectedResult), trim($this->command->getDisplay())); diff --git a/tests/Func/ValidateZddMessageCommandTest.php b/tests/Func/ValidateZddMessageCommandTest.php index 5e1c044..cb35a3c 100644 --- a/tests/Func/ValidateZddMessageCommandTest.php +++ b/tests/Func/ValidateZddMessageCommandTest.php @@ -1,6 +1,6 @@ command = new CommandTester((new Application(self::$kernel))->find('yousign:zdd-message:validate')); + $this->command = new CommandTester((new Application(self::$kernel))->find('youtrust:zdd-message:validate')); $customBasePathFile = $kernel->getContainer()->getParameter('custom_path_file'); - $this->serializedMessagesDir = $customBasePathFile.'/Yousign/ZddMessageBundle/Tests/Fixtures/App/Messages'; + $this->serializedMessagesDir = $customBasePathFile.'/Youtrust/ZddMessageBundle/Tests/Fixtures/App/Messages'; MessageConfig::$messagesToAssert = [ DummyMessage::class, @@ -56,11 +56,11 @@ public function testThatCommandIsSuccessful(): void $this->command->assertCommandIsSuccessful(); $expectedResult = <<assertSame(trim($expectedResult), trim($this->command->getDisplay())); @@ -75,11 +75,11 @@ public function testThatCommandIsSuccessfulEvenIfTheSerializedMessageDoesNotExis $this->command->assertCommandIsSuccessful(); $expectedResult = <<assertSame(trim($expectedResult), trim($this->command->getDisplay())); @@ -109,11 +109,11 @@ public function testThatCommandFailsWhenMessageIsNotZddCompliant(): void self::assertEquals(Command::FAILURE, $this->command->getStatusCode()); $expectedResult = <<command->getStatusCode()); $expectedResult = <<assertSame( @@ -170,7 +170,7 @@ private function getSerializedMessageForPreviousVersionOfDummyMessageWithNumberP { return <<has('content')); self::assertTrue($propertyList->has('number')); $this->expectException(\LogicException::class); - $this->expectExceptionMessage('⚠️ The properties "number" in class "Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage" seems to have been removed'); + $this->expectExceptionMessage('⚠️ The properties "number" in class "Youtrust\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage" seems to have been removed'); $sut = $this->getSut(); $sut->assert(DummyMessage::class, $serializedMessage, $propertyList); @@ -136,7 +136,7 @@ public function testItThrowsExceptionForInvalidIntegrationDueToPropertyTypeMisma JSON ); $this->expectException(\LogicException::class); - $this->expectExceptionMessage('Error for property "content" in class "Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage", the type mismatch between the old and the new version of class. Please verify your integration.'); + $this->expectExceptionMessage('Error for property "content" in class "Youtrust\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessage", the type mismatch between the old and the new version of class. Please verify your integration.'); $sut = $this->getSut(); $sut->assert(DummyMessage::class, $serializedMessage, $propertyList); diff --git a/tests/Unit/ZddMessageFactoryTest.php b/tests/Unit/ZddMessageFactoryTest.php index bc83d0c..8544d25 100644 --- a/tests/Unit/ZddMessageFactoryTest.php +++ b/tests/Unit/ZddMessageFactoryTest.php @@ -1,20 +1,20 @@