From df8f4470378d232a5ccbbf799e210dd8faba7a0d Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 19 Oct 2024 00:46:51 +0200 Subject: [PATCH 1/7] try to fix bug --- .../service/BuildJobContainerService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java index b7c97daa9786..3449f11518a6 100644 --- a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java +++ b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java @@ -309,7 +309,8 @@ public void populateBuildJobContainer(String buildJobContainerId, Path assignmen addAndPrepareDirectory(buildJobContainerId, solutionRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + solutionCheckoutPath); } for (int i = 0; i < auxiliaryRepositoriesPaths.length; i++) { - addAndPrepareDirectory(buildJobContainerId, auxiliaryRepositoriesPaths[i], LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + auxiliaryRepositoryCheckoutDirectories[i]); + addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, auxiliaryRepositoriesPaths[i], + LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + auxiliaryRepositoryCheckoutDirectories[i]); } createScriptFile(buildJobContainerId); @@ -326,6 +327,16 @@ private void addAndPrepareDirectory(String containerId, Path repositoryPath, Str renameDirectoryOrFile(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName); } + private void addAndPrepareDirectoryAndReplaceContent(String containerId, Path repositoryPath, String newDirectoryName) { + copyToContainer(repositoryPath.toString(), containerId); + addDirectory(containerId, newDirectoryName, true); + renameDirectoryOrFileAndReplace(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString() + "/*", newDirectoryName + "/"); + } + + private void renameDirectoryOrFileAndReplace(String containerId, String oldName, String newName) { + executeDockerCommand(containerId, null, false, false, true, "mv", "-f", oldName, newName); + } + private void renameDirectoryOrFile(String containerId, String oldName, String newName) { executeDockerCommand(containerId, null, false, false, true, "mv", oldName, newName); } From 38ad7bfc39b02a375c5624ff668640031d2019c5 Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 19 Oct 2024 10:39:51 +0200 Subject: [PATCH 2/7] remove existing files before moving --- .../buildagent/service/BuildJobContainerService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java index 3449f11518a6..ded946c3b314 100644 --- a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java +++ b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java @@ -103,8 +103,8 @@ public CreateContainerResponse configureContainer(String containerName, String i // container from exiting until it finishes. // It waits until the script that is running the tests (see below execCreateCmdResponse) is completed, and until the result files are extracted which is indicated // by the creation of a file "stop_container.txt" in the container's root directory. - .withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done") - // .withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using + // .withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done") + .withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using // "docker exec -it /bin/bash". .exec(); } @@ -330,11 +330,12 @@ private void addAndPrepareDirectory(String containerId, Path repositoryPath, Str private void addAndPrepareDirectoryAndReplaceContent(String containerId, Path repositoryPath, String newDirectoryName) { copyToContainer(repositoryPath.toString(), containerId); addDirectory(containerId, newDirectoryName, true); - renameDirectoryOrFileAndReplace(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString() + "/*", newDirectoryName + "/"); + removeDirectoryAndFiles(containerId, newDirectoryName); + renameDirectoryOrFile(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName); } - private void renameDirectoryOrFileAndReplace(String containerId, String oldName, String newName) { - executeDockerCommand(containerId, null, false, false, true, "mv", "-f", oldName, newName); + private void removeDirectoryAndFiles(String containerId, String newName) { + executeDockerCommand(containerId, null, false, false, true, "rm", "-rf", newName); } private void renameDirectoryOrFile(String containerId, String oldName, String newName) { From c8d5156b185410ed9198e76c1172cf6e320c867e Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 19 Oct 2024 10:40:46 +0200 Subject: [PATCH 3/7] remove debugging --- .../artemis/buildagent/service/BuildJobContainerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java index ded946c3b314..2d9aa4f32930 100644 --- a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java +++ b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java @@ -103,8 +103,8 @@ public CreateContainerResponse configureContainer(String containerName, String i // container from exiting until it finishes. // It waits until the script that is running the tests (see below execCreateCmdResponse) is completed, and until the result files are extracted which is indicated // by the creation of a file "stop_container.txt" in the container's root directory. - // .withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done") - .withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using + .withCmd("sh", "-c", "while [ ! -f " + LOCALCI_WORKING_DIRECTORY + "/stop_container.txt ]; do sleep 0.5; done") + // .withCmd("tail", "-f", "/dev/null") // Activate for debugging purposes instead of the above command to get a running container that you can peek into using // "docker exec -it /bin/bash". .exec(); } From 6819d5f7d743431273b7f133b7f0207c6737e5fd Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 19 Oct 2024 13:55:44 +0200 Subject: [PATCH 4/7] imporve aux repo tool tip --- .../programming-exercise-information.component.scss | 4 ++++ src/main/webapp/i18n/de/programmingExercise.json | 2 +- src/main/webapp/i18n/en/programmingExercise.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/exercises/programming/manage/update/update-components/programming-exercise-information.component.scss b/src/main/webapp/app/exercises/programming/manage/update/update-components/programming-exercise-information.component.scss index 76bf7863f5c5..47462abdee4e 100644 --- a/src/main/webapp/app/exercises/programming/manage/update/update-components/programming-exercise-information.component.scss +++ b/src/main/webapp/app/exercises/programming/manage/update/update-components/programming-exercise-information.component.scss @@ -1,3 +1,7 @@ #creation-config-selector { position: relative; } + +::ng-deep .tooltip-inner { + max-width: 600px; +} diff --git a/src/main/webapp/i18n/de/programmingExercise.json b/src/main/webapp/i18n/de/programmingExercise.json index 387ffb3f548a..4081f50b033a 100644 --- a/src/main/webapp/i18n/de/programmingExercise.json +++ b/src/main/webapp/i18n/de/programmingExercise.json @@ -519,7 +519,7 @@ "auxiliaryRepository": { "error": "Es gibt ein Problem mit den Hilfs-Repositories!", "addAuxiliaryRepository": "Hilfs-Repository anlegen", - "usageDescription": "Du kannst Hilfsrepositorys verwenden, um zusätzlichen Code bereitzustellen, den Studierende nicht sehen oder ändern können. Der zusätzliche Code wird während des Builds der Abgabe am angegebenen Checkout-Verzeichnis eingefügt.", + "usageDescription": "Du kannst Hilfsrepositorien verwenden, um zusätzlichen Code bereitzustellen, den die Studierenden nicht sehen oder ändern können. Der zusätzliche Code wird im angegebenen Checkout-Verzeichnis eingefügt, bevor der Build erstellt wird. Er wird durch eine mv Operation eingefügt. Das bedeutet, dass es einen Unterschied beim Einfügen gibt, je nachdem, ob der Ordner des Checkout-Verzeichnis bereits existiert oder nicht. Wenn der Ordner existiert, wird der Inhalt des Repositorys im Checkout-Verzeichnis in einen neuen Ordner mit dem Namen des Repositorys eingefügt. Existiert der Ordner nicht, wird ein neuer Ordner im Checkout-Verzeichnis erstellt und der Inhalt des Hilfsrepositorys direkt dort eingefügt. Um die Dateien der Studierenden zu überschreiben, musst du das Build-Skript anpassen.", "repositoryName": "Name des Repositorys", "checkoutDirectory": "Checkout-Verzeichnis", "description": "Beschreibung", diff --git a/src/main/webapp/i18n/en/programmingExercise.json b/src/main/webapp/i18n/en/programmingExercise.json index f4163cf7a4d8..51c6831affcb 100644 --- a/src/main/webapp/i18n/en/programmingExercise.json +++ b/src/main/webapp/i18n/en/programmingExercise.json @@ -519,7 +519,7 @@ "auxiliaryRepository": { "error": "There is a problem with the auxiliary repository.", "addAuxiliaryRepository": "Add Auxiliary Repository", - "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted at the specified Checkout Directory during the build of the submission.", + "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted at the specified Checkout Directory before the build of the submission. It is inserted via a mv operation. This means, there is a difference on how it is inserted, depending whether the checkout dir already exists or not. If it exists, the repository's content is added at the checkout dir in a new folder with the repository's name. If it does not exist, the checkout dir's folder is created and the auxiliary repositories content is inserted directly there. To overwrite student's files, you need to adapt the build script.", "repositoryName": "Repository Name", "checkoutDirectory": "Checkout Directory", "description": "Description", From 5ef7749f49ffa60e8f0429426bdf3acb14b99803 Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 26 Oct 2024 17:42:06 +0200 Subject: [PATCH 5/7] added suggested changes --- src/main/webapp/i18n/en/programmingExercise.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/i18n/en/programmingExercise.json b/src/main/webapp/i18n/en/programmingExercise.json index 460b8d56791a..96645c02c4cf 100644 --- a/src/main/webapp/i18n/en/programmingExercise.json +++ b/src/main/webapp/i18n/en/programmingExercise.json @@ -535,7 +535,7 @@ "auxiliaryRepository": { "error": "There is a problem with the auxiliary repository.", "addAuxiliaryRepository": "Add Auxiliary Repository", - "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted at the specified Checkout Directory before the build of the submission. It is inserted via a mv operation. This means, there is a difference on how it is inserted, depending whether the checkout dir already exists or not. If it exists, the repository's content is added at the checkout dir in a new folder with the repository's name. If it does not exist, the checkout dir's folder is created and the auxiliary repositories content is inserted directly there. To overwrite student's files, you need to adapt the build script.", + "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted into the specified checkout directory before the submission is built, using a mv operation. This means, there is a difference on how it is inserted, depending on whether the checkout directory already exists or not. If it exists, the repository's content is added as a new folder within the checkout directory with the repository's name. If it does not exist, the checkout directory's folder is created and the auxiliary repositories content is inserted directly into it. To overwrite student's files, you need to adapt the build script.", "repositoryName": "Repository Name", "checkoutDirectory": "Checkout Directory", "description": "Description", From aa2882229318794d968ca4745901d11104ace4ab Mon Sep 17 00:00:00 2001 From: entholzer Date: Sat, 26 Oct 2024 23:36:08 +0200 Subject: [PATCH 6/7] same functionality for all repository types --- .../buildagent/service/BuildJobContainerService.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java index 2d9aa4f32930..5d4c72d5b491 100644 --- a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java +++ b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobContainerService.java @@ -300,13 +300,13 @@ public void populateBuildJobContainer(String buildJobContainerId, Path assignmen executeDockerCommand(buildJobContainerId, null, false, false, true, "chmod", "-R", "777", LOCALCI_WORKING_DIRECTORY + "/testing-dir"); // Copy the test repository to the container and move it to the test checkout path (may be the working directory) - addAndPrepareDirectory(buildJobContainerId, testRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + testCheckoutPath); + addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, testRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + testCheckoutPath); // Copy the assignment repository to the container and move it to the assignment checkout path - addAndPrepareDirectory(buildJobContainerId, assignmentRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + assignmentCheckoutPath); + addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, assignmentRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + assignmentCheckoutPath); if (solutionRepositoryPath != null) { solutionCheckoutPath = (!StringUtils.isBlank(solutionCheckoutPath)) ? solutionCheckoutPath : RepositoryCheckoutPath.SOLUTION.forProgrammingLanguage(programmingLanguage); - addAndPrepareDirectory(buildJobContainerId, solutionRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + solutionCheckoutPath); + addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, solutionRepositoryPath, LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + solutionCheckoutPath); } for (int i = 0; i < auxiliaryRepositoriesPaths.length; i++) { addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, auxiliaryRepositoriesPaths[i], @@ -321,12 +321,6 @@ private void createScriptFile(String buildJobContainerId) { executeDockerCommand(buildJobContainerId, null, false, false, true, "bash", "-c", "chmod +x " + LOCALCI_WORKING_DIRECTORY + "/script.sh"); } - private void addAndPrepareDirectory(String containerId, Path repositoryPath, String newDirectoryName) { - copyToContainer(repositoryPath.toString(), containerId); - addDirectory(containerId, getParentFolderPath(newDirectoryName), true); - renameDirectoryOrFile(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName); - } - private void addAndPrepareDirectoryAndReplaceContent(String containerId, Path repositoryPath, String newDirectoryName) { copyToContainer(repositoryPath.toString(), containerId); addDirectory(containerId, newDirectoryName, true); From d6cd82580262ae6db26c1cc71b1c3b4875765bb5 Mon Sep 17 00:00:00 2001 From: entholzer Date: Sun, 27 Oct 2024 00:21:40 +0200 Subject: [PATCH 7/7] change tootlitp to reflect new functionality --- src/main/webapp/i18n/de/programmingExercise.json | 2 +- src/main/webapp/i18n/en/programmingExercise.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/i18n/de/programmingExercise.json b/src/main/webapp/i18n/de/programmingExercise.json index cd404377979d..733fdeaaf120 100644 --- a/src/main/webapp/i18n/de/programmingExercise.json +++ b/src/main/webapp/i18n/de/programmingExercise.json @@ -535,7 +535,7 @@ "auxiliaryRepository": { "error": "Es gibt ein Problem mit den Hilfs-Repositories!", "addAuxiliaryRepository": "Hilfs-Repository anlegen", - "usageDescription": "Du kannst Hilfsrepositorien verwenden, um zusätzlichen Code bereitzustellen, den die Studierenden nicht sehen oder ändern können. Der zusätzliche Code wird im angegebenen Checkout-Verzeichnis eingefügt, bevor der Build erstellt wird. Er wird durch eine mv Operation eingefügt. Das bedeutet, dass es einen Unterschied beim Einfügen gibt, je nachdem, ob der Ordner des Checkout-Verzeichnis bereits existiert oder nicht. Wenn der Ordner existiert, wird der Inhalt des Repositorys im Checkout-Verzeichnis in einen neuen Ordner mit dem Namen des Repositorys eingefügt. Existiert der Ordner nicht, wird ein neuer Ordner im Checkout-Verzeichnis erstellt und der Inhalt des Hilfsrepositorys direkt dort eingefügt. Um die Dateien der Studierenden zu überschreiben, musst du das Build-Skript anpassen.", + "usageDescription": "Du kannst Hilfsrepositorien verwenden, um zusätzlichen Code bereitzustellen, den die Studierenden nicht sehen oder ändern können. Der zusätzliche Code wird im angegebenen Checkout-Verzeichnis eingefügt, bevor der Build erstellt wird. Der eingefügte Code überschreibt alles, was sich an der durch das Checkout-Verzeichnis angegebenen Stelle befindet. Wenn du die Dateien der Studierenden nur teilweise überschreiben willst, muss das Build-Skript angepasst werden.", "repositoryName": "Name des Repositorys", "checkoutDirectory": "Checkout-Verzeichnis", "description": "Beschreibung", diff --git a/src/main/webapp/i18n/en/programmingExercise.json b/src/main/webapp/i18n/en/programmingExercise.json index 96645c02c4cf..ff251a44ef57 100644 --- a/src/main/webapp/i18n/en/programmingExercise.json +++ b/src/main/webapp/i18n/en/programmingExercise.json @@ -535,7 +535,7 @@ "auxiliaryRepository": { "error": "There is a problem with the auxiliary repository.", "addAuxiliaryRepository": "Add Auxiliary Repository", - "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted into the specified checkout directory before the submission is built, using a mv operation. This means, there is a difference on how it is inserted, depending on whether the checkout directory already exists or not. If it exists, the repository's content is added as a new folder within the checkout directory with the repository's name. If it does not exist, the checkout directory's folder is created and the auxiliary repositories content is inserted directly into it. To overwrite student's files, you need to adapt the build script.", + "usageDescription": "You can use auxiliary repositories to provide additional code that students cannot see or modify. The additional code is inserted into the specified checkout directory before the submission is built. The inserted code overwrites everything which lies at the location specified by the checkout directory. If you only need to overwrite student files partially, you need to adapt the build script.", "repositoryName": "Repository Name", "checkoutDirectory": "Checkout Directory", "description": "Description",