Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade CI matrix #92

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: upgrade CI matrix
  • Loading branch information
nikophil committed Sep 26, 2024
commit ae2a41a4f77da518741831c655caf00605305ac2
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
Loading