Skip to content

Commit

Permalink
Integrated code lifecycle: Insert repository content consistently whe…
Browse files Browse the repository at this point in the history
…n preparing for building (#9521)
  • Loading branch information
SimonEntholzer authored Oct 27, 2024
1 parent 3b1b15e commit e13b4a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,17 @@ 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++) {
addAndPrepareDirectory(buildJobContainerId, auxiliaryRepositoriesPaths[i], LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + auxiliaryRepositoryCheckoutDirectories[i]);
addAndPrepareDirectoryAndReplaceContent(buildJobContainerId, auxiliaryRepositoriesPaths[i],
LOCALCI_WORKING_DIRECTORY + "/testing-dir/" + auxiliaryRepositoryCheckoutDirectories[i]);
}

createScriptFile(buildJobContainerId);
Expand All @@ -320,12 +321,17 @@ 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) {
private void addAndPrepareDirectoryAndReplaceContent(String containerId, Path repositoryPath, String newDirectoryName) {
copyToContainer(repositoryPath.toString(), containerId);
addDirectory(containerId, getParentFolderPath(newDirectoryName), true);
addDirectory(containerId, newDirectoryName, true);
removeDirectoryAndFiles(containerId, newDirectoryName);
renameDirectoryOrFile(containerId, LOCALCI_WORKING_DIRECTORY + "/" + repositoryPath.getFileName().toString(), newDirectoryName);
}

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) {
executeDockerCommand(containerId, null, false, false, true, "mv", oldName, newName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#creation-config-selector {
position: relative;
}

::ng-deep .tooltip-inner {
max-width: 600px;
}
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/de/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,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. 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",
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/en/programmingExercise.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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",
Expand Down

0 comments on commit e13b4a8

Please sign in to comment.