-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Jeckel-Lab/feature/replace_makefile_with_c…
…astor Replace current Makefile recipes with Castor tasks
- Loading branch information
Showing
7 changed files
with
111 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 30/10/2023 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace php; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Castor\Attribute\AsTask; | ||
use PhpAmqpLib\Connection\AMQPStreamConnection; | ||
use PhpAmqpLib\Message\AMQPMessage; | ||
|
||
use function Castor\notify; | ||
use function Castor\run; | ||
|
||
#[AsTask(description: 'Execute console command')] | ||
function console( | ||
string $consoleCommand | ||
): void { | ||
run( | ||
command: 'docker-compose -f docker-compose.yml exec demo php -d max_execution_time=0 console.php ' . $consoleCommand, | ||
timeout: 0 | ||
); | ||
} | ||
|
||
#[AsTask(description: 'Load messaged in RabbitMQ', name: 'load-messages')] | ||
function loadMessages(int $nbMessages): void | ||
{ | ||
run( | ||
command: 'docker-compose -f docker-compose.yml exec demo php -d max_execution_time=0 console.php demo:load-messages ' . $nbMessages, | ||
timeout: 0 | ||
); | ||
notify(sprintf('%d messages loaded', $nbMessages)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2023 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace docker; | ||
|
||
use Castor\Attribute\AsTask; | ||
|
||
use function Castor\notify; | ||
use function Castor\run; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
#[AsTask(description: 'Start docker containers')] | ||
function up(): void { | ||
docker_compose(command: 'up', timeout: 0); | ||
} | ||
|
||
#[AsTask(description: 'Stop and clean docker containers')] | ||
function down(): void { | ||
docker_compose('down -v'); | ||
} | ||
|
||
#[AsTask(description: 'Initialize rabbitmq configuration')] | ||
function init(): void { | ||
docker_compose_exec('rabbitmq', 'rabbitmqctl import_definitions /scripts/definitions.json'); | ||
notify('RabbitMQ Initialized'); | ||
} | ||
|
||
function docker_compose( | ||
string $command, | ||
?int $timeout = null | ||
): void { | ||
run( | ||
command: 'docker-compose -f docker-compose.yml ' . $command, | ||
timeout: $timeout | ||
); | ||
} | ||
|
||
function docker_compose_exec(string $container, string $command, ?int $timeout = null): void | ||
{ | ||
docker_compose("up -d $container"); | ||
docker_compose("exec $container $command", $timeout); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
use function Castor\import; | ||
|
||
import(__DIR__ . '/castor-commands'); | ||
import(__DIR__ . '/.castor'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters