From 17172fe4e47ba4cea0b36e923b120ad8fcd94279 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 13:10:42 +0530 Subject: [PATCH 1/6] feat: javascript runtime --- livecode_server/config.py | 5 +++++ runtimes/javascript/Dockerfile | 7 +++++++ runtimes/javascript/modes/exec.sh | 3 +++ runtimes/javascript/run.sh | 12 ++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 runtimes/javascript/Dockerfile create mode 100644 runtimes/javascript/modes/exec.sh create mode 100644 runtimes/javascript/run.sh diff --git a/livecode_server/config.py b/livecode_server/config.py index ee0d0cd..9e325ae 100644 --- a/livecode_server/config.py +++ b/livecode_server/config.py @@ -15,6 +15,11 @@ "command": [], "code_filename": "main.py" }, + "javascript": { + "image": "frappe/falcon-javascript:latest", + "command": [], + "code_filename": "main.js" + } "rust": { "image": "fossunited/falcon-rust", "command": [], diff --git a/runtimes/javascript/Dockerfile b/runtimes/javascript/Dockerfile new file mode 100644 index 0000000..15ed33e --- /dev/null +++ b/runtimes/javascript/Dockerfile @@ -0,0 +1,7 @@ +FROM node:18 +WORKDIR /app +RUN mkdir -p /opt/modes +COPY run.sh /opt/ +COPY modes/exec.sh /opt/modes/ +RUN chmod +x /opt/run.sh /opt/modes/exec.sh +ENTRYPOINT ["/opt/run.sh"] diff --git a/runtimes/javascript/modes/exec.sh b/runtimes/javascript/modes/exec.sh new file mode 100644 index 0000000..d96ef00 --- /dev/null +++ b/runtimes/javascript/modes/exec.sh @@ -0,0 +1,3 @@ +#!/bin/sh +SOURCE_FILE=${FALCON_SOURCE_FILE:-"main.js"} +node "$SOURCE_FILE" diff --git a/runtimes/javascript/run.sh b/runtimes/javascript/run.sh new file mode 100644 index 0000000..290cbaf --- /dev/null +++ b/runtimes/javascript/run.sh @@ -0,0 +1,12 @@ +#! /bin/sh +TIMEOUT=10 +SOURCE_FILE=${FALCON_SOURCE_FILE:-"main.js"} +MODE=${FALCON_MODE:-"exec"} +SCRIPT=/opt/modes/$MODE.sh + +if [ -x "$SCRIPT" ]; then + exec timeout $TIMEOUT $SCRIPT "$@" +else + echo "ERROR: invalid mode - $MODE" 1>&2 + exit 1 +fi From 9be452e8d1e94e400a4a9f9d204b28adb0c4db92 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 16:53:58 +0530 Subject: [PATCH 2/6] ci: added httpx --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 8aca38b..0994c53 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,4 @@ pytest pytest-asyncio pyyaml +httpx \ No newline at end of file From 2b5b40b8656f675011aed90b478797c62fcc6c02 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 17:15:58 +0530 Subject: [PATCH 3/6] fix: javascript runtime config --- livecode_server/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livecode_server/config.py b/livecode_server/config.py index 9e325ae..2d35665 100644 --- a/livecode_server/config.py +++ b/livecode_server/config.py @@ -19,7 +19,7 @@ "image": "frappe/falcon-javascript:latest", "command": [], "code_filename": "main.js" - } + }, "rust": { "image": "fossunited/falcon-rust", "command": [], From 1f2bb2e56872dc16828f18a724e9238895e13cab Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 17:52:15 +0530 Subject: [PATCH 4/6] test: javascript hello world test from ci --- tests/runtimes/test_javascript_hello.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/runtimes/test_javascript_hello.yml diff --git a/tests/runtimes/test_javascript_hello.yml b/tests/runtimes/test_javascript_hello.yml new file mode 100644 index 0000000..ff51b78 --- /dev/null +++ b/tests/runtimes/test_javascript_hello.yml @@ -0,0 +1,4 @@ +runtime: javascript +code: > + console.log("hello, world!") +expected_output: "hello, world!\n" \ No newline at end of file From 04c4a88f235c08708bbded7b9853d524fdf75e39 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 18:10:28 +0530 Subject: [PATCH 5/6] ci: added missing dev packages --- dev-requirements.txt | 4 +++- tests/runtimes/test_javascript_hello.yml | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 0994c53..44194bc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,6 @@ pytest pytest-asyncio pyyaml -httpx \ No newline at end of file +httpx +starlette +aiodocker \ No newline at end of file diff --git a/tests/runtimes/test_javascript_hello.yml b/tests/runtimes/test_javascript_hello.yml index ff51b78..4aaf832 100644 --- a/tests/runtimes/test_javascript_hello.yml +++ b/tests/runtimes/test_javascript_hello.yml @@ -1,4 +1,3 @@ runtime: javascript -code: > - console.log("hello, world!") +code: console.log("hello, world!") expected_output: "hello, world!\n" \ No newline at end of file From debc26f7eda78502a9f080f3a85a05d956668b7a Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 24 Jun 2025 18:13:13 +0530 Subject: [PATCH 6/6] fix: changed image path for javascript --- livecode_server/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livecode_server/config.py b/livecode_server/config.py index 2d35665..dd46312 100644 --- a/livecode_server/config.py +++ b/livecode_server/config.py @@ -16,7 +16,7 @@ "code_filename": "main.py" }, "javascript": { - "image": "frappe/falcon-javascript:latest", + "image": "frappedevs/falcon-javascript:latest", "command": [], "code_filename": "main.js" },