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
c79ee818
Commit
c79ee818
authored
1 year ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
Add step 7 => Upload of the results to the server
parent
f3184388
No related branches found
No related tags found
No related merge requests found
Pipeline
#25721
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
+22
-1
22 additions, 1 deletion
ExerciceChecker/src/app.ts
with
22 additions
and
1 deletion
ExerciceChecker/src/app.ts
+
22
−
1
View file @
c79ee818
...
...
@@ -4,6 +4,7 @@ const path = require('node:path');
require
(
'
dotenv
'
).
config
({
path
:
path
.
join
(
__dirname
,
'
../.env
'
)
});
require
(
'
./shared/helpers/TypeScriptExtensions
'
);
// ATTENTION : This line MUST be the second of this file
import
RecursiveFilesStats
from
'
./shared/helpers/recursiveFilesStats/RecursiveFilesStats
'
;
import
Toolbox
from
'
./shared/helpers/Toolbox
'
;
import
ExerciceHelper
from
'
./shared/helpers/ExerciceHelper
'
;
import
ExerciceCheckerError
from
'
./types/ExerciceCheckerError
'
;
...
...
@@ -14,6 +15,7 @@ import chalk from 'chalk';
import
HttpManager
from
'
./managers/HttpManager
'
;
import
DojoBackendManager
from
'
./managers/DojoBackendManager
'
;
import
Config
from
'
./config/Config
'
;
import
ArchiveHelper
from
'
./shared/helpers/ArchiveHelper
'
;
(
async
()
=>
{
...
...
@@ -55,7 +57,7 @@ import Config from './config/Config';
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
)
=>
{
let
logs
=
'
####################################################### Docker Compose & Main Container Logs #######################################################
\n
'
;
const
dockerCompose
=
spawn
(
`
${
dockerComposeCommand
}
run --build
${
exerciceEnonce
.
enonceFile
.
result
.
container
}
`
,
{
...
...
@@ -125,6 +127,25 @@ import Config from './config/Config';
}
// Step 7: Upload and show the results
try
{
console
.
log
(
chalk
.
green
(
`- Uploading results to the dojo server`
));
const
commit
:
any
=
{};
Toolbox
.
getKeysWithPrefix
(
process
.
env
,
'
CI_COMMIT_
'
).
forEach
(
key
=>
{
commit
[
Toolbox
.
snakeToCamel
(
key
.
replace
(
'
CI_COMMIT_
'
,
''
))]
=
process
.
env
[
key
];
});
const
files
=
await
RecursiveFilesStats
.
explore
(
Config
.
folders
.
resultsVolume
,
{
replacePathByRelativeOne
:
true
,
liteStats
:
true
});
await
DojoBackendManager
.
sendResults
(
containerExitStatus
[
0
],
commit
,
validationResults
.
results
!
,
files
,
await
ArchiveHelper
.
getBase64
(
Config
.
folders
.
resultsVolume
));
}
catch
(
error
)
{
console
.
error
(
chalk
.
red
(
`X Error while uploading the results`
));
console
.
error
(
JSON
.
stringify
(
error
));
process
.
exit
(
ExerciceCheckerError
.
UPLOAD
);
}
// Step 8: Exit with container exit code
console
.
log
(
chalk
.
green
(
`- Good bye (container's exit code :
${
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