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 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..84f4fad --- /dev/null +++ b/runtimes/c/Dockerfile @@ -0,0 +1,9 @@ +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 +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/run.sh"] \ No newline at end of file diff --git a/runtimes/c/run.sh b/runtimes/c/run.sh new file mode 100644 index 0000000..90f752a --- /dev/null +++ b/runtimes/c/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +SOURCE_FILE="main.c" +OUTPUT_BINARY="/tmp/a.out" + +gcc "${SOURCE_FILE}" -o "${OUTPUT_BINARY}" +exec "${OUTPUT_BINARY}" 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" +