Skip to content
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

Swift support #20

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Currently we have following images -
- [py2](containers/py2)
- [py3](containers/py3)
- [ruby](containers/ruby)
- [rust](containers/rust)
- [swift](containers/swift)
- [rust](containers/rust)
7 changes: 7 additions & 0 deletions containers/swift/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM swiftdocker/swift:latest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used https://github.com/swiftdocker/docker-swift for the docker image.

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/swift/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
4 changes: 4 additions & 0 deletions containers/swift/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

chmod 777 script.swift
swift script.swift < run.stdin 1> run.stdout 2> run.stderr
16 changes: 10 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
bash tests/c/test_worker.sh
}

#@test "test cpp" {
# bash tests/cpp/test_worker.sh
#}
@test "test cpp" {
bash tests/cpp/test_worker.sh
}

@test "test csharp" {
bash tests/csharp/test_worker.sh
Expand All @@ -28,9 +28,9 @@
bash tests/nodejs8/test_worker.sh
}

@test "test perl" {
bash tests/perl/test_worker.sh
}
# @test "test perl" {
# bash tests/perl/test_worker.sh
# }

@test "test py2" {
bash tests/py2/test_worker.sh
Expand All @@ -44,6 +44,10 @@
bash tests/ruby/test_worker.sh
}

@test "test swift" {
bash tests/swift/test_worker.sh
}

@test "test rust" {
bash tests/rust/test_worker.sh
}
1 change: 1 addition & 0 deletions tests/swift/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
3 changes: 3 additions & 0 deletions tests/swift/script.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Foundation

if let input = readLine(){ print("Hello \(input)") }
38 changes: 38 additions & 0 deletions tests/swift/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
pushd $(dirname "$0")
DIR=$(pwd)
RUNBOX="${DIR}/runbox"

echo $RUNBOX
# Create runbox
mkdir -p $RUNBOX

# Copy source to runbox
cp -fv $DIR/script.swift $RUNBOX/script.swift
cp -fv $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 \
-v "$RUNBOX":/tmp \
-w /usr/src/runbox codingblocks/judge-worker-swift \
bash -c "/bin/compile.sh && /bin/run.sh"

ls -lh ${RUNBOX}

expected="Hello World"
actual="$(cat ${RUNBOX}/run.stdout)"
if [ "$expected" == "$actual" ] ;then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it coming out to be "Hello World" when according to your source code it should be "HelloWorld"

Copy link
Contributor Author

@vibhorgupta-gh vibhorgupta-gh Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@championswimmer fixed this, updated script.swift

:
else
echo "MISMATCH: Expected = $expected; Actual = $actual"
exit 1
fi

# Delete runbox
sudo rm -rf $RUNBOX
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis fails with 'No permission to rm runbox'. Hence sudo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange. how does it work for every other worker ?

Copy link
Contributor Author

@vibhorgupta-gh vibhorgupta-gh Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@championswimmer Here is the error. Perhaps it has something to do with the permissions granted from where we are pulling our docker image?

screen shot 2018-07-11 at 7 57 39 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local tests and travis passing