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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Pipelines
DojoExerciseChecker
Commits
f3318470
Commit
f3318470
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite step 3 and 4 (and add step 5) with the linking of volume with the host container
parent
3e0fc237
No related branches found
No related tags found
No related merge requests found
Pipeline
#25630
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
+19
-14
19 additions, 14 deletions
ExerciceChecker/src/app.ts
with
19 additions
and
14 deletions
ExerciceChecker/src/app.ts
+
19
−
14
View file @
f3318470
...
@@ -26,34 +26,38 @@ import Config from './config/Config';
...
@@ -26,34 +26,38 @@ import Config from './config/Config';
- 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 immutable
s
files
'
));
console
.
log
(
chalk
.
green
(
'
-
Checking the exercice
\'
s enonce and his immutable 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
(
`
X
Error while getting the exercice's enonce`
));
process
.
exit
(
ExerciceCheckerError
.
EXERCICE_ENONCE_GET_ERROR
);
process
.
exit
(
ExerciceCheckerError
.
EXERCICE_ENONCE_GET_ERROR
);
}
}
exerciceEnonce
.
immutable
.
forEach
(
immutableFile
=>
{
exerciceEnonce
.
immutable
.
forEach
(
immutableFile
=>
{
const
filePath
=
`
${
Config
.
f
ilesF
older
}
/
${
immutableFile
.
file_path
}
`
.
replace
(
/
\/\/
/g
,
'
/
'
);
const
filePath
=
`
${
Config
.
folder
s
.
project
}
/
${
immutableFile
.
file_path
}
`
.
replace
(
/
\/\/
/g
,
'
/
'
);
fs
.
mkdirSync
(
path
.
dirname
(
filePath
),
{
recursive
:
true
});
fs
.
mkdirSync
(
path
.
dirname
(
filePath
),
{
recursive
:
true
});
fs
.
writeFileSync
(
filePath
,
immutableFile
.
content
,
{
encoding
:
'
base64
'
});
fs
.
writeFileSync
(
filePath
,
immutableFile
.
content
,
{
encoding
:
'
base64
'
});
});
});
/*
/*
Step 3 & 4:
Step 3 & 4 & 5:
- Get override of docker-compose file (for override the volume by a bind mount to the results folder shared between dind and the host)
- Run docker-compose file
- Run docker-compose file
-
Wait until the end of the execution of the result container
-
Get logs from linked services
*/
*/
console
.
log
(
chalk
.
green
(
'
Run docker compose file
'
));
console
.
log
(
chalk
.
green
(
'
- Run docker compose file
'
));
const
changeDirectoryCommand
=
`cd "
${
Config
.
filesFolder
}
"`
;
const
dockerComposeOverride
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
../assets/docker-compose-override.yml
'
),
'
utf8
'
).
replace
(
'
{{VOLUME_NAME}}
'
,
exerciceEnonce
.
enonceFile
.
result
.
volume
).
replace
(
'
{{MOUNT_PATH}}
'
,
Config
.
folders
.
resultsExercice
);
const
dockerComposeCommand
=
`docker compose --project-name
${
Config
.
dockerCompose
.
projectName
}
--progress plain`
;
fs
.
writeFileSync
(
`
${
Config
.
folders
.
project
}
/docker-compose-override.yml`
,
dockerComposeOverride
);
const
changeDirectoryCommand
=
`cd "
${
Config
.
folders
.
project
}
"`
;
const
dockerComposeCommand
=
`docker compose --project-name
${
Config
.
dockerCompose
.
projectName
}
--progress plain --file docker-compose.yml --file docker-compose-override.yml`
;
const
containerExitStatus
=
await
new
Promise
<
[
number
,
string
]
>
((
resolve
,
reject
)
=>
{
const
containerExitStatus
=
await
new
Promise
<
[
number
,
string
]
>
((
resolve
,
reject
)
=>
{
let
logs
=
'
####################################################### Docker Compose & Main Container Logs #######################################################
\n
'
;
let
logs
=
'
####################################################### Docker Compose & Main Container Logs #######################################################
\n
'
;
const
dockerCompose
=
spawn
(
`
${
dockerComposeCommand
}
run
${
exerciceEnonce
.
enonceFile
.
result
.
container
}
`
,
{
const
dockerCompose
=
spawn
(
`
${
dockerComposeCommand
}
run
${
exerciceEnonce
.
enonceFile
.
result
.
container
}
`
,
{
cwd
:
Config
.
f
ilesF
older
,
cwd
:
Config
.
folder
s
.
project
,
shell
:
true
,
shell
:
true
,
env
:
{
env
:
{
'
DOCKER_BUILDKIT
'
:
'
1
'
,
'
DOCKER_BUILDKIT
'
:
'
1
'
,
...
@@ -77,23 +81,24 @@ import Config from './config/Config';
...
@@ -77,23 +81,24 @@ import Config from './config/Config';
});
});
});
});
if
(
containerExitStatus
[
0
]
===
ExerciceCheckerError
.
DOCKER_COMPOSE_UP_ERROR
)
{
if
(
containerExitStatus
[
0
]
===
ExerciceCheckerError
.
DOCKER_COMPOSE_UP_ERROR
)
{
console
.
error
(
chalk
.
red
(
`Error while running the docker
-
compose file`
));
console
.
error
(
chalk
.
red
(
`
X
Error while running the docker
compose file`
));
process
.
exit
(
containerExitStatus
[
0
]);
process
.
exit
(
containerExitStatus
[
0
]);
}
}
fs
.
writeFileSync
(
`
${
Config
.
results
Folder
}
/dockerComposeLogs.txt`
,
containerExitStatus
[
1
]);
fs
.
writeFileSync
(
`
${
Config
.
folders
.
results
Dojo
}
/dockerComposeLogs.txt`
,
containerExitStatus
[
1
]);
console
.
log
(
chalk
.
green
(
'
- Acquire logs of linked services
'
));
try
{
try
{
await
execAsync
(
`
${
changeDirectoryCommand
}
;
${
dockerComposeCommand
}
logs --timestamps >>
${
Config
.
results
Folder
}
/dockerComposeLogs.txt`
);
await
execAsync
(
`
${
changeDirectoryCommand
}
;
${
dockerComposeCommand
}
logs --timestamps >>
${
Config
.
folders
.
results
Dojo
}
/dockerComposeLogs.txt`
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
chalk
.
red
(
`Error while getting the
docker-compose
logs`
));
console
.
error
(
chalk
.
red
(
`
X
Error while getting the
linked services
logs`
));
process
.
exit
(
ExerciceCheckerError
.
DOCKER_COMPOSE_LOGS_ERROR
);
process
.
exit
(
ExerciceCheckerError
.
DOCKER_COMPOSE_LOGS_ERROR
);
}
}
// 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
// Step 8: Exit with container exit code
process
.
exit
(
containerExitStatus
[
0
]);
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