Skip to content
Snippets Groups Projects
Commit c79ee818 authored by michael.minelli's avatar michael.minelli
Browse files

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
......@@ -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] })`));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment