Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Skip build triggers for programming exercises during file imports #7376

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public ProgrammingExercise importProgrammingExercise(ProgrammingExercise origina

if (recreateBuildPlans) {
// Create completely new build plans for the exercise
programmingExerciseService.setupBuildPlansForNewExercise(importedProgrammingExercise, true);
programmingExerciseService.setupBuildPlansForNewExercise(importedProgrammingExercise, false);
}
else {
// We have removed the automatic build trigger from test to base for new programming exercises.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ public ProgrammingExerciseService(ProgrammingExerciseRepository programmingExerc
* </ol>
*
* @param programmingExercise The programmingExercise that should be setup
* @param imported defines if the programming exercise is imported
* @param isImportedFromFile defines if the programming exercise is imported from a file
* @return The new setup exercise
* @throws GitAPIException If something during the communication with the remote Git repository went wrong
* @throws IOException If the template files couldn't be read
*/
@Transactional // TODO: apply the transaction on a smaller scope
// ok because we create many objects in a rather complex way and need a rollback in case of exceptions
public ProgrammingExercise createProgrammingExercise(ProgrammingExercise programmingExercise, boolean imported) throws GitAPIException, IOException {
public ProgrammingExercise createProgrammingExercise(ProgrammingExercise programmingExercise, boolean isImportedFromFile) throws GitAPIException, IOException {
programmingExercise.generateAndSetProjectKey();
final User exerciseCreator = userRepository.getUser();

Expand All @@ -223,7 +223,7 @@ public ProgrammingExercise createProgrammingExercise(ProgrammingExercise program

channelService.createExerciseChannel(savedProgrammingExercise, Optional.ofNullable(programmingExercise.getChannelName()));

setupBuildPlansForNewExercise(savedProgrammingExercise, imported);
setupBuildPlansForNewExercise(savedProgrammingExercise, isImportedFromFile);
// save to get the id required for the webhook
savedProgrammingExercise = programmingExerciseRepository.saveAndFlush(savedProgrammingExercise);

Expand Down Expand Up @@ -346,10 +346,10 @@ public void validateStaticCodeAnalysisSettings(ProgrammingExercise programmingEx
*
* @param programmingExercise Programming exercise for the build plans should be generated. The programming
* exercise should contain a fully initialized template and solution participation.
* @param isImported defines if the programming exercise is imported from a source exercise, if the
* @param isImportedFromFile defines if the programming exercise is imported from a file, if the
* exercise is imported, the build plans will not be triggered to prevent erroneous builds
*/
public void setupBuildPlansForNewExercise(ProgrammingExercise programmingExercise, boolean isImported) {
public void setupBuildPlansForNewExercise(ProgrammingExercise programmingExercise, boolean isImportedFromFile) {
String projectKey = programmingExercise.getProjectKey();
// Get URLs for repos
var exerciseRepoUrl = programmingExercise.getVcsTemplateRepositoryUrl();
Expand All @@ -370,7 +370,7 @@ public void setupBuildPlansForNewExercise(ProgrammingExercise programmingExercis

// if the exercise is imported from a file, the changes fixing the project name will trigger a first build anyway, so
// we do not trigger them here
if (!isImported) {
if (!isImportedFromFile) {
// trigger BASE and SOLUTION build plans once here
continuousIntegrationTriggerService.orElseThrow().triggerBuild(programmingExercise.getTemplateParticipation());
continuousIntegrationTriggerService.orElseThrow().triggerBuild(programmingExercise.getSolutionParticipation());
Expand Down
Loading