Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
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
UI
DojoCLI
Commits
0dd0a7eb
Commit
0dd0a7eb
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
ExerciseRun => Adapt for optional results file
parent
ff18f6ff
No related branches found
No related tags found
No related merge requests found
Pipeline
#26558
passed
1 year ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
NodeApp/src/commander/exercise/ExerciseRunCommand.ts
+52
-26
52 additions, 26 deletions
NodeApp/src/commander/exercise/ExerciseRunCommand.ts
NodeApp/src/shared
+1
-1
1 addition, 1 deletion
NodeApp/src/shared
NodeApp/src/sharedByClients
+1
-1
1 addition, 1 deletion
NodeApp/src/sharedByClients
with
54 additions
and
28 deletions
NodeApp/src/commander/exercise/ExerciseRunCommand.ts
+
52
−
26
View file @
0dd0a7eb
...
...
@@ -10,10 +10,10 @@ import path from 'path';
import
ClientsSharedConfig
from
'
../../sharedByClients/config/ClientsSharedConfig
'
;
import
AssignmentFile
from
'
../../shared/types/Dojo/AssignmentFile
'
;
import
ExerciseDockerCompose
from
'
../../sharedByClients/helpers/Dojo/ExerciseDockerCompose
'
;
import
ExerciseResultsValidation
from
'
../../sharedByClients/helpers/Dojo/ExerciseResultsValidation
'
;
import
SharedAssignmentHelper
from
'
../../shared/helpers/Dojo/SharedAssignmentHelper
'
;
import
ExerciseCheckerError
from
'
../../shared/types/Dojo/ExerciseCheckerError
'
;
import
ClientsSharedExerciseHelper
from
'
../../sharedByClients/helpers/Dojo/ClientsSharedExerciseHelper
'
;
import
ExerciseResultsSanitizerAndValidator
from
'
../../sharedByClients/helpers/Dojo/ExerciseResultsSanitizerAndValidator
'
;
const
execAsync
=
util
.
promisify
(
exec
);
...
...
@@ -36,7 +36,7 @@ class ExerciseRunCommand extends CommanderCommand {
this
.
command
.
description
(
'
locally run an exercise
'
)
.
option
(
'
-p, --path <value>
'
,
'
exercise path
'
,
Config
.
folders
.
defaultLocalExercise
)
.
option
(
'
-v, --verbose
'
,
'
exercise path
'
,
Config
.
folders
.
defaultLocalExercise
)
.
option
(
'
-v, --verbose
'
,
'
verbose mode (display docker compose logs in live)
'
)
.
action
(
this
.
commandAction
.
bind
(
this
));
}
...
...
@@ -48,11 +48,13 @@ class ExerciseRunCommand extends CommanderCommand {
}
protected
async
commandAction
(
options
:
{
path
:
string
,
verbose
:
boolean
}):
Promise
<
void
>
{
const
localExercisePath
=
options
.
path
??
Config
.
folders
.
defaultLocalExercise
;
const
localExercisePath
:
string
=
options
.
path
??
Config
.
folders
.
defaultLocalExercise
;
let
assignmentFile
:
AssignmentFile
;
let
exerciseDockerCompose
:
ExerciseDockerCompose
;
let
exerciseResultsValidation
:
ExerciseResultsValidation
;
let
exerciseResultsValidation
:
ExerciseResultsSanitizerAndValidator
;
let
haveResultsVolume
:
boolean
;
// Step 1: Check requirements (if it's an exercise folder and if Docker deamon is running)
{
...
...
@@ -102,6 +104,8 @@ class ExerciseRunCommand extends CommanderCommand {
assignmentFile
=
validationResults
.
results
!
;
}
haveResultsVolume
=
assignmentFile
.
result
.
volume
!==
undefined
;
spinner
.
succeed
(
`The
${
Config
.
assignment
.
filename
}
file is valid`
);
}
...
...
@@ -128,12 +132,16 @@ class ExerciseRunCommand extends CommanderCommand {
{
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are running the exercise...
'
));
let
composeFileOverride
:
string
[]
=
[];
const
composeOverridePath
:
string
=
path
.
join
(
localExercisePath
,
'
docker-compose-override.yml
'
);
const
composeOverride
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
../../../assets/docker-compose-override.yml
'
),
'
utf8
'
).
replace
(
'
{{VOLUME_NAME}}
'
,
assignmentFile
.
result
.
volume
).
replace
(
'
{{MOUNT_PATH}}
'
,
this
.
folderResultsExercise
);
if
(
haveResultsVolume
)
{
const
composeOverride
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
../../../assets/docker-compose-override.yml
'
),
'
utf8
'
).
replace
(
'
{{VOLUME_NAME}}
'
,
assignmentFile
.
result
.
volume
!
).
replace
(
'
{{MOUNT_PATH}}
'
,
this
.
folderResultsExercise
);
fs
.
writeFileSync
(
composeOverridePath
,
composeOverride
);
exerciseDockerCompose
=
new
ExerciseDockerCompose
(
this
.
projectName
,
assignmentFile
,
localExercisePath
,
[
composeOverridePath
]);
composeFileOverride
=
[
composeOverridePath
];
}
exerciseDockerCompose
=
new
ExerciseDockerCompose
(
this
.
projectName
,
assignmentFile
,
localExercisePath
,
composeFileOverride
);
try
{
await
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
...
...
@@ -152,14 +160,32 @@ class ExerciseRunCommand extends CommanderCommand {
text
:
message
,
indent
:
4
}).
start
();
if
(
options
.
verbose
&&
name
==
'
COMPOSE_RUN
'
)
{
spinner
.
info
();
}
});
exerciseDockerCompose
.
events
.
on
(
'
endStep
'
,
(
stepName
:
string
,
message
:
string
,
error
:
boolean
)
=>
{
if
(
error
)
{
if
(
options
.
verbose
&&
stepName
==
'
COMPOSE_RUN
'
)
{
ora
({
text
:
message
,
indent
:
4
}).
start
().
fail
();
}
else
{
spinner
.
fail
(
message
);
}
}
else
{
if
(
options
.
verbose
&&
stepName
==
'
COMPOSE_RUN
'
)
{
ora
({
text
:
message
,
indent
:
4
}).
start
().
succeed
();
}
else
{
spinner
.
succeed
(
message
);
}
}
});
exerciseDockerCompose
.
events
.
on
(
'
finished
'
,
(
success
:
boolean
,
exitCode
:
number
)
=>
{
...
...
@@ -170,7 +196,7 @@ class ExerciseRunCommand extends CommanderCommand {
});
}
catch
(
error
)
{
}
fs
.
rmSync
(
composeOverridePath
);
fs
.
rmSync
(
composeOverridePath
,
{
force
:
true
}
);
fs
.
writeFileSync
(
this
.
fileComposeLogs
,
exerciseDockerCompose
.
allLogs
);
if
(
!
exerciseDockerCompose
.
success
)
{
...
...
@@ -184,7 +210,7 @@ class ExerciseRunCommand extends CommanderCommand {
{
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are checking the results...
'
));
exerciseResultsValidation
=
new
ExerciseResultsValidat
ion
(
this
.
folderResultsDojo
,
this
.
folderResultsExercise
);
exerciseResultsValidation
=
new
ExerciseResults
SanitizerAnd
Validat
or
(
this
.
folderResultsDojo
,
this
.
folderResultsExercise
,
exerciseDockerCompose
.
exitCode
);
try
{
await
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
shared
@
8bdbef31
Compare
8d7e3ca0
...
8bdbef31
Subproject commit 8
d7e3ca0cca10e874ac48e19e47da8a1491ccba7
Subproject commit 8
bdbef31376a8284bd8a5139588b43a57cf74a4b
This diff is collapsed.
Click to expand it.
sharedByClients
@
97ba763f
Compare
4ff3846e
...
97ba763f
Subproject commit
4ff3846e9415a6122b0b966be089eec3f0117f4f
Subproject commit
97ba763f9517880ecfa6245c172a0e330ebdd11a
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