Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c9164e

Browse files
move from locked files top yml based config
1 parent 73402f1 commit 3c9164e

File tree

5 files changed

+249
-53
lines changed

5 files changed

+249
-53
lines changed

‎src/rabbitmq/jobqueue.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ProjectJob {
3333
problem: string,
3434
timelimit: number,
3535
scenario: string,
36-
lockedFiles: string
36+
config: string
3737
}
3838

3939
export type JudgeJob = RunJob | SubmissionJob | ProjectJob

‎src/routes/api/project/controller.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
source: req.body.submission,
3333
problem: req.body.problem,
3434
lang: req.body.lang,
35-
lockedFiles: req.body.lockedFiles,
35+
config: req.body.config,
3636
timelimit: req.body.timelimit,
3737
scenario: 'project'
3838
})

‎src/routes/api/project/validators.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ export default class ProjectValidator extends BaseValidator {
2222
.string()
2323
.uri()
2424
.required(),
25-
lockedFiles: Joi
26-
.array()
27-
.items(Joi.string())
28-
.min(1)
25+
config: Joi
26+
.string()
2927
.required(),
3028
mode: Joi
3129
.string()

‎test/e2e/ProjectScenario.spec.ts‎

Lines changed: 95 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ describe('POST api/project', () => {
6666
const params = {
6767
lang: 'node',
6868
submission: 'https://minio.cb.lk/public/input',
69-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
69+
config: `
70+
project:
71+
allowed-folders:
72+
- src/**/*.js
73+
before-test:
74+
- yarn install
75+
- yarn build
76+
testcases:
77+
- yarn test
78+
`,
7079
mode: 'sync',
7180
timelimit: 1
7281
};
@@ -85,7 +94,16 @@ describe('POST api/project', () => {
8594
lang: 'node',
8695
problem: 'not-a-url',
8796
submission: 'https://minio.cb.lk/public/input',
88-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
97+
config: `
98+
project:
99+
allowed-folders:
100+
- src/**/*.js
101+
before-test:
102+
- yarn install
103+
- yarn build
104+
testcases:
105+
- yarn test
106+
`,
89107
mode: 'sync',
90108
timelimit: 1
91109
};
@@ -103,7 +121,16 @@ describe('POST api/project', () => {
103121
const params = {
104122
lang: 'node',
105123
problem: 'https://minio.cb.lk/public/input',
106-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
124+
config: `
125+
project:
126+
allowed-folders:
127+
- src/**/*.js
128+
before-test:
129+
- yarn install
130+
- yarn build
131+
testcases:
132+
- yarn test
133+
`,
107134
mode: 'sync',
108135
timelimit: 1
109136
};
@@ -122,7 +149,16 @@ describe('POST api/project', () => {
122149
lang: 'node',
123150
problem: 'https://minio.cb.lk/public/input',
124151
submission: 'not-a-url',
125-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
152+
config: `
153+
project:
154+
allowed-folders:
155+
- src/**/*.js
156+
before-test:
157+
- yarn install
158+
- yarn build
159+
testcases:
160+
- yarn test
161+
`,
126162
mode: 'sync',
127163
timelimit: 1
128164
};
@@ -136,7 +172,7 @@ describe('POST api/project', () => {
136172
expect(res.body.err.message).to.equal('"submission" must be a valid uri');
137173
});
138174

139-
it('should throw 400 error for lockedFiles missing', async () => {
175+
it('should throw 400 error for config missing', async () => {
140176
const params = {
141177
lang: 'node',
142178
problem: 'https://minio.cb.lk/public/input',
@@ -151,15 +187,15 @@ describe('POST api/project', () => {
151187
}).send(params);
152188

153189
expect(res.status).to.equal(400);
154-
expect(res.body.err.message).to.equal('"lockedFiles" is required');
190+
expect(res.body.err.message).to.equal('"config" is required');
155191
});
156192

157-
it('should throw 400 error when lockedFiles is not a string', async () => {
193+
it('should throw 400 error when config is not a string', async () => {
158194
const params = {
159195
lang: 'node',
160196
problem: 'https://minio.cb.lk/public/input',
161197
submission: 'https://minio.cb.lk/public/input',
162-
lockedFiles: 123,
198+
config: 123,
163199
mode: 'sync',
164200
timelimit: 1
165201
};
@@ -170,15 +206,24 @@ describe('POST api/project', () => {
170206
}).send(params);
171207

172208
expect(res.status).to.equal(400);
173-
expect(res.body.err.message).to.equal('"lockedFiles" must be an array');
209+
expect(res.body.err.message).to.equal('"config" must be an array');
174210
});
175211

176212
it('should throw 400 error for incorrect mode ', async () => {
177213
const params = {
178214
lang: 'node',
179215
problem: 'https://minio.cb.lk/public/input',
180216
submission: 'https://minio.cb.lk/public/input',
181-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
217+
config: `
218+
project:
219+
allowed-folders:
220+
- src/**/*.js
221+
before-test:
222+
- yarn install
223+
- yarn build
224+
testcases:
225+
- yarn test
226+
`,
182227
mode: 'abc',
183228
timelimit: 1
184229
};
@@ -197,7 +242,16 @@ describe('POST api/project', () => {
197242
lang: 'node',
198243
problem: 'https://minio.cb.lk/public/input',
199244
submission: 'https://minio.cb.lk/public/input',
200-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
245+
config: `
246+
project:
247+
allowed-folders:
248+
- src/**/*.js
249+
before-test:
250+
- yarn install
251+
- yarn build
252+
testcases:
253+
- yarn test
254+
`,
201255
mode: 'callback',
202256
timelimit: 1
203257
};
@@ -216,7 +270,16 @@ describe('POST api/project', () => {
216270
lang: 'node',
217271
problem: 'https://minio.cb.lk/public/input',
218272
submission: 'https://minio.cb.lk/public/input',
219-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
273+
config: `
274+
project:
275+
allowed-folders:
276+
- src/**/*.js
277+
before-test:
278+
- yarn install
279+
- yarn build
280+
testcases:
281+
- yarn test
282+
`,
220283
mode: 'sync',
221284
timelimit: 1
222285
};
@@ -236,7 +299,16 @@ describe('POST api/project', () => {
236299
lang: 'node',
237300
problem: 'https://minio.cb.lk/public/input',
238301
submission: 'https://minio.cb.lk/public/input',
239-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
302+
config: `
303+
project:
304+
allowed-folders:
305+
- src/**/*.js
306+
before-test:
307+
- yarn install
308+
- yarn build
309+
testcases:
310+
- yarn test
311+
`,
240312
mode: 'poll',
241313
timelimit: 1
242314
};
@@ -261,7 +333,16 @@ describe('POST api/project', () => {
261333
lang: 'node',
262334
problem: 'https://minio.cb.lk/public/input',
263335
submission: 'https://minio.cb.lk/public/input',
264-
lockedFiles: ['package.json', 'yarn.lock', 'test'],
336+
config: `
337+
project:
338+
allowed-folders:
339+
- src/**/*.js
340+
before-test:
341+
- yarn install
342+
- yarn build
343+
testcases:
344+
- yarn test
345+
`,
265346
mode: 'callback',
266347
callback: 'http://localhost:2404',
267348
timelimit: 1

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /