Skip to content

Commit c13ff8d

Browse files
committed
using git bundles rather than zips
1 parent e9e2866 commit c13ff8d

File tree

8 files changed

+70
-80
lines changed

8 files changed

+70
-80
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM alpine:3.11.5
22

3-
RUN apk add --no-cache gcc musl-dev bash
3+
RUN apk add --no-cache gcc musl-dev bash python3 git openssh
44

55
COPY ./runguard /usr/src/runguard
66
RUN gcc /usr/src/runguard/runguard.c -o /bin/runguard
77

8-
COPY ./judge.sh ./bin/judge.sh
8+
COPY ./judge.py ./bin/judge.py
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#! /usr/bin/python3
2+
3+
import sys
4+
import os
5+
import subprocess
6+
import argparse
7+
8+
def compareHash(path):
9+
hash1 = subprocess.getoutput(f'git --git-dir=problem/.git log --pretty=format:\'%h\' -n 1 -- {path}')
10+
hash2 = subprocess.getoutput(f'git --git-dir=solution/.git log --pretty=format:\'%h\' -n 1 -- {path}')
11+
12+
return hash1 == hash2
13+
14+
def buildAndRun(timeout):
15+
currentDir = os.getcwd()
16+
os.chdir('solution')
17+
18+
subprocess.call('/bin/setup.sh')
19+
subprocess.call(f'/bin/build.sh 1> {currentDir}/build.stdout 2> {currentDir}/build.stderr', shell=True)
20+
subprocess.call([
21+
f'runguard \
22+
-t {timeout} \
23+
-E {currentDir}/result.code \
24+
-T {currentDir}/result.time \
25+
/bin/run.sh 1> {currentDir}/run.stdout 2> {currentDir}/run.stderr'
26+
], shell=True)
27+
28+
def main(timeout, locked):
29+
30+
# Compare hashes locked directories
31+
for path in locked:
32+
if not compareHash(path):
33+
open('result.code', 'w').write('25')
34+
open('result.stderr', 'w').write('Solution modified test directory')
35+
sys.exit(1)
36+
37+
buildAndRun(timeout)
38+
39+
if __name__ == '__main__':
40+
parser = argparse.ArgumentParser()
41+
42+
parser.add_argument(
43+
'-t',
44+
'--timeout',
45+
help='Timeout for the Code Run',
46+
default=20
47+
)
48+
parser.add_argument(
49+
'-l',
50+
'--locked-paths',
51+
nargs='+',
52+
help='List of paths whose hash is to be compared',
53+
required=True
54+
)
55+
56+
args = parser.parse_args()
57+
timeout, locked = args.timeout, args.locked_paths
58+
main(timeout, locked)

containers/project-worker/base/judge.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

push_docker_images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ for type in $(ls "$DIR/containers")
66
do
77
for lang in $(ls "$DIR/containers/$type")
88
do
9-
docker push codingblocks/$type-$lang $DIR/containers/$type/$lang
9+
docker push codingblocks/$type-$lang
1010
done
1111
done

tests/project-worker/nodejs/problem/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ typings/
7777

7878
#DynamoDB Local files
7979
.dynamodb/
80+
81+
# MAC OS
82+
.DS_Store

tests/project-worker/nodejs/solution/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ typings/
7777

7878
#DynamoDB Local files
7979
.dynamodb/
80+
81+
# MAC OS
82+
.DS_Store

tests/project-worker/nodejs/solution/src/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ const express = require('express')
33
const app = express()
44

55
app.get('/users', (req, res) => {
6-
const users = [
7-
{
8-
id: 1,
9-
name: 'Jatin Katyal'
10-
}
11-
]
12-
res.json(users)
6+
// TODO:
7+
res.json([{ name: 'jatin' }])
138
})
149

1510
app.listen(3000, () => console.log('App running'))

tests/project-worker/test_workers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ docker run \
1818
--rm \
1919
-v "$RUNBOX":/usr/src/runbox \
2020
-w /usr/src/runbox codingblocks/project-worker-"$LANGUAGE" \
21-
/bin/judge.sh -s src/*
21+
/bin/judge.py -l package.json yarn.lock test
2222

2323
ls -lh ${RUNBOX}
2424

0 commit comments

Comments
 (0)