use of fr.inria.jtravis.entities.Job in project repairnator by Spirals-Team.
the class InspectJobs method run.
@Override
public void run() {
LOGGER.debug("Start running inspect Jobs...");
if (sleepTime == -1) {
throw new RuntimeException("Sleep time has to be set before running this.");
}
while (!shouldStop) {
List<Job> jobList = JobHelper.getJobList();
if (jobList != null) {
LOGGER.info("Retrieved " + jobList.size() + " jobs");
for (Job job : jobList) {
if (this.rtScanner.isRepositoryInteresting(job.getRepositoryId())) {
this.rtScanner.submitWaitingBuild(job.getBuildId());
}
}
}
if (this.rtScanner.getInspectBuilds().maxSubmittedBuildsReached() || jobList == null) {
LOGGER.debug("Max number of submitted builds reached. Sleep for " + sleepTime + " seconds.");
try {
Thread.sleep(sleepTime * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
LOGGER.info("This will now stop.");
}
use of fr.inria.jtravis.entities.Job in project repairnator by Spirals-Team.
the class RTScanner method submitBuildToExecution.
public void submitBuildToExecution(Build build) {
boolean failing = false;
List<Job> jobs = build.getJobs();
if (jobs != null) {
for (Job job : jobs) {
Log jobLog = job.getLog();
if (jobLog != null && jobLog.getTestsInformation() != null && (jobLog.getTestsInformation().getErrored() >= 0 || jobLog.getTestsInformation().getFailing() >= 0)) {
failing = true;
break;
}
}
}
if (failing) {
LOGGER.info("Failing or erroring tests has been found in build (id: " + build.getId() + ")");
this.buildRunner.submitBuild(build);
} else {
LOGGER.info("No failing or erroring test has been found in build (id: " + build.getId() + ")");
}
}
use of fr.inria.jtravis.entities.Job in project repairnator by Spirals-Team.
the class RTScanner method isRepositoryInteresting.
public boolean isRepositoryInteresting(int repositoryId) {
if (this.blackListedRepository.contains(repositoryId)) {
// LOGGER.debug("Repo already blacklisted (id: "+repositoryId+")");
return false;
}
if (this.whiteListedRepository.contains(repositoryId)) {
// LOGGER.debug("Repo already whitelisted (id: "+repositoryId+")");
return true;
}
if (this.tempBlackList.containsKey(repositoryId)) {
if (this.tempBlackList.get(repositoryId).after(new Date())) {
return false;
} else {
this.tempBlackList.remove(repositoryId);
}
}
Repository repository = RepositoryHelper.getRepositoryFromId(repositoryId);
if (repository != null) {
Build masterBuild = BuildHelper.getLastSuccessfulBuildFromMaster(repository, false, 5);
if (masterBuild == null) {
this.addInTempBlackList(repository, "No successful build found.");
return false;
} else {
if (masterBuild.getConfig().getLanguage() == null || !masterBuild.getConfig().getLanguage().equals("java")) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getConfig().getLanguage());
return false;
}
if (masterBuild.getBuildTool() == BuildTool.GRADLE) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, "");
return false;
} else if (masterBuild.getBuildTool() == BuildTool.UNKNOWN) {
this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, "");
return false;
}
if (!masterBuild.getJobs().isEmpty()) {
Job firstJob = masterBuild.getJobs().get(0);
Log jobLog = firstJob.getLog();
if (jobLog.getTestsInformation() != null && jobLog.getTestsInformation().getRunning() > 0) {
LOGGER.info("Tests has been found in repository " + repository.getSlug() + " (id: " + repositoryId + ") build (id: " + masterBuild.getId() + "). The repo is now whitelisted.");
this.addInWhitelistRepository(repository);
return true;
} else {
this.addInTempBlackList(repository, "No test found");
}
} else {
LOGGER.info("No job found in repository " + repository.getSlug() + " (id: " + repositoryId + ") build (id: " + masterBuild.getId() + "). It is not considered right now.");
}
}
} else {
LOGGER.info("Repository not found with the following id: " + repositoryId + " it will be temporary blacklisted");
Date expirationDate = new Date(new Date().toInstant().plusSeconds(DURATION_IN_TEMP_BLACKLIST).toEpochMilli());
this.tempBlackList.put(repositoryId, expirationDate);
}
return false;
}
Aggregations