@Test public void testRepositoryWithSuccessfulBuildIsInteresting() { String slug = "INRIA/spoon"; RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.REPAIR); Optional<Repository> repositoryOptional = RepairnatorConfig.getInstance().getJTravis().repository().fromSlug(slug); assertTrue(repositoryOptional.isPresent()); RTScanner rtScanner = new RTScanner("test", new ArrayList<>()); boolean result = rtScanner.isRepositoryInteresting(repositoryOptional.get().getId()); assertTrue(result); }
public boolean isRepositoryInteresting(long repositoryId) { if (this.blackListedRepository.contains(repositoryId)) { return false; } if (this.whiteListedRepository.contains(repositoryId)) { return true; } if (this.tempBlackList.containsKey(repositoryId)) { if (this.tempBlackList.get(repositoryId).after(new Date())) { return false; } else { this.tempBlackList.remove(repositoryId); } } JTravis jTravis = RepairnatorConfig.getInstance().getJTravis(); Optional<Repository> repositoryOptional = jTravis.repository().fromId(repositoryId); if (repositoryOptional.isPresent()) { Repository repository = repositoryOptional.get(); Optional<Build> optionalBuild = jTravis.build().lastBuildFromMasterWithState(repository, StateType.PASSED); if (!optionalBuild.isPresent()) { this.addInTempBlackList(repository, "No successful build found."); return false; } else { Build masterBuild = optionalBuild.get(); if (masterBuild.getLanguage() == null || !masterBuild.getLanguage().equals("java")) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getLanguage()); return false; } Optional<BuildTool> optionalBuildTool = masterBuild.getBuildTool(); if (!optionalBuildTool.isPresent()) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } BuildTool buildTool = optionalBuildTool.get(); if (buildTool == BuildTool.GRADLE) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, ""); return false; } else if (buildTool == BuildTool.UNKNOWN) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } if (!masterBuild.getJobs().isEmpty()) { Job firstJob = masterBuild.getJobs().get(0); Optional<Log> optionalLog = firstJob.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle 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 checkstyle found"); } } else { 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.error("Error while getting log for job "+firstJob.getId()); } } 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; }
RTScanner { public boolean isRepositoryInteresting(long repositoryId) { if (this.blackListedRepository.contains(repositoryId)) { return false; } if (this.whiteListedRepository.contains(repositoryId)) { return true; } if (this.tempBlackList.containsKey(repositoryId)) { if (this.tempBlackList.get(repositoryId).after(new Date())) { return false; } else { this.tempBlackList.remove(repositoryId); } } JTravis jTravis = RepairnatorConfig.getInstance().getJTravis(); Optional<Repository> repositoryOptional = jTravis.repository().fromId(repositoryId); if (repositoryOptional.isPresent()) { Repository repository = repositoryOptional.get(); Optional<Build> optionalBuild = jTravis.build().lastBuildFromMasterWithState(repository, StateType.PASSED); if (!optionalBuild.isPresent()) { this.addInTempBlackList(repository, "No successful build found."); return false; } else { Build masterBuild = optionalBuild.get(); if (masterBuild.getLanguage() == null || !masterBuild.getLanguage().equals("java")) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getLanguage()); return false; } Optional<BuildTool> optionalBuildTool = masterBuild.getBuildTool(); if (!optionalBuildTool.isPresent()) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } BuildTool buildTool = optionalBuildTool.get(); if (buildTool == BuildTool.GRADLE) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, ""); return false; } else if (buildTool == BuildTool.UNKNOWN) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } if (!masterBuild.getJobs().isEmpty()) { Job firstJob = masterBuild.getJobs().get(0); Optional<Log> optionalLog = firstJob.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle 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 checkstyle found"); } } else { 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.error("Error while getting log for job "+firstJob.getId()); } } 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; } }
RTScanner { public boolean isRepositoryInteresting(long repositoryId) { if (this.blackListedRepository.contains(repositoryId)) { return false; } if (this.whiteListedRepository.contains(repositoryId)) { return true; } if (this.tempBlackList.containsKey(repositoryId)) { if (this.tempBlackList.get(repositoryId).after(new Date())) { return false; } else { this.tempBlackList.remove(repositoryId); } } JTravis jTravis = RepairnatorConfig.getInstance().getJTravis(); Optional<Repository> repositoryOptional = jTravis.repository().fromId(repositoryId); if (repositoryOptional.isPresent()) { Repository repository = repositoryOptional.get(); Optional<Build> optionalBuild = jTravis.build().lastBuildFromMasterWithState(repository, StateType.PASSED); if (!optionalBuild.isPresent()) { this.addInTempBlackList(repository, "No successful build found."); return false; } else { Build masterBuild = optionalBuild.get(); if (masterBuild.getLanguage() == null || !masterBuild.getLanguage().equals("java")) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getLanguage()); return false; } Optional<BuildTool> optionalBuildTool = masterBuild.getBuildTool(); if (!optionalBuildTool.isPresent()) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } BuildTool buildTool = optionalBuildTool.get(); if (buildTool == BuildTool.GRADLE) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, ""); return false; } else if (buildTool == BuildTool.UNKNOWN) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } if (!masterBuild.getJobs().isEmpty()) { Job firstJob = masterBuild.getJobs().get(0); Optional<Log> optionalLog = firstJob.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle 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 checkstyle found"); } } else { 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.error("Error while getting log for job "+firstJob.getId()); } } 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; } RTScanner(String runId);  RTScanner(String runId, List<SerializerEngine> theengines);  RTScanner(String runId, List<SerializerEngine> engines, PipelineRunner runner); }
RTScanner { public boolean isRepositoryInteresting(long repositoryId) { if (this.blackListedRepository.contains(repositoryId)) { return false; } if (this.whiteListedRepository.contains(repositoryId)) { return true; } if (this.tempBlackList.containsKey(repositoryId)) { if (this.tempBlackList.get(repositoryId).after(new Date())) { return false; } else { this.tempBlackList.remove(repositoryId); } } JTravis jTravis = RepairnatorConfig.getInstance().getJTravis(); Optional<Repository> repositoryOptional = jTravis.repository().fromId(repositoryId); if (repositoryOptional.isPresent()) { Repository repository = repositoryOptional.get(); Optional<Build> optionalBuild = jTravis.build().lastBuildFromMasterWithState(repository, StateType.PASSED); if (!optionalBuild.isPresent()) { this.addInTempBlackList(repository, "No successful build found."); return false; } else { Build masterBuild = optionalBuild.get(); if (masterBuild.getLanguage() == null || !masterBuild.getLanguage().equals("java")) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getLanguage()); return false; } Optional<BuildTool> optionalBuildTool = masterBuild.getBuildTool(); if (!optionalBuildTool.isPresent()) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } BuildTool buildTool = optionalBuildTool.get(); if (buildTool == BuildTool.GRADLE) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, ""); return false; } else if (buildTool == BuildTool.UNKNOWN) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } if (!masterBuild.getJobs().isEmpty()) { Job firstJob = masterBuild.getJobs().get(0); Optional<Log> optionalLog = firstJob.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle 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 checkstyle found"); } } else { 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.error("Error while getting log for job "+firstJob.getId()); } } 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; } RTScanner(String runId);  RTScanner(String runId, List<SerializerEngine> theengines);  RTScanner(String runId, List<SerializerEngine> engines, PipelineRunner runner); void setEndProcessNotifier(EndProcessNotifier endProcessNotifier); void setSummaryNotifier(TimedSummaryNotifier summaryNotifier); List<SerializerEngine> getEngines(); String getRunId(); InspectBuilds getInspectBuilds(); void initWhiteListedRepository(File whiteListFile); void initBlackListedRepository(File blackListFile); void launch(); void submitIfBuildIsInteresting(Build build); boolean isRepositoryInteresting(long repositoryId); void submitBuildToExecution(Build build); void saveInfoToDisk(); void stopDockerJobs(); }
RTScanner { public boolean isRepositoryInteresting(long repositoryId) { if (this.blackListedRepository.contains(repositoryId)) { return false; } if (this.whiteListedRepository.contains(repositoryId)) { return true; } if (this.tempBlackList.containsKey(repositoryId)) { if (this.tempBlackList.get(repositoryId).after(new Date())) { return false; } else { this.tempBlackList.remove(repositoryId); } } JTravis jTravis = RepairnatorConfig.getInstance().getJTravis(); Optional<Repository> repositoryOptional = jTravis.repository().fromId(repositoryId); if (repositoryOptional.isPresent()) { Repository repository = repositoryOptional.get(); Optional<Build> optionalBuild = jTravis.build().lastBuildFromMasterWithState(repository, StateType.PASSED); if (!optionalBuild.isPresent()) { this.addInTempBlackList(repository, "No successful build found."); return false; } else { Build masterBuild = optionalBuild.get(); if (masterBuild.getLanguage() == null || !masterBuild.getLanguage().equals("java")) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.OTHER_LANGUAGE, masterBuild.getLanguage()); return false; } Optional<BuildTool> optionalBuildTool = masterBuild.getBuildTool(); if (!optionalBuildTool.isPresent()) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } BuildTool buildTool = optionalBuildTool.get(); if (buildTool == BuildTool.GRADLE) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.USE_GRADLE, ""); return false; } else if (buildTool == BuildTool.UNKNOWN) { this.addInBlacklistRepository(repository, BlacklistedSerializer.Reason.UNKNOWN_BUILD_TOOL, ""); return false; } if (!masterBuild.getJobs().isEmpty()) { Job firstJob = masterBuild.getJobs().get(0); Optional<Log> optionalLog = firstJob.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle 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 checkstyle found"); } } else { 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.error("Error while getting log for job "+firstJob.getId()); } } 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; } RTScanner(String runId);  RTScanner(String runId, List<SerializerEngine> theengines);  RTScanner(String runId, List<SerializerEngine> engines, PipelineRunner runner); void setEndProcessNotifier(EndProcessNotifier endProcessNotifier); void setSummaryNotifier(TimedSummaryNotifier summaryNotifier); List<SerializerEngine> getEngines(); String getRunId(); InspectBuilds getInspectBuilds(); void initWhiteListedRepository(File whiteListFile); void initBlackListedRepository(File blackListFile); void launch(); void submitIfBuildIsInteresting(Build build); boolean isRepositoryInteresting(long repositoryId); void submitBuildToExecution(Build build); void saveInfoToDisk(); void stopDockerJobs();  }