Skip to content

Commit

Permalink
chore: upgrade CI matrix (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil authored Sep 26, 2024
1 parent 1f78317 commit 36329a1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
matrix:
php: [8.1, 8.2, 8.3]
deps: [highest]
symfony: [5.4.*, 6.3.*, 6.4.*, 7.0.*]
symfony: [5.4.*, 6.4.*, 7.1.*]
include:
- php: 8.1
deps: lowest
symfony: '*'
exclude:
- php: 8.1
symfony: 7.0.*
symfony: 7.1.*
steps:
- uses: zenstruck/.github@php-test-symfony
with:
Expand Down
4 changes: 2 additions & 2 deletions src/Stamp/AvailableAtStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function __construct(private \DateTimeImmutable $availableAt)
public static function fromDelayStamp(DelayStamp $delayStamp, \DateTimeImmutable $now): self
{
return new self(
$now->modify(\sprintf('%s%d seconds',
$now->modify(\sprintf('%s%d milliseconds',
$delayStamp->getDelay() > 0 ? '+' : '-',
\abs($delayStamp->getDelay() / 1000)
\abs($delayStamp->getDelay())
))
);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Fixture/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use Symfony\Component\Clock\Clock;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Messenger\Retry\MultiplierRetryStrategy;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Zenstruck\Messenger\Test\Tests\Fixture\Messenger\MessageA;
Expand Down Expand Up @@ -50,6 +52,9 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
if (\class_exists(Clock::class) && !$c->has(\Psr\Clock\ClockInterface::class)) {
$c->register(\Psr\Clock\ClockInterface::class, Clock::class)->setPublic(true);
}

$this->registerRetryStrategyWithoutJitter($c);

}

/**
Expand All @@ -65,4 +70,16 @@ protected function configureRoutes($routes): void // @phpstan-ignore-line

$routes->add('dispatch', '/dispatch')->controller('kernel::dispatch');
}

// Jitter makes harder the assertions on retries
private function registerRetryStrategyWithoutJitter(ContainerBuilder $c): void
{
$definition = $c->register('messenger_test_retry_strategy', MultiplierRetryStrategy::class)
->setArgument('$maxRetries', 1);

// jitter property appeared in symfony/messenger 7.1
if ((new \ReflectionClass(MultiplierRetryStrategy::class))->hasProperty('jitter')) {
$definition->setArgument('$jitter', 0);
}
}
}
2 changes: 2 additions & 0 deletions tests/Fixture/config/delay_stamp_disabled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ framework:
transports:
async:
dsn: test://?disable_retries=false&support_delay_stamp=false
retry_strategy:
service: messenger_test_retry_strategy
routing:
Zenstruck\Messenger\Test\Tests\Fixture\Messenger\MessageA: [async]
Zenstruck\Messenger\Test\Tests\Fixture\Messenger\MessageB: [async]
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixture/config/multi_bus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ framework:
transports:
async:
dsn: test://?disable_retries=false&support_delay_stamp=true
retry_strategy:
service: messenger_test_retry_strategy
routing:
Zenstruck\Messenger\Test\Tests\Fixture\Messenger\MessageA: async
default_bus: bus_c
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixture/config/multi_transport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ framework:
async3: in-memory://
async4:
dsn: test://?disable_retries=false&support_delay_stamp=true
retry_strategy:
service: messenger_test_retry_strategy
async5:
dsn: test://?intercept=false&catch_exceptions=false&test_serialization=true&support_delay_stamp=true
routing:
Expand Down
8 changes: 1 addition & 7 deletions tests/InteractsWithMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,6 @@ public function can_enable_retries(): void

$clock->sleep(1);
$this->transport('async4')->process()->rejected()->assertContains(MessageA::class, 2);

$clock->sleep(2);
$this->transport('async4')->process()->rejected()->assertContains(MessageA::class, 3);

$clock->sleep(4);
$this->transport('async4')->process()->rejected()->assertContains(MessageA::class, 4);
}

/**
Expand All @@ -922,7 +916,7 @@ public function can_enable_retries_without_delay_stamp(): void

self::getContainer()->get(MessageBusInterface::class)->dispatch(new MessageA(true));

$this->transport('async')->process()->rejected()->assertContains(MessageA::class, 4);
$this->transport('async')->process()->rejected()->assertContains(MessageA::class, 2);
}

/**
Expand Down

0 comments on commit 36329a1

Please sign in to comment.