Skip to content

Commit

Permalink
Merge branch '5.x' into php84
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone authored Nov 12, 2024
2 parents b9fd66d + a48d242 commit ea857d1
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- 'test-improvements'
- '*.x'
pull_request:
schedule:
Expand Down Expand Up @@ -55,7 +56,7 @@ jobs:

- name: Install dependencies
run: |
composer update --prefer-dist --no-interaction --no-progress --with=illuminate/contracts:^${{ matrix.laravel }}
composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^${{ matrix.laravel }}"
- name: Execute tests (Deprecations)
run: vendor/bin/phpunit --display-deprecations --fail-on-deprecation
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Release Notes

## [Unreleased](https://github.com/laravel/horizon/compare/v5.29.1...5.x)
## [Unreleased](https://github.com/laravel/horizon/compare/v5.29.2...5.x)

## [v5.29.2](https://github.com/laravel/horizon/compare/v5.29.1...v5.29.2) - 2024-10-16

* [5.x] Use `#[\Override]` PHP Attribute to detect breaking changes by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/horizon/pull/1506
* Improvement: Wont spawn extra queues by [@alexmontoanelli](https://github.com/alexmontoanelli) in https://github.com/laravel/horizon/pull/1508

## [v5.29.1](https://github.com/laravel/horizon/compare/v5.29.0...v5.29.1) - 2024-10-08

Expand Down
9 changes: 1 addition & 8 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Upgrade Guide

With every upgrade, make sure to publish Horizon's assets and clear the view cache:

php artisan horizon:publish

php artisan view:clear

# Upgrade Guide

## Upgrading To 5.0 From 4.x

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"nesbot/carbon": "^2.17|^3.0",
"ramsey/uuid": "^4.0",
"symfony/console": "^6.0|^7.0",
"symfony/process": "^6.0|^7.0",
"symfony/error-handler": "^6.0|^7.0"
"symfony/error-handler": "^6.0|^7.0",
"symfony/polyfill-php83": "^1.28",
"symfony/process": "^6.0|^7.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
Expand Down
4 changes: 3 additions & 1 deletion src/ProvisioningPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public function deploy($environment)
}

foreach ($supervisors as $supervisor => $options) {
$this->add($options);
if ($options->maxProcesses > 0) {
$this->add($options);
}
}

event(new MasterSupervisorDeployed($this->master));
Expand Down
9 changes: 9 additions & 0 deletions src/RedisQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function readyNow($queue = null)
* @param string|null $queue
* @return mixed
*/
#[\Override]
public function push($job, $data = '', $queue = null)
{
return $this->enqueueUsing(
Expand All @@ -62,6 +63,7 @@ function ($payload, $queue) use ($job) {
* @param array $options
* @return mixed
*/
#[\Override]
public function pushRaw($payload, $queue = null, array $options = [])
{
$payload = (new JobPayload($payload))->prepare($this->lastPushed);
Expand All @@ -81,6 +83,7 @@ public function pushRaw($payload, $queue = null, array $options = [])
* @param mixed $data
* @return array
*/
#[\Override]
protected function createPayloadArray($job, $queue, $data = '')
{
$payload = parent::createPayloadArray($job, $queue, $data);
Expand All @@ -99,6 +102,7 @@ protected function createPayloadArray($job, $queue, $data = '')
* @param string $queue
* @return mixed
*/
#[\Override]
public function later($delay, $job, $data = '', $queue = null)
{
$payload = (new JobPayload($this->createPayload($job, $queue, $data)))->prepare($job)->value;
Expand Down Expand Up @@ -126,8 +130,10 @@ function ($payload, $queue, $delay) {
* Pop the next job off of the queue.
*
* @param string $queue
* @param int $index
* @return \Illuminate\Contracts\Queue\Job|null
*/
#[\Override]
public function pop($queue = null, $index = 0)
{
return tap(parent::pop($queue, $index), function ($result) use ($queue) {
Expand All @@ -144,6 +150,7 @@ public function pop($queue = null, $index = 0)
* @param string $to
* @return void
*/
#[\Override]
public function migrateExpiredJobs($from, $to)
{
return tap(parent::migrateExpiredJobs($from, $to), function ($jobs) use ($to) {
Expand All @@ -158,6 +165,7 @@ public function migrateExpiredJobs($from, $to)
* @param \Illuminate\Queue\Jobs\RedisJob $job
* @return void
*/
#[\Override]
public function deleteReserved($queue, $job)
{
parent::deleteReserved($queue, $job);
Expand All @@ -173,6 +181,7 @@ public function deleteReserved($queue, $job)
* @param int $delay
* @return void
*/
#[\Override]
public function deleteAndRelease($queue, $job, $delay)
{
parent::deleteAndRelease($queue, $job, $delay);
Expand Down
1 change: 1 addition & 0 deletions src/SupervisorProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function __construct(SupervisorOptions $options, $process, Closure $outpu
*
* @return void
*/
#[\Override]
public function monitor()
{
if (! $this->process->isStarted()) {
Expand Down
18 changes: 2 additions & 16 deletions tests/Feature/Listeners/MarkJobAsCompleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,11 @@
use Laravel\Horizon\Listeners\MarkJobAsComplete;
use Laravel\Horizon\Tests\IntegrationTest;
use Mockery as m;
use Orchestra\Testbench\Attributes\WithConfig;

#[WithConfig('horizon.silenced', ['App\\Jobs\\ConfigJob'])]
class MarkJobAsCompleteTest extends IntegrationTest
{
protected function tearDown(): void
{
parent::tearDown();

m::close();
}

protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

$app['config']->set('horizon.silenced', [
'App\\Jobs\\ConfigJob',
]);
}

public function test_it_can_mark_a_job_as_complete(): void
{
$this->runScenario('App\\Jobs\\TestJob', false);
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/SupervisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function tearDown(): void
parent::tearDown();
}

/** @requires extension redis */
public function test_supervisor_can_start_worker_process_with_given_options()
{
Queue::push(new Jobs\BasicJob);
Expand Down Expand Up @@ -260,6 +261,7 @@ public function test_supervisor_can_restart_processes()
$this->assertNotEquals($pid, $supervisor->processes()[0]->getPid());
}

/** @requires extension redis */
public function test_processes_can_be_paused_and_continued()
{
$options = $this->supervisorOptions();
Expand Down
26 changes: 10 additions & 16 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,18 @@ abstract class IntegrationTest extends TestCase
*/
protected function setUp(): void
{
parent::setUp();

Redis::flushall();
}
$this->afterApplicationCreated(function () {
Redis::flushall();
});

/**
* Tear down the test case.
*
* @return void
*/
protected function tearDown(): void
{
parent::tearDown();
$this->beforeApplicationDestroyed(function () {
Redis::flushall();
WorkerCommandString::reset();
SupervisorCommandString::reset();
Horizon::$authUsing = null;
});

Redis::flushall();
WorkerCommandString::reset();
SupervisorCommandString::reset();
Horizon::$authUsing = null;
parent::setUp();
}

/**
Expand Down
19 changes: 2 additions & 17 deletions tests/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,11 @@
use Illuminate\Queue\QueueManager;
use Illuminate\Queue\Worker;
use Illuminate\Queue\WorkerOptions;
use Orchestra\Testbench\Concerns\CreatesApplication;

$appLoader = new class
{
use CreatesApplication;

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Define your environment setup.
}
};
use function Orchestra\Testbench\container;

// Configure the application...
$app = $appLoader->createApplication();
$app = container()->createApplication();
$app->register(Laravel\Horizon\HorizonServiceProvider::class);
$app->make('config')->set('queue.default', 'redis');

Expand Down

0 comments on commit ea857d1

Please sign in to comment.