Skip to content

Commit 810101b

Browse files
authored
Merge pull request #200 from open-runtimes/refactor-extract-runtimes
2 parents af6fa64 + e9295fe commit 810101b

File tree

11 files changed

+589
-127
lines changed

11 files changed

+589
-127
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OPR_EXECUTOR_ENV=development
22
OPR_EXECUTOR_IMAGE_PULL=enabled
33
OPR_EXECUTOR_RUNTIMES=php-8.1,dart-2.18,deno-1.24,node-18.0,python-3.10,ruby-3.1,cpp-17,dotnet-6.0
4-
OPR_EXECUTOR_CONNECTION_STORAGE=
4+
OPR_EXECUTOR_CONNECTION_STORAGE=local://localhost
55
OPR_EXECUTOR_INACTIVE_THRESHOLD=60
66
OPR_EXECUTOR_MAINTENANCE_INTERVAL=60
77
OPR_EXECUTOR_NETWORK=executor_runtimes

.github/workflows/tests.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@ name: "Tests"
22

33
on: [pull_request]
44
jobs:
5-
tests:
6-
name: Tests
5+
unit-tests:
6+
name: Unit Tests
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Check out the repo
11+
uses: actions/checkout@v2
12+
13+
- name: Run Unit Tests
14+
run: |
15+
docker run --rm \
16+
-v $PWD:/app \
17+
-w /app \
18+
phpswoole/swoole:5.1.2-php8.3-alpine \
19+
sh -c "
20+
apk update && \
21+
apk add zip unzip && \
22+
composer install --profile --ignore-platform-reqs && \
23+
composer test -- --testsuite=unit
24+
"
25+
26+
executor-tests:
27+
name: Executor Tests
728
runs-on: ubuntu-latest
829

930
steps:
@@ -27,7 +48,7 @@ jobs:
2748
docker ps
2849
docker network ls
2950
30-
- name: Run Tests
51+
- name: Run Executor Tests
3152
run: |
3253
docker run --rm \
3354
-v $PWD:/app \
@@ -40,5 +61,5 @@ jobs:
4061
apk update && \
4162
apk add docker-cli zip unzip && \
4263
composer install --profile --ignore-platform-reqs && \
43-
composer test
64+
composer test -- --testsuite=e2e
4465
"

app/http.php

Lines changed: 5 additions & 1 deletion
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

36+
3437
run(function () {
3538
$orchestration = new Orchestration(new DockerAPI(
3639
System::getEnv('OPR_EXECUTOR_DOCKER_HUB_USERNAME', ''),
3740
System::getEnv('OPR_EXECUTOR_DOCKER_HUB_PASSWORD', '')
3841
));
3942
$networks = explode(',', System::getEnv('OPR_EXECUTOR_NETWORK') ?: 'openruntimes-runtimes');
40-
$runner = new Docker($orchestration, $networks);
43+
$runner = new Docker($orchestration, new Runtimes(), $networks);
44+
4145
Http::setResource('runner', fn () => $runner);
4246

4347
$payloadSize = 22 * (1024 * 1024);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"appwrite/php-runtimes": "0.19.*",
2424
"utopia-php/config": "^0.2.2",
2525
"utopia-php/console": "0.0.*",
26-
"utopia-php/dsn": "0.1.*",
26+
"utopia-php/dsn": "0.2.*",
2727
"utopia-php/fetch": "0.4.*",
2828
"utopia-php/framework": "0.34.*",
2929
"utopia-php/logger": "0.6.*",

composer.lock

Lines changed: 20 additions & 20 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)