Skip to content

Commit

Permalink
remove remaining prod and test code referring to hestia
Browse files Browse the repository at this point in the history
  • Loading branch information
krusche committed Dec 10, 2024
1 parent 3256303 commit 809684b
Show file tree
Hide file tree
Showing 63 changed files with 58 additions and 5,034 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ public ResponseEntity<Void> processNewProgrammingExerciseResult(@RequestHeader("
// This method will return without triggering the build if the submission is not of type TEST.
var programmingSubmission = (ProgrammingSubmission) result.getSubmission();
triggerTemplateBuildIfTestCasesChanged(participation.getProgrammingExercise().getId(), programmingSubmission);

// the test cases and the submission have been saved to the database previously, therefore we can add the reference to the coverage reports
if (Boolean.TRUE.equals(participation.getProgrammingExercise().getBuildConfig().isTestwiseCoverageEnabled()) && Boolean.TRUE.equals(result.isSuccessful())) {
testwiseCoverageService.createTestwiseCoverageReport(result.getCoverageFileReportsByTestCaseName(), participation.getProgrammingExercise(),
programmingSubmission);
}
}

programmingMessagingService.notifyUserAboutNewResult(result, participation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ else if (foundByShortName.isPresent()) {

private void clearProgrammingExerciseAttributes(ProgrammingExercise programmingExercise) {
programmingExercise.setTasks(null);
programmingExercise.setExerciseHints(new HashSet<>());
programmingExercise.setTestCases(new HashSet<>());
programmingExercise.setStaticCodeAnalysisCategories(new HashSet<>());
programmingExercise.setTeams(new HashSet<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

// NOTE: this data structure is used in shared code between core and build agent nodes. Changing it requires that the shared data structures in Hazelcast (or potentially Redis)
// in the future are migrated or cleared. Changes should be communicated in release notes as potentially breaking changes.
// TODO: reduce the amount of parameters and combine some in smaller record DTOs
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record BuildConfig(String buildScript, String dockerImage, String commitHashToBuild, String assignmentCommitHash, String testCommitHash, String branch,
ProgrammingLanguage programmingLanguage, ProjectType projectType, boolean scaEnabled, boolean sequentialTestRunsEnabled, boolean testwiseCoverageEnabled,
List<String> resultPaths, int timeoutSeconds, String assignmentCheckoutPath, String testCheckoutPath, String solutionCheckoutPath, DockerRunConfig dockerRunConfig)
implements Serializable {
ProgrammingLanguage programmingLanguage, ProjectType projectType, boolean scaEnabled, boolean sequentialTestRunsEnabled, List<String> resultPaths, int timeoutSeconds,
String assignmentCheckoutPath, String testCheckoutPath, String solutionCheckoutPath, DockerRunConfig dockerRunConfig) implements Serializable {

@Override
public String dockerImage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@ else if (entity instanceof ApollonDiagram diagram) {
else if (entity instanceof Exam exam) {
evictIdFromCache("examTitle", exam.getId());
}
else if (entity instanceof ExerciseHint hint) {
if (hint.getExercise() == null) {
log.warn("Unable to clear title of exercise hint {}: Exercise not present", hint.getId());
return;
}

var combinedId = hint.getExercise().getId() + "-" + hint.getId();
evictIdFromCache("exerciseHintTitle", combinedId);
}
else if (entity instanceof ExerciseGroup exerciseGroup) {
if (!Hibernate.isInitialized(exerciseGroup.getExercises())) {
log.warn("Unable to clear title of exercises from exercise group {}: Exercises not initialized", exerciseGroup.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,6 @@ enum ProgrammingExerciseFetchOptions implements FetchOptions {
Tasks(ProgrammingExercise_.TASKS),
StaticCodeAnalysisCategories(ProgrammingExercise_.STATIC_CODE_ANALYSIS_CATEGORIES),
SubmissionPolicy(ProgrammingExercise_.SUBMISSION_POLICY),
ExerciseHints(ProgrammingExercise_.EXERCISE_HINTS),
CompetencyLinks(ProgrammingExercise_.COMPETENCY_LINKS),
Teams(ProgrammingExercise_.TEAMS),
TutorParticipations(ProgrammingExercise_.TUTOR_PARTICIPATIONS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ public String getCachedScript(String key) {
* @param projectType the project type for which the template file should be returned. If omitted, a default depending on the language will be used.
* @param staticAnalysis whether the static analysis template should be used
* @param sequentialRuns whether the sequential runs template should be used
* @param testCoverage whether the test coverage template should be used
* @return the requested template as a bash script
* @throws IOException if the file does not exist
*/
public String getScriptFor(ProgrammingLanguage programmingLanguage, Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns, Boolean testCoverage)
throws IOException {
String templateFileName = buildTemplateName(projectType, staticAnalysis, sequentialRuns, testCoverage, "sh");
public String getScriptFor(ProgrammingLanguage programmingLanguage, Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns) throws IOException {
String templateFileName = buildTemplateName(projectType, staticAnalysis, sequentialRuns, "sh");
String uniqueKey = programmingLanguage.name().toLowerCase() + "_" + templateFileName;
if (scriptCache.containsKey(uniqueKey)) {
log.debug("Returning cached script for {}", uniqueKey);
Expand Down Expand Up @@ -139,7 +137,7 @@ public String getScriptFor(ProgrammingExercise exercise) {
try {
ProgrammingExerciseBuildConfig buildConfig = exercise.getBuildConfig();
return getScriptFor(exercise.getProgrammingLanguage(), Optional.ofNullable(exercise.getProjectType()), exercise.isStaticCodeAnalysisEnabled(),
buildConfig.hasSequentialTestRuns(), buildConfig.isTestwiseCoverageEnabled());
buildConfig.hasSequentialTestRuns());
}
catch (IOException e) {
log.error("Failed to provide build script for programming exercise " + exercise.getId(), e);
Expand All @@ -153,11 +151,10 @@ public String getScriptFor(ProgrammingExercise exercise) {
* @param projectType The project type for which the template file should be returned. If omitted, a default depending on the language will be used.
* @param staticAnalysis whether the static analysis template should be used
* @param sequentialRuns whether the sequential runs template should be used
* @param testCoverage whether the test coverage template should be used
* @param fileExtension the file extension of the template file
* @return The filename of the requested configuration
*/
public String buildTemplateName(Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns, Boolean testCoverage, String fileExtension) {
public String buildTemplateName(Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns, String fileExtension) {
List<String> fileNameComponents = new ArrayList<>();

if (ProjectType.MAVEN_BLACKBOX.equals(projectType.orElse(null))) {
Expand All @@ -173,9 +170,6 @@ public String buildTemplateName(Optional<ProjectType> projectType, Boolean stati
if (sequentialRuns) {
fileNameComponents.add("sequential");
}
if (testCoverage) {
fileNameComponents.add("coverage");
}
return String.join("_", fileNameComponents) + "." + fileExtension;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public String getScript(ProgrammingExercise programmingExercise) {
try {
ProgrammingExerciseBuildConfig buildConfig = programmingExercise.getBuildConfig();
return buildScriptProviderService.getScriptFor(programmingExercise.getProgrammingLanguage(), Optional.ofNullable(programmingExercise.getProjectType()),
programmingExercise.isStaticCodeAnalysisEnabled(), buildConfig.hasSequentialTestRuns(), buildConfig.isTestwiseCoverageEnabled());
programmingExercise.isStaticCodeAnalysisEnabled(), buildConfig.hasSequentialTestRuns());
}
catch (IOException e) {
log.error("Failed to generate build script for programming exercise " + programmingExercise.getId(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ private void setupJVMTestTemplateAndPush(final RepositoryResources resources, fi
final Map<String, Boolean> sectionsMap = new HashMap<>();
// Keep or delete static code analysis configuration in the build configuration file
sectionsMap.put("static-code-analysis", Boolean.TRUE.equals(programmingExercise.isStaticCodeAnalysisEnabled()));
// Keep or delete testwise coverage configuration in the build file
sectionsMap.put("record-testwise-coverage", Boolean.TRUE.equals(programmingExercise.getBuildConfig().isTestwiseCoverageEnabled()));

if (programmingExercise.getBuildConfig().hasSequentialTestRuns()) {
setupTestTemplateSequentialTestRuns(resources, templatePath, projectTemplatePath, projectType, sectionsMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,6 @@ public void validateNewProgrammingExerciseSettings(ProgrammingExercise programmi
throw new BadRequestAlertException("Checkout solution repository is not supported for this programming language", "Exercise", "checkoutSolutionRepositoryNotSupported");
}

// Check if testwise coverage analysis is enabled
if (Boolean.TRUE.equals(buildConfig.isTestwiseCoverageEnabled()) && !programmingLanguageFeature.testwiseCoverageAnalysisSupported()) {
throw new BadRequestAlertException("Testwise coverage analysis is not supported for this language", "Exercise", "testwiseCoverageAnalysisNotSupported");
}

programmingExerciseRepository.validateCourseSettings(programmingExercise, course);
validateStaticCodeAnalysisSettings(programmingExercise);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ private static Windfile readWindfile(String yaml) throws IOException {
* @return the requested template as a {@link Windfile} object
* @throws IOException if the file does not exist
*/
public Windfile getWindfileFor(ProgrammingLanguage programmingLanguage, Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns, Boolean testCoverage)
throws IOException {
public Windfile getWindfileFor(ProgrammingLanguage programmingLanguage, Optional<ProjectType> projectType, Boolean staticAnalysis, Boolean sequentialRuns) throws IOException {
if (programmingLanguage.equals(ProgrammingLanguage.JAVA) && projectType.isEmpty()) {
// to be backwards compatible, we assume that java exercises without project type are plain maven projects
projectType = Optional.of(ProjectType.PLAIN_MAVEN);
}
String templateFileName = buildScriptProviderService.buildTemplateName(projectType, staticAnalysis, sequentialRuns, testCoverage, "yaml");
String templateFileName = buildScriptProviderService.buildTemplateName(projectType, staticAnalysis, sequentialRuns, "yaml");
String uniqueKey = programmingLanguage.name().toLowerCase() + "_" + templateFileName;
if (templateCache.containsKey(uniqueKey)) {
return templateCache.get(uniqueKey);
Expand Down Expand Up @@ -184,7 +183,7 @@ public Windfile getDefaultWindfileFor(ProgrammingExercise exercise) {
try {
ProgrammingExerciseBuildConfig buildConfig = exercise.getBuildConfig();
return getWindfileFor(exercise.getProgrammingLanguage(), Optional.ofNullable(exercise.getProjectType()), exercise.isStaticCodeAnalysisEnabled(),
buildConfig.hasSequentialTestRuns(), buildConfig.isTestwiseCoverageEnabled());
buildConfig.hasSequentialTestRuns());
}
catch (IOException e) {
log.info("No windfile for the settings of exercise {}", exercise.getId(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ public abstract class AbstractContinuousIntegrationResultService implements Cont

protected final BuildLogStatisticsEntryRepository buildLogStatisticsEntryRepository;

protected final TestwiseCoverageService testwiseCoverageService;

protected final ProgrammingExerciseFeedbackCreationService feedbackCreationService;

protected final ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository;

protected AbstractContinuousIntegrationResultService(ProgrammingExerciseTestCaseRepository testCaseRepository,
BuildLogStatisticsEntryRepository buildLogStatisticsEntryRepository, TestwiseCoverageService testwiseCoverageService,
ProgrammingExerciseFeedbackCreationService feedbackCreationService, ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository) {
BuildLogStatisticsEntryRepository buildLogStatisticsEntryRepository, ProgrammingExerciseFeedbackCreationService feedbackCreationService,
ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository) {
this.testCaseRepository = testCaseRepository;
this.buildLogStatisticsEntryRepository = buildLogStatisticsEntryRepository;
this.testwiseCoverageService = testwiseCoverageService;
this.feedbackCreationService = feedbackCreationService;
this.programmingExerciseBuildConfigRepository = programmingExerciseBuildConfigRepository;
}
Expand Down Expand Up @@ -71,9 +68,6 @@ private void addFeedbackToResult(Result result, AbstractBuildResultNotificationD

// 2) process static code analysis feedback
addStaticCodeAnalysisFeedbackToResult(result, buildResult, programmingExercise);

// 3) process testwise coverage analysis report
addTestwiseCoverageReportToResult(result, buildResult, programmingExercise);
}

private void addTestCaseFeedbacksToResult(Result result, List<? extends BuildJobDTOInterface> jobs, ProgrammingExercise programmingExercise) {
Expand Down Expand Up @@ -104,18 +98,6 @@ private void addStaticCodeAnalysisFeedbackToResult(Result result, AbstractBuildR
}
}

private void addTestwiseCoverageReportToResult(Result result, AbstractBuildResultNotificationDTO buildResult, ProgrammingExercise programmingExercise) {
programmingExercise.setBuildConfig(programmingExerciseBuildConfigRepository.getProgrammingExerciseBuildConfigElseThrow(programmingExercise));
if (Boolean.TRUE.equals(programmingExercise.getBuildConfig().isTestwiseCoverageEnabled())) {
var report = buildResult.getTestwiseCoverageReports();
if (report != null) {
// since the test cases are not saved to the database yet, the test case is null for the entries
var coverageFileReportsWithoutTestsByTestCaseName = testwiseCoverageService.createTestwiseCoverageFileReportsWithoutTestsByTestCaseName(report);
result.setCoverageFileReportsByTestCaseName(coverageFileReportsWithoutTestsByTestCaseName);
}
}
}

/**
* Find the ZonedDateTime of the first BuildLogEntry that contains the searchString in the log message.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission;
import de.tum.cit.aet.artemis.programming.domain.ProjectType;
Expand All @@ -18,8 +17,6 @@
import de.tum.cit.aet.artemis.programming.repository.BuildLogStatisticsEntryRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingSubmissionRepository;
import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService;
import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseFeedbackCreationService;
import de.tum.cit.aet.artemis.programming.service.ci.AbstractContinuousIntegrationResultService;
import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestResultsDTO;
Expand All @@ -33,11 +30,9 @@ public class GitLabCIResultService extends AbstractContinuousIntegrationResultSe

private static final Logger log = LoggerFactory.getLogger(GitLabCIResultService.class);

public GitLabCIResultService(ProgrammingSubmissionRepository programmingSubmissionRepository, FeedbackRepository feedbackRepository, BuildLogEntryService buildLogService,
BuildLogStatisticsEntryRepository buildLogStatisticsEntryRepository, TestwiseCoverageService testwiseCoverageService,
ProgrammingExerciseFeedbackCreationService feedbackCreationService, ProgrammingExerciseTestCaseRepository testCaseRepository,
ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository) {
super(testCaseRepository, buildLogStatisticsEntryRepository, testwiseCoverageService, feedbackCreationService, programmingExerciseBuildConfigRepository);
public GitLabCIResultService(BuildLogStatisticsEntryRepository buildLogStatisticsEntryRepository, ProgrammingExerciseFeedbackCreationService feedbackCreationService,
ProgrammingExerciseTestCaseRepository testCaseRepository, ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository) {
super(testCaseRepository, buildLogStatisticsEntryRepository, feedbackCreationService, programmingExerciseBuildConfigRepository);
}

@Override
Expand Down
Loading

0 comments on commit 809684b

Please sign in to comment.