Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoExerciseChecker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Pipelines
DojoExerciseChecker
Commits
505abb8d
Commit
505abb8d
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
Add step 3 and 4 (run docker compose and wait for completion)
parent
5b170982
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#25599
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ExerciceChecker/src/app.ts
+66
-11
66 additions, 11 deletions
ExerciceChecker/src/app.ts
with
66 additions
and
11 deletions
ExerciceChecker/src/app.ts
+
66
−
11
View file @
505abb8d
...
@@ -4,6 +4,9 @@ const path = require('node:path');
...
@@ -4,6 +4,9 @@ const path = require('node:path');
require
(
'
dotenv
'
).
config
({
path
:
path
.
join
(
__dirname
,
'
../.env
'
)
});
require
(
'
dotenv
'
).
config
({
path
:
path
.
join
(
__dirname
,
'
../.env
'
)
});
require
(
'
./shared/helpers/TypeScriptExtensions
'
);
// ATTENTION : This line MUST be the second of this file
require
(
'
./shared/helpers/TypeScriptExtensions
'
);
// ATTENTION : This line MUST be the second of this file
import
ExerciceCheckerError
from
'
./types/ExerciceCheckerError
'
;
import
{
exec
,
spawn
}
from
'
child_process
'
;
import
util
from
'
util
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
fs
from
'
fs
'
;
import
chalk
from
'
chalk
'
;
import
chalk
from
'
chalk
'
;
import
HttpManager
from
'
./managers/HttpManager
'
;
import
HttpManager
from
'
./managers/HttpManager
'
;
...
@@ -12,21 +15,22 @@ import Config from './config/Config';
...
@@ -12,21 +15,22 @@ import Config from './config/Config';
(
async
()
=>
{
(
async
()
=>
{
HttpManager
.
registerAxiosInterceptor
();
const
execAsync
=
util
.
promisify
(
exec
);
console
.
log
(
chalk
.
blue
(
'
Dojo Exercice Checker
'
)
);
HttpManager
.
registerAxiosInterceptor
(
);
console
.
log
(
chalk
.
bgBlue
.
black
.
bold
(
'
DOJO EXERCICE CHECKER
'
));
/*
/*
Step 1 & 2:
Step 1 & 2:
- Read the dojo enonce file from the enonce repository
- Read the dojo enonce file from the enonce repository
- Download immutables files (maybe throw or show an error if the files have been modified ?)
- Download immutables files (maybe throw or show an error if the files have been modified ?)
*/
*/
console
.
log
(
chalk
.
green
(
'
Checking the exercice
\'
s enonce and his immutables files
'
));
const
exerciceEnonce
=
await
DojoBackendManager
.
getExerciceEnonce
();
const
exerciceEnonce
=
await
DojoBackendManager
.
getExerciceEnonce
();
if
(
!
exerciceEnonce
)
{
if
(
!
exerciceEnonce
)
{
console
.
error
(
chalk
.
red
(
`Error while getting the exercice's enonce`
));
console
.
error
(
chalk
.
red
(
`Error while getting the exercice's enonce`
));
process
.
exit
(
1
);
process
.
exit
(
ExerciceCheckerError
.
EXERCICE_ENONCE_GET_ERROR
);
}
}
exerciceEnonce
.
immutable
.
forEach
(
immutableFile
=>
{
exerciceEnonce
.
immutable
.
forEach
(
immutableFile
=>
{
...
@@ -36,10 +40,61 @@ import Config from './config/Config';
...
@@ -36,10 +40,61 @@ import Config from './config/Config';
});
});
// Step 3: Run docker-compose file
/*
// Step 4: Wait the end of the execution of the result container
Step 3 & 4:
- Run docker-compose file
- Wait until the end of the execution of the result container
*/
console
.
log
(
chalk
.
green
(
'
Run docker compose file
'
));
const
changeDirectoryCommand
=
`cd "
${
Config
.
filesFolder
}
"`
;
const
dockerComposeCommand
=
`docker compose --project-name
${
Config
.
dockerCompose
.
projectName
}
--progress plain`
;
const
containerExitStatus
=
await
new
Promise
<
[
number
,
string
]
>
((
resolve
,
reject
)
=>
{
let
logs
=
'
####################################################### Docker Compose & Main Container Logs #######################################################
\n
'
;
const
dockerCompose
=
spawn
(
`
${
dockerComposeCommand
}
run
${
exerciceEnonce
.
enonceFile
.
result
.
container
}
`
,
{
cwd
:
Config
.
filesFolder
,
shell
:
true
,
env
:
{
'
DOCKER_BUILDKIT
'
:
'
1
'
,
'
BUILDKIT_PROGRESS
'
:
'
plain
'
,
...
process
.
env
}
});
dockerCompose
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
logs
+=
data
.
toString
();
console
.
log
(
data
.
toString
());
});
dockerCompose
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
logs
+=
data
.
toString
();
console
.
error
(
data
.
toString
());
});
dockerCompose
.
on
(
'
exit
'
,
(
code
)
=>
{
logs
+=
'
####################################################### Other Services Logs #######################################################
\n
'
;
resolve
([
code
??
ExerciceCheckerError
.
DOCKER_COMPOSE_UP_ERROR
,
logs
]);
});
});
if
(
containerExitStatus
[
0
]
===
ExerciceCheckerError
.
DOCKER_COMPOSE_UP_ERROR
)
{
console
.
error
(
chalk
.
red
(
`Error while running the docker-compose file`
));
process
.
exit
(
containerExitStatus
[
0
]);
}
fs
.
writeFileSync
(
`
${
Config
.
resultsFolder
}
/dockerComposeLogs.txt`
,
containerExitStatus
[
1
]);
try
{
await
execAsync
(
`
${
changeDirectoryCommand
}
;
${
dockerComposeCommand
}
logs --timestamps >>
${
Config
.
resultsFolder
}
/dockerComposeLogs.txt`
);
}
catch
(
error
)
{
console
.
error
(
chalk
.
red
(
`Error while getting the docker-compose logs`
));
process
.
exit
(
ExerciceCheckerError
.
DOCKER_COMPOSE_LOGS_ERROR
);
}
// Step 5: Get the result from the volume
// Step 5: Get the result from the volume
// Step 6: Check content requirements and content size
// Step 6: Check content requirements and content size
// Step 7: Upload and show the results
// Step 7: Upload and show the results
// Step 8: Exit with container exit code
process
.
exit
(
containerExitStatus
[
0
]);
})();
})();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment