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

Add hyperskill/go profile #33

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions epicbox-hyperskill/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.16.5-buster

RUN apt-get update && \
apt-get install -y python3 python3-pip && \
rm -rf /var/lib/apt/lists/*

RUN pip3 install https://github.com/hyperskill/hs-test-python/archive/v5.tar.gz

COPY checker/ /checker/
6 changes: 6 additions & 0 deletions epicbox-hyperskill/go/checker/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

В предыдущих ПР подобные файлы были неисполняемыми. Если это так, то этот файл надо сделать исполняемым.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Поправил.


cd /sandbox
python3 tests.py --inside_docker > stdout.txt 2> stderr.txt
echo $? > code.txt
python3 /checker/process.py
42 changes: 42 additions & 0 deletions epicbox-hyperskill/go/checker/process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import json

FAILED_TEST_BEGIN = '#educational_plugin FAILED + '
FAILED_TEST_CONTINUE = '#educational_plugin '

if __name__ == '__main__':
score = 1
feedback = ''

code = open('code.txt').read().strip()
stdout = open('stdout.txt').read().splitlines()
stderr = open('stderr.txt').read().splitlines()
if code != '0':
score = 0
feedback = (
'Cannot check the submission.\n\nPerhaps your program '
'has fallen into an infinite loop or created too many objects in memory. '
'If you are sure that this is not the case, please send the report to support@hyperskill.org\n'
'stdout:\n{stdout}\n\nstderr:\n{stderr}'
.format(stdout='\n'.join(stdout), stderr='\n'.join(stderr))
)

elif any(line.startswith(FAILED_TEST_BEGIN) for line in stdout):
score = 0
output = []
output_started = False

for line in stdout:
if output_started and line.startswith(FAILED_TEST_CONTINUE):
output.append(line[len(FAILED_TEST_CONTINUE):])

if not output_started and line.startswith(FAILED_TEST_BEGIN):
output_started = True
output.append(line[len(FAILED_TEST_BEGIN):])

feedback = '\n'.join(output).strip()

result = {
'score': score,
'feedback': feedback,
}
print(json.dumps(result))