From 8e9f5237a32449cdd41f3e9fecc4671dde0924fa Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Wed, 8 Oct 2025 01:29:20 +0530 Subject: [PATCH 1/5] feat: Add C language support --- Makefile | 5 ++++- livecode_server/config.py | 5 +++++ runtimes/c/Dockerfile | 11 +++++++++++ runtimes/c/run.sh | 16 ++++++++++++++++ tests/runtimes/test_c_hello.yml | 9 +++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 runtimes/c/Dockerfile create mode 100644 runtimes/c/run.sh create mode 100644 tests/runtimes/test_c_hello.yml diff --git a/Makefile b/Makefile index f973317..47d3b8c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,10 @@ LIVECODE_PORT?=8010 default: run -setup: +build-c-runtime: + docker build -t fossunited/falcon-c ./runtimes/c + +setup: build-c-runtime docker pull fossunited/falcon-python:3.9 docker pull fossunited/falcon-golang docker pull fossunited/falcon-rust diff --git a/livecode_server/config.py b/livecode_server/config.py index dd46312..cc40877 100644 --- a/livecode_server/config.py +++ b/livecode_server/config.py @@ -30,6 +30,11 @@ "command": [], "code_filename": "main.go" }, + "c": { + "image": "fossunited/falcon-c", + "command": [], + "code_filename": "main.c" + }, "joy": { "image": "falcon-joy", "command": ["python", "/opt/start.py"], diff --git a/runtimes/c/Dockerfile b/runtimes/c/Dockerfile new file mode 100644 index 0000000..81941f2 --- /dev/null +++ b/runtimes/c/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:bullseye-slim +RUN apt-get update && \ + apt-get install -y build-essential && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +COPY run.sh /usr/local/bin/run.sh +RUN chmod +x /usr/local/bin/run.sh +RUN useradd -m -s /bin/bash appuser +USER appuser +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/run.sh"] diff --git a/runtimes/c/run.sh b/runtimes/c/run.sh new file mode 100644 index 0000000..12fac9a --- /dev/null +++ b/runtimes/c/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e +SOURCE_FILE="main.c" +OUTPUT_BINARY="/tmp/a.out" + +compile_and_run() { + gcc "${SOURCE_FILE}" -o "${OUTPUT_BINARY}" + exec "${OUTPUT_BINARY}" +} + +if [ "$FALCON_MODE" = "test" ] +then + compile_and_run +else + compile_and_run +fi diff --git a/tests/runtimes/test_c_hello.yml b/tests/runtimes/test_c_hello.yml new file mode 100644 index 0000000..34f0664 --- /dev/null +++ b/tests/runtimes/test_c_hello.yml @@ -0,0 +1,9 @@ +runtime: c +code: | + #include + int main() { + printf("Hello from C runtime!\n"); + return 0; + } +expected_output: "Hello from C runtime!\n" + From 2112796af96f42cdebe894cf585747690019bf50 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Fri, 10 Oct 2025 14:30:43 +0530 Subject: [PATCH 2/5] Fixed Failing Tests --- runtimes/c/run.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/runtimes/c/run.sh b/runtimes/c/run.sh index 12fac9a..822c9dd 100644 --- a/runtimes/c/run.sh +++ b/runtimes/c/run.sh @@ -1,16 +1,10 @@ #!/bin/sh set -e + SOURCE_FILE="main.c" +TEMP_SOURCE="/tmp/main.c" OUTPUT_BINARY="/tmp/a.out" -compile_and_run() { - gcc "${SOURCE_FILE}" -o "${OUTPUT_BINARY}" - exec "${OUTPUT_BINARY}" -} - -if [ "$FALCON_MODE" = "test" ] -then - compile_and_run -else - compile_and_run -fi +cp "${SOURCE_FILE}" "${TEMP_SOURCE}" +gcc "${TEMP_SOURCE}" -o "${OUTPUT_BINARY}" +exec "${OUTPUT_BINARY}" \ No newline at end of file From 5ccb794d9111a4a8a49a1ca74788ff9ed5c5daef Mon Sep 17 00:00:00 2001 From: Aditya Singh <78854372+ARH-MNAJS@users.noreply.github.com> Date: Fri, 10 Oct 2025 20:00:36 +0530 Subject: [PATCH 3/5] Update livecode_ci.yml Added Manual trigger for testing --- .github/workflows/livecode_ci.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/livecode_ci.yml b/.github/workflows/livecode_ci.yml index bb674a2..f26a38b 100644 --- a/.github/workflows/livecode_ci.yml +++ b/.github/workflows/livecode_ci.yml @@ -1,14 +1,17 @@ name: Livecode (Code Sanity Check & Test) -on: [ push, pull_request ] +on: + push: + pull_request: + workflow_dispatch: jobs: sanity_check: runs-on: ubuntu-latest name: Sanity Check steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: python-version: '3.x' - name: Installing dependencies @@ -23,8 +26,8 @@ jobs: runs-on: ubuntu-latest name: Test Cases steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: python-version: '3.x' - name: Installing Dependencies From 2825e26c708c9f9cda62dc07678e241c5d842dd4 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Fri, 10 Oct 2025 20:03:52 +0530 Subject: [PATCH 4/5] fix: simplify C runtime to properly handle mounted files - Streamline run.sh by removing unnecessary copy operations - Improve Dockerfile structure and user permission handling --- runtimes/c/Dockerfile | 8 +++++--- runtimes/c/run.sh | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtimes/c/Dockerfile b/runtimes/c/Dockerfile index 81941f2..f687f5d 100644 --- a/runtimes/c/Dockerfile +++ b/runtimes/c/Dockerfile @@ -3,9 +3,11 @@ RUN apt-get update && \ apt-get install -y build-essential && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +RUN mkdir /app +RUN useradd -m -s /bin/bash appuser +RUN chown -R appuser:appuser /app COPY run.sh /usr/local/bin/run.sh RUN chmod +x /usr/local/bin/run.sh -RUN useradd -m -s /bin/bash appuser -USER appuser WORKDIR /app -ENTRYPOINT ["/usr/local/bin/run.sh"] +USER appuser +ENTRYPOINT ["/usr/local/bin/run.sh"] \ No newline at end of file diff --git a/runtimes/c/run.sh b/runtimes/c/run.sh index 822c9dd..90f752a 100644 --- a/runtimes/c/run.sh +++ b/runtimes/c/run.sh @@ -2,9 +2,7 @@ set -e SOURCE_FILE="main.c" -TEMP_SOURCE="/tmp/main.c" OUTPUT_BINARY="/tmp/a.out" -cp "${SOURCE_FILE}" "${TEMP_SOURCE}" -gcc "${TEMP_SOURCE}" -o "${OUTPUT_BINARY}" -exec "${OUTPUT_BINARY}" \ No newline at end of file +gcc "${SOURCE_FILE}" -o "${OUTPUT_BINARY}" +exec "${OUTPUT_BINARY}" From 20ebfc524552780c47c6f760fa24c6bd7dc2e745 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Fri, 10 Oct 2025 20:08:17 +0530 Subject: [PATCH 5/5] Restructured Dockerfile --- runtimes/c/Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/runtimes/c/Dockerfile b/runtimes/c/Dockerfile index f687f5d..84f4fad 100644 --- a/runtimes/c/Dockerfile +++ b/runtimes/c/Dockerfile @@ -3,11 +3,7 @@ RUN apt-get update && \ apt-get install -y build-essential && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN mkdir /app -RUN useradd -m -s /bin/bash appuser -RUN chown -R appuser:appuser /app COPY run.sh /usr/local/bin/run.sh RUN chmod +x /usr/local/bin/run.sh WORKDIR /app -USER appuser ENTRYPOINT ["/usr/local/bin/run.sh"] \ No newline at end of file