diff --git a/README.md b/README.md index fc443ff..50bc03e 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,6 @@ Currently we have following images - - [nodejs6](containers/nodejs6) - [nodejs](containers/nodejs8) - [py2](containers/py2) + - [py3](containers/py3) + - [ruby](containers/ruby) diff --git a/containers/ruby/Dockerfile b/containers/ruby/Dockerfile new file mode 100644 index 0000000..275645b --- /dev/null +++ b/containers/ruby/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.6 + +RUN apk add --no-cache ruby="2.4.4-r0" bash + +COPY ./compile.sh /bin/compile.sh +COPY ./run.sh /bin/run.sh + +RUN chmod 777 /bin/compile.sh; \ + chmod 777 /bin/run.sh diff --git a/containers/ruby/compile.sh b/containers/ruby/compile.sh new file mode 100644 index 0000000..212c4ba --- /dev/null +++ b/containers/ruby/compile.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash \ No newline at end of file diff --git a/containers/ruby/run.sh b/containers/ruby/run.sh new file mode 100644 index 0000000..98629e8 --- /dev/null +++ b/containers/ruby/run.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +ruby script.rb < run.stdin 1> run.stdout 2> run.stderr \ No newline at end of file diff --git a/test.sh b/test.sh index ee3af42..3f1d73d 100755 --- a/test.sh +++ b/test.sh @@ -28,3 +28,7 @@ sh tests/py3/test_worker.sh } +@test "test ruby" { + bash tests/ruby/test_worker.sh +} + diff --git a/tests/ruby/run.stdin b/tests/ruby/run.stdin new file mode 100644 index 0000000..beef906 --- /dev/null +++ b/tests/ruby/run.stdin @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/tests/ruby/runbox/run.stderr b/tests/ruby/runbox/run.stderr new file mode 100644 index 0000000..e69de29 diff --git a/tests/ruby/runbox/run.stdin b/tests/ruby/runbox/run.stdin new file mode 100644 index 0000000..beef906 --- /dev/null +++ b/tests/ruby/runbox/run.stdin @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/tests/ruby/runbox/run.stdout b/tests/ruby/runbox/run.stdout new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/tests/ruby/runbox/run.stdout @@ -0,0 +1 @@ +Hello World diff --git a/tests/ruby/runbox/script.rb b/tests/ruby/runbox/script.rb new file mode 100644 index 0000000..ac3e255 --- /dev/null +++ b/tests/ruby/runbox/script.rb @@ -0,0 +1 @@ +puts "Hello " + gets.to_s \ No newline at end of file diff --git a/tests/ruby/script.rb b/tests/ruby/script.rb new file mode 100644 index 0000000..ac3e255 --- /dev/null +++ b/tests/ruby/script.rb @@ -0,0 +1 @@ +puts "Hello " + gets.to_s \ No newline at end of file diff --git a/tests/ruby/test_worker.sh b/tests/ruby/test_worker.sh new file mode 100644 index 0000000..39d0a45 --- /dev/null +++ b/tests/ruby/test_worker.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +pushd $(dirname "$0") +DIR=$(pwd) +RUNBOX="${DIR}/runbox" + +echo $RUNBOX +# Remove RUNBOX +rm -rf $RUNBOX + +# Create runbox +mkdir -p $RUNBOX + +# Copy source to runbox +cp $DIR/script.rb $RUNBOX/script.rb +cp $DIR/run.stdin $RUNBOX/run.stdin + +# Test Compile +docker run \ + --cpus="0.5" \ + --memory="20m" \ + --ulimit nofile=64:64 \ + --rm \ + --read-only \ + -v "$RUNBOX":/usr/src/runbox \ + -w /usr/src/runbox codingblocks/judge-worker-ruby \ + bash -c "/bin/compile.sh && /bin/run.sh" + + +# Delete runbox +#rm -rf $RUNBOX \ No newline at end of file