@@ -5,35 +5,41 @@ import { ProjectResult } from 'types/result'
5
5
import * as path from 'path'
6
6
import { Scenario } from 'tasks/scenario'
7
7
import { download } from 'utils/request'
8
+ const AdmZip = require ( 'adm-zip' )
8
9
9
10
export default class ProjectScenario extends Scenario {
10
11
async setup ( currentJobDir : string , job : ProjectJob ) {
11
- // check this. directory might be wrong
12
+
13
+ // for testing only, change it to download
14
+ var problemZip = new AdmZip ( '/judge-worker-prabal/current/problem.zip' )
15
+ var solutionZip = new AdmZip ( '/judge-worker-prabal/current/solution.zip' )
16
+
12
17
const problemDir = path . join ( currentJobDir , 'problem' )
13
18
mkdir ( '-p' , problemDir )
14
- await download ( job . problem , path . join ( problemDir , 'problem' ) )
19
+ problemZip . extractAllTo ( problemDir , true ) ;
15
20
16
21
const solutionDir = path . join ( currentJobDir , 'solution' )
17
22
mkdir ( '-p' , solutionDir )
18
- await download ( job . source , path . join ( solutionDir , 'solution' ) )
23
+ solutionZip . extractAllTo ( solutionDir , true ) ;
19
24
}
20
25
21
26
run ( currentJobDir : string , job : ProjectJob ) {
27
+
28
+ // LANG_CONFIG is undefined rn
22
29
const LANG_CONFIG = config . LANGS [ job . lang ]
23
30
return exec ( `docker run \\
24
- --cpus="${ LANG_CONFIG . CPU_SHARE } " \\
25
- --memory="${ LANG_CONFIG . MEM_LIMIT } " \\
31
+ --cpus="1 " \\
32
+ --memory="100m " \\
26
33
--rm \\
27
34
-v "${ currentJobDir } ":/usr/src/runbox \\
28
35
-w /usr/src/runbox codingblocks/project-worker-"${ job . lang } " \\
29
- /bin/judge.sh -s "${ job . submissionDirs } "
36
+ /bin/judge.sh -s "${ job . submissionDirs }
30
37
` ) ;
31
38
}
32
39
33
40
async result ( currentJobDir : string , job : ProjectJob ) : Promise < ProjectResult > {
34
41
35
42
const result_code = cat ( path . join ( currentJobDir , 'result.code' ) ) . toString ( )
36
-
37
43
if ( result_code ) {
38
44
// problem hash and solution hash were not equal. // error
39
45
return {
@@ -42,7 +48,7 @@ export default class ProjectScenario extends Scenario {
42
48
stdout : '' ,
43
49
code : parseInt ( result_code ) ,
44
50
time : 1 ,
45
- score : 0
51
+ score : 12
46
52
}
47
53
}
48
54
@@ -52,11 +58,11 @@ export default class ProjectScenario extends Scenario {
52
58
if ( stderr ) {
53
59
return {
54
60
id : job . id ,
55
- stderr : build_stderr ,
61
+ stderr,
56
62
stdout : '' ,
57
63
code : 12123 ,
58
64
time : 1 ,
59
- score : 0
65
+ score : 100
60
66
}
61
67
}
62
68
@@ -68,8 +74,8 @@ export default class ProjectScenario extends Scenario {
68
74
stderr : '' ,
69
75
stdout : stdout ,
70
76
time : 0 ,
71
- code : 0 ,
72
- score : 0
77
+ code : 10 ,
78
+ score : 100
73
79
}
74
80
}
75
81
}
0 commit comments