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

PHP support #23

Open
wants to merge 5 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -27,6 +27,7 @@ Currently we have following images -
- [nodejs6](containers/nodejs6)
- [nodejs](containers/nodejs8)
- [perl](containers/perl)
- [php7](containers/php7)
- [py2](containers/py2)
- [py3](containers/py3)
- [ruby](containers/ruby)
Expand Down
9 changes: 9 additions & 0 deletions containers/php7/Dockerfile
@@ -0,0 +1,9 @@
FROM alpine:3.6

RUN apk add --no-cache musl-dev php7="7.1.17-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
1 change: 1 addition & 0 deletions containers/php7/compile.sh
@@ -0,0 +1 @@
#!/usr/bin/env bash
3 changes: 3 additions & 0 deletions containers/php7/run.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

php script.php < run.stdin 1> run.stdout 2> run.stderr
14 changes: 9 additions & 5 deletions test.sh
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,10 +28,14 @@
bash tests/nodejs8/test_worker.sh
}

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

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

@test "test py2" {
bash tests/py2/test_worker.sh
}
Expand Down
1 change: 1 addition & 0 deletions tests/php7/run.stdin
@@ -0,0 +1 @@
World
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this work without W ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@championswimmer Did not get you, could you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's failing without the W

screen shot 2018-07-28 at 5 54 08 am

6 changes: 6 additions & 0 deletions tests/php7/script.php
@@ -0,0 +1,6 @@
<?php

$line = readline();
echo 'Hello ' . $line;

?>
41 changes: 41 additions & 0 deletions tests/php7/test_worker.sh
@@ -0,0 +1,41 @@
#!/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 -fv $DIR/script.php $RUNBOX/script.php
cp -fv $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 \
-v "$RUNBOX":/tmp \
-w /usr/src/runbox codingblocks/judge-worker-php7 \
bash -c "/bin/compile.sh && /bin/run.sh"

ls -lh ${RUNBOX}

expected="Hello World"
actual="$(cat ${RUNBOX}/run.stdout)"
if [ "$expected" == "$actual" ] ;then
:
else
echo "MISMATCH: Expected = $expected; Actual = $actual"
exit 1
fi

# Delete runbox
rm -rf $RUNBOX