Skip to content

Add Support for Swift #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
.idea.DS_Store
.DS_Store
.DS_Store
10 changes: 10 additions & 0 deletions containers/csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:3.6

RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk add --update --no-cache mono@testing bash

COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh

RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
3 changes: 3 additions & 0 deletions containers/csharp/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

csc program.cs 2> compile.stderr 1> compile.stdout
4 changes: 4 additions & 0 deletions containers/csharp/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

chmod 777 program.exe
mono program.exe < run.stdin 1> run.stdout 2> run.stderr
7 changes: 7 additions & 0 deletions containers/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.6

RUN apk add --no-cache ruby=2.4.4 bash
COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh
RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
1 change: 1 addition & 0 deletions containers/ruby/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
3 changes: 3 additions & 0 deletions containers/ruby/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby script.rb < run.stdin 1> run.stdout 2> run.stderr
9 changes: 9 additions & 0 deletions containers/swift/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:3.6

RUN apk add --no-cache swift=4.0 bash

COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh

RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
2 changes: 2 additions & 0 deletions containers/swift/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash

3 changes: 3 additions & 0 deletions containers/swift/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

swift file.swift < run.stdin 1> run.stdout 2> run.stderr
7 changes: 7 additions & 0 deletions tests/csharp/program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

public class HelloWorld {
static public void Main () {
Console.WriteLine ("Hello " + Console.ReadLine());
}
}
1 change: 1 addition & 0 deletions tests/csharp/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
Empty file.
3 changes: 3 additions & 0 deletions tests/csharp/runbox/compile.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Microsoft (R) Visual C# Compiler version 2.6.0.62309 (d3f6b8e7)
Copyright (C) Microsoft Corporation. All rights reserved.

7 changes: 7 additions & 0 deletions tests/csharp/runbox/program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

public class HelloWorld {
static public void Main () {
Console.WriteLine ("Hello " + Console.ReadLine());
}
}
Binary file added tests/csharp/runbox/program.exe
Binary file not shown.
Empty file added tests/csharp/runbox/run.stderr
Empty file.
1 change: 1 addition & 0 deletions tests/csharp/runbox/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
1 change: 1 addition & 0 deletions tests/csharp/runbox/run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
26 changes: 26 additions & 0 deletions tests/csharp/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
pushd $(dirname "$0")
DIR=$(pwd)
RUNBOX="${DIR}/runbox"

echo $RUNBOX
# Create runbox
mkdir -p $RUNBOX

# Copy source to runbox
cp $DIR/Program.cs $RUNBOX/Program.cs
cp $DIR/run.stdin $RUNBOX/run.stdin

# Test Compile
docker run \
--cpus="1" \
--memory="100m" \
--ulimit nofile=64:64 \
--rm \
--read-only \
-v "$RUNBOX":/usr/src/runbox \
-w /usr/src/runbox codingblocks/judge-worker-csharp \
bash -c "/bin/compile.sh && /bin/run.sh"

# Delete runbox
#rm -rf $RUNBOX
1 change: 1 addition & 0 deletions tests/ruby/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
Empty file added tests/ruby/runbox/run.stderr
Empty file.
1 change: 1 addition & 0 deletions tests/ruby/runbox/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
1 change: 1 addition & 0 deletions tests/ruby/runbox/run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
1 change: 1 addition & 0 deletions tests/ruby/runbox/script.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello " + gets.to_s
1 change: 1 addition & 0 deletions tests/ruby/script.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello " + gets.to_s
27 changes: 27 additions & 0 deletions tests/ruby/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/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"

6 changes: 6 additions & 0 deletions tests/swift/file.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

let inputStr = readLine()
if let inputStr = inputStr {
print("Hello",inputStr)
}
1 change: 1 addition & 0 deletions tests/swift/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
6 changes: 6 additions & 0 deletions tests/swift/runbox/file.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

let inputStr = readLine()
if let inputStr = inputStr {
print("Hello",inputStr)
}
Empty file added tests/swift/runbox/run.stderr
Empty file.
1 change: 1 addition & 0 deletions tests/swift/runbox/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
1 change: 1 addition & 0 deletions tests/swift/runbox/run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
27 changes: 27 additions & 0 deletions tests/swift/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/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/file.swift
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-swift \
bash -c "/bin/compile.sh && /bin/run.sh"