File tree Expand file tree Collapse file tree 9 files changed +78
-13
lines changed Expand file tree Collapse file tree 9 files changed +78
-13
lines changed Original file line number Diff line number Diff line change 19
19
- run :
20
20
name : Build Docker Image
21
21
command : |
22
- docker build -t codingblocks/judge-api .
22
+ docker-compose build
23
23
- run :
24
24
name : Docker Compose
25
25
command : |
35
35
command : |
36
36
mkdir -p coverage
37
37
docker kill judgecompose_api_1
38
- docker run -t --env-file .env \
38
+ docker run -t --env-file test .env \
39
39
-v "$PWD/coverage:/usr/src/judge-api/coverage" \
40
40
--network judgecompose_default \
41
41
--env "DEBUG=test:* JUDGEAPI_HOST=api JUDGEAPI_PORT=2222" codingblocks/judge-api \
Original file line number Diff line number Diff line change @@ -110,3 +110,6 @@ crashlytics.properties
110
110
crashlytics-build.properties
111
111
fabric.properties
112
112
113
+ .circleci
114
+ .travis.yml
115
+ docker-compose.yml
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ before_install:
18
18
- curl -L https://raw.githubusercontent.com/coding-blocks/judge-compose/master/judgeapi-example.env > .env
19
19
20
20
install :
21
- - docker build -t codingblocks/judge-api .
21
+ - docker-compose build
22
22
- docker-compose -p judgecompose up -d
23
23
24
24
before_script :
@@ -28,7 +28,7 @@ script:
28
28
- docker kill judgecompose_api_1
29
29
- mkdir -p coverage
30
30
- |
31
- docker run -t --env-file .env \
31
+ docker run -t --env-file test .env \
32
32
-v "$PWD/coverage:/usr/src/judge-api/coverage" \
33
33
--network judgecompose_default \
34
34
--env "DEBUG=test:* JUDGEAPI_HOST=api JUDGEAPI_PORT=2222" codingblocks/judge-api \
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+ postgres :
4
+ image : postgres:9.6
5
+ environment :
6
+ - POSTGRES_USER=judgeapi
7
+ - POSTGRES_PASSWORD=judgeapi
8
+ - POSTGRES_DB=judgeapi-dev
9
+ rabbitmq :
10
+ image : rabbitmq:3-management-alpine
11
+ environment :
12
+ - RABBITMQ_DEFAULT_USER=codingblocks
13
+ - RABBITMQ_DEFAULT_PASS=codingblocks
14
+ ports :
15
+ - " 5672:5672"
16
+ - " 15672:15672"
17
+ api :
18
+ build : .
19
+ image : codingblocks/judge-api
20
+ depends_on :
21
+ - postgres
22
+ ports :
23
+ - " 3737:3737"
24
+ env_file :
25
+ - test.env
Original file line number Diff line number Diff line change 40
40
"apidoc" : " apidoc -i src -o docs" ,
41
41
"prestart" : " npm run build && npm run apidoc" ,
42
42
"start" : " scripts/wait-for-it.sh ${AMQP_HOST}:${AMQP_PORT} -- node dist/run.js" ,
43
- "test" : " node_modules/.bin/mocha --timeout 10000 --exit --require ts-node/register test/utils/setup.ts test/*.ts" ,
43
+ "test" : " node_modules/.bin/mocha --timeout 10000 --exit --require ts-node/register test/utils/setup* .ts test/*.ts" ,
44
44
"cover" : " nyc npm test" ,
45
45
"seedlangs" : " node dist/db/scripts/seed-defaultlangs.js" ,
46
46
"precodecov" : " npm run cover" ,
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- curl -L https://raw.githubusercontent.com/coding-blocks/judge-compose/master/docker-compose-withdb.yml > docker-compose.yml
4
- curl -L https://raw.githubusercontent.com/coding-blocks/judge-compose/master/judgeapi-example.env > .env
5
-
6
- docker build -t codingblocks/judge-api .
3
+ docker-compose build
7
4
docker-compose -p judgecompose up -d
8
5
9
6
docker exec judgecompose_api_1 scripts/wait-for-it.sh -t 180 api:3737 -- npm run seedlangs
10
7
docker kill judgecompose_api_1
11
- docker run -t --env-file .env \
8
+ docker run -t --env-file test .env \
12
9
--network judgecompose_default \
13
10
--env " DEBUG=test:* JUDGEAPI_HOST=api JUDGEAPI_PORT=2222" codingblocks/judge-api \
14
11
npm run cover
15
12
16
13
docker-compose kill
17
14
docker-compose down
18
15
19
- rm docker-compose.yml
20
- rm .env
21
-
22
16
docker system prune -f
23
17
docker volume prune -f
Original file line number Diff line number Diff line change
1
+ # Copy this to .env and use real values (and remove this comment line)
2
+ AMQP_USER = codingblocks
3
+ AMQP_PASS = codingblocks
4
+ AMQP_HOST = rabbitmq
5
+ AMQP_PORT = 5672
6
+ DB_HOST = postgres
7
+ DB_NAME = judgeapi-dev
8
+ DB_USER = judgeapi
9
+ DB_PASS = judgeapi
10
+ JUDGEAPI_HOST = localhost
11
+ JUDGEAPI_PORT = 3737
12
+ DEBUG = test:*
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import { RunResponse } from '../../src/routes/api/run'
2
+ import * as amqp from 'amqplib/callback_api'
3
+ import { Channel , Connection } from 'amqplib/callback_api'
4
+ import app , { config } from '../../src/server'
5
+
6
+ const jobQ = 'job_queue'
7
+ const successQ = 'success_queue'
8
+
9
+ before ( ( done ) => {
10
+ amqp . connect ( `amqp://${ config . AMQP . USER } :${ config . AMQP . PASS } @${ config . AMQP . HOST } :${ config . AMQP . PORT } ` ,
11
+ ( err , connection ) => {
12
+ if ( err ) throw err
13
+
14
+ connection . createChannel ( ( err2 , channel ) => {
15
+
16
+ channel . assertQueue ( successQ )
17
+ channel . assertQueue ( jobQ )
18
+ channel . consume ( jobQ , ( msg ) => {
19
+ let job = JSON . parse ( msg . content . toString ( ) )
20
+ channel . sendToQueue ( successQ , ( new Buffer ( JSON . stringify ( < RunResponse > {
21
+ id : job . id ,
22
+ stderr : 'stderr' ,
23
+ stdout : 'stdout'
24
+ } ) ) ) )
25
+ channel . ack ( msg )
26
+ } )
27
+
28
+
29
+ } )
30
+ } )
31
+ } )
You can’t perform that action at this time.
0 commit comments