Skip to content

Commit 7b6847f

Browse files
committed
refactor: extract runtimes
1 parent 9f15a25 commit 7b6847f

File tree

8 files changed

+494
-104
lines changed

8 files changed

+494
-104
lines changed

app/http.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require_once __DIR__ . '/controllers.php';
99

1010
use OpenRuntimes\Executor\Runner\Docker;
11+
use OpenRuntimes\Executor\Runner\Repository\Runtimes;
1112
use Swoole\Runtime;
1213
use Utopia\Console;
1314
use Utopia\Http\Http;
@@ -25,19 +26,22 @@
2526
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
2627

2728
Http::setMode((string)System::getEnv('OPR_EXECUTOR_ENV', Http::MODE_TYPE_PRODUCTION));
29+
2830
Http::onRequest()
2931
->inject('response')
3032
->action(function (Response $response) {
3133
$response->addHeader('Server', 'Executor');
3234
});
3335

34-
run(function () {
36+
$runtimes = new Runtimes();
37+
38+
run(function () use ($runtimes) {
3539
$orchestration = new Orchestration(new DockerAPI(
3640
System::getEnv('OPR_EXECUTOR_DOCKER_HUB_USERNAME', ''),
3741
System::getEnv('OPR_EXECUTOR_DOCKER_HUB_PASSWORD', '')
3842
));
3943
$networks = explode(',', System::getEnv('OPR_EXECUTOR_NETWORK') ?: 'openruntimes-runtimes');
40-
$runner = new Docker($orchestration, $networks);
44+
$runner = new Docker($orchestration, $runtimes, $networks);
4145

4246
Http::setResource('runner', fn () => $runner);
4347

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
<phpunit backupGlobals="false"
2-
backupStaticAttributes="false"
3-
bootstrap="vendor/autoload.php"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
processIsolation="false"
9-
stopOnFailure="true"
10-
>
1+
<phpunit
2+
backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="true"
11+
>
1112
<testsuites>
12-
<testsuite name="Application Test Suite">
13-
<directory>./tests/</directory>
13+
<testsuite name="e2e">
14+
<file>./tests/ExecutorTest.php</file>
15+
</testsuite>
16+
<testsuite name="unit">
17+
<directory>./tests/unit</directory>
1418
</testsuite>
1519
</testsuites>
1620
</phpunit>

0 commit comments

Comments
 (0)