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

Merge branch 'success_optional_and_compose_verbose' into v2.2.0

parents 75111aa1 74d83191
No related branches found
No related tags found
No related merge requests found
Pipeline #26557 passed
...@@ -21,14 +21,13 @@ ...@@ -21,14 +21,13 @@
- If the file is not present or the `success` field is not present: - If the file is not present or the `success` field is not present:
- The exercise will be considered as valid if the container exit code is 0 - The exercise will be considered as valid if the container exit code is 0
- The `results.json` file will be construct / completed with the container exit code - The `results.json` file will be construct / completed with the container exit code
- If the file is present, the exercise will be considered as valid
- The `volume` argument of `dojo_assignment.json` is now optional (if the teaching staff don't want to provide `results.json` file or other files) - The `volume` argument of `dojo_assignment.json` is now optional (if the teaching staff don't want to provide `results.json` file or other files)
### 🔨 Internal / Developers ### 🔨 Internal / Developers
- Enhancement in pipelines by splitting them into several files - Enhancement in pipelines by splitting them into several files
## 2.1.0 (?) ## 2.1.0 (2023-09-29)
### 🎨 Interface ### 🎨 Interface
- **💥 Breaking:** Renamed `dojo.enonce` (or `dojo.assignment`) file to `dojo_assignment.json` - **💥 Breaking:** Renamed `dojo.enonce` (or `dojo.assignment`) file to `dojo_assignment.json`
......
...@@ -21,7 +21,7 @@ import DojoBackendManager from './managers/DojoBackendManager'; ...@@ -21,7 +21,7 @@ import DojoBackendManager from './managers/DojoBackendManager';
import Config from './config/Config'; import Config from './config/Config';
import ArchiveHelper from './shared/helpers/ArchiveHelper'; import ArchiveHelper from './shared/helpers/ArchiveHelper';
import ExerciseDockerCompose from './sharedByClients/helpers/Dojo/ExerciseDockerCompose'; import ExerciseDockerCompose from './sharedByClients/helpers/Dojo/ExerciseDockerCompose';
import ExerciseResultsValidation from './sharedByClients/helpers/Dojo/ExerciseResultsValidation'; import ExerciseResultsSanitizerAndValidator from './sharedByClients/helpers/Dojo/ExerciseResultsSanitizerAndValidator';
import ExerciseAssignment from './sharedByClients/models/ExerciseAssignment'; import ExerciseAssignment from './sharedByClients/models/ExerciseAssignment';
import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsSharedExerciseHelper'; import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsSharedExerciseHelper';
...@@ -35,7 +35,10 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -35,7 +35,10 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
let exerciseAssignment: ExerciseAssignment | undefined; let exerciseAssignment: ExerciseAssignment | undefined;
let exerciseDockerCompose: ExerciseDockerCompose; let exerciseDockerCompose: ExerciseDockerCompose;
let exerciseResultsValidation: ExerciseResultsValidation; let exerciseResultsValidation: ExerciseResultsSanitizerAndValidator;
let haveResultsVolume: boolean;
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 1: //////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 1:
...@@ -55,6 +58,8 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -55,6 +58,8 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
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' });
}); });
haveResultsVolume = exerciseAssignment.assignmentFile.result.volume !== undefined;
} }
...@@ -65,12 +70,16 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -65,12 +70,16 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
- Get logs from linked services - Get logs from linked services
*/ */
{ {
let composeFileOverride: string[] = [];
const composeOverridePath: string = path.join(Config.folders.project, 'docker-compose-override.yml'); const composeOverridePath: string = path.join(Config.folders.project, 'docker-compose-override.yml');
if ( haveResultsVolume ) {
const composeOverride = fs.readFileSync(path.join(__dirname, '../assets/docker-compose-override.yml'), 'utf8').replace('{{VOLUME_NAME}}', exerciseAssignment.assignmentFile.result.volume).replace('{{MOUNT_PATH}}', Config.folders.resultsExercise); const composeOverride = fs.readFileSync(path.join(__dirname, '../assets/docker-compose-override.yml'), 'utf8').replace('{{VOLUME_NAME}}', exerciseAssignment.assignmentFile.result.volume!).replace('{{MOUNT_PATH}}', Config.folders.resultsExercise);
fs.writeFileSync(composeOverridePath, composeOverride); fs.writeFileSync(composeOverridePath, composeOverride);
exerciseDockerCompose = new ExerciseDockerCompose(ClientsSharedConfig.dockerCompose.projectName, exerciseAssignment.assignmentFile, Config.folders.project, [ composeOverridePath ]); composeFileOverride = [ composeOverridePath ];
}
exerciseDockerCompose = new ExerciseDockerCompose(ClientsSharedConfig.dockerCompose.projectName, exerciseAssignment.assignmentFile, Config.folders.project, composeFileOverride);
try { try {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
...@@ -92,7 +101,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -92,7 +101,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
}); });
} catch ( error ) { } } catch ( error ) { }
fs.rmSync(composeOverridePath); fs.rmSync(composeOverridePath, { force: true });
fs.writeFileSync(path.join(Config.folders.resultsDojo, 'dockerComposeLogs.txt'), exerciseDockerCompose.allLogs); fs.writeFileSync(path.join(Config.folders.resultsDojo, 'dockerComposeLogs.txt'), exerciseDockerCompose.allLogs);
if ( !exerciseDockerCompose.success ) { if ( !exerciseDockerCompose.success ) {
...@@ -104,7 +113,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -104,7 +113,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 3: Check content requirements and content size //////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 3: Check content requirements and content size
{ {
exerciseResultsValidation = new ExerciseResultsValidation(Config.folders.resultsDojo, Config.folders.resultsExercise); exerciseResultsValidation = new ExerciseResultsSanitizerAndValidator(Config.folders.resultsDojo, Config.folders.resultsExercise, exerciseDockerCompose.exitCode);
try { try {
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
...@@ -146,7 +155,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -146,7 +155,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
liteStats : true liteStats : true
}); });
await DojoBackendManager.sendResults(exerciseDockerCompose.exitCode, commit, exerciseResultsValidation.exerciseResults!, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume)); await DojoBackendManager.sendResults(exerciseDockerCompose.exitCode, commit, exerciseResultsValidation.exerciseResults, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume));
} catch ( error ) { } catch ( error ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Error while uploading the results`)); console.error(Styles.ERROR(`${ Icon.ERROR } Error while uploading the results`));
console.error(JSON.stringify(error)); console.error(JSON.stringify(error));
...@@ -161,7 +170,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -161,7 +170,7 @@ import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsS
- Exit with container exit code - Exit with container exit code
*/ */
{ {
ClientsSharedExerciseHelper.displayExecutionResults(exerciseResultsValidation.exerciseResults!, exerciseDockerCompose.exitCode, Styles, `\n\n${ Icon.INFO }️ More detailed logs and resources may be available in artifacts`); ClientsSharedExerciseHelper.displayExecutionResults(exerciseResultsValidation.exerciseResults, exerciseDockerCompose.exitCode, Styles, `\n\n${ Icon.INFO }️ More detailed logs and resources may be available in artifacts`);
process.exit(exerciseDockerCompose.exitCode); process.exit(exerciseDockerCompose.exitCode);
} }
......
Subproject commit 8d7e3ca0cca10e874ac48e19e47da8a1491ccba7 Subproject commit 8bdbef31376a8284bd8a5139588b43a57cf74a4b
Subproject commit 4ff3846e9415a6122b0b966be089eec3f0117f4f Subproject commit 97ba763f9517880ecfa6245c172a0e330ebdd11a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment