File tree Expand file tree Collapse file tree 8 files changed +70
-80
lines changed
containers/project-worker/base Expand file tree Collapse file tree 8 files changed +70
-80
lines changed Original file line number Diff line number Diff line change 1
1
FROM alpine:3.11.5
2
2
3
- RUN apk add --no-cache gcc musl-dev bash
3
+ RUN apk add --no-cache gcc musl-dev bash python3 git openssh
4
4
5
5
COPY ./runguard /usr/src/runguard
6
6
RUN gcc /usr/src/runguard/runguard.c -o /bin/runguard
7
7
8
- COPY ./judge.sh ./bin/judge.sh
8
+ COPY ./judge.py ./bin/judge.py
Original file line number Diff line number Diff line change
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 )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ for type in $(ls "$DIR/containers")
6
6
do
7
7
for lang in $( ls " $DIR /containers/$type " )
8
8
do
9
- docker push codingblocks/$type -$lang $DIR /containers/ $type / $lang
9
+ docker push codingblocks/$type -$lang
10
10
done
11
11
done
Original file line number Diff line number Diff line change @@ -77,3 +77,6 @@ typings/
77
77
78
78
# DynamoDB Local files
79
79
.dynamodb /
80
+
81
+ # MAC OS
82
+ .DS_Store
Original file line number Diff line number Diff line change @@ -77,3 +77,6 @@ typings/
77
77
78
78
# DynamoDB Local files
79
79
.dynamodb /
80
+
81
+ # MAC OS
82
+ .DS_Store
Original file line number Diff line number Diff line change @@ -3,13 +3,8 @@ const express = require('express')
3
3
const app = express ( )
4
4
5
5
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' } ] )
13
8
} )
14
9
15
10
app . listen ( 3000 , ( ) => console . log ( 'App running' ) )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ docker run \
18
18
--rm \
19
19
-v " $RUNBOX " :/usr/src/runbox \
20
20
-w /usr/src/runbox codingblocks/project-worker-" $LANGUAGE " \
21
- /bin/judge.sh -s src/ *
21
+ /bin/judge.py -l package.json yarn.lock test
22
22
23
23
ls -lh ${RUNBOX}
24
24
You can’t perform that action at this time.
0 commit comments