@Test public void testTestBuildWithFailingAndBearsMode() { long buildId = 230022061; RepairnatorConfig config = RepairnatorConfig.getInstance(); config.setLauncherMode(LauncherMode.BEARS); Optional<Build> buildOptional = config.getJTravis().build().fromId(buildId); assertTrue(buildOptional.isPresent()); Build build = buildOptional.get(); ProjectScanner projectScanner = new ProjectScanner(new Date(), new Date(), "test"); boolean isOKForBears = projectScanner.testBuild(build); assertFalse(isOKForBears); }
protected boolean testBuild(Build build) { if (build.isPullRequest()) { this.totalPRBuilds++; } Repository repo = build.getRepository(); String language = build.getLanguage(); if ("java".equals(language)) { this.totalBuildInJava++; this.logger.debug("Repo " + repo.getSlug() + " with java language - build " + build.getId() + " - Status : " + build.getState().name()); if (build.getState() == StateType.FAILED) { this.totalBuildInJavaFailing++; if (isFailedBuildFailingByTestFailure(build)) { this.totalBuildInJavaFailingWithFailingTests++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { return false; } } } else if (build.getState() == StateType.PASSED) { this.totalJavaPassingBuilds++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (jobLog.getBuildTool() == BuildTool.MAVEN) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { logger.debug("Maven is not used in the build " + build.getId()); } } } } } } } else { this.logger.warn("Examine repo " + repo.getSlug() + " Careful the following build " + build.getId() + " is not in java but language: " + language); } return false; }
ProjectScanner { protected boolean testBuild(Build build) { if (build.isPullRequest()) { this.totalPRBuilds++; } Repository repo = build.getRepository(); String language = build.getLanguage(); if ("java".equals(language)) { this.totalBuildInJava++; this.logger.debug("Repo " + repo.getSlug() + " with java language - build " + build.getId() + " - Status : " + build.getState().name()); if (build.getState() == StateType.FAILED) { this.totalBuildInJavaFailing++; if (isFailedBuildFailingByTestFailure(build)) { this.totalBuildInJavaFailingWithFailingTests++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { return false; } } } else if (build.getState() == StateType.PASSED) { this.totalJavaPassingBuilds++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (jobLog.getBuildTool() == BuildTool.MAVEN) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { logger.debug("Maven is not used in the build " + build.getId()); } } } } } } } else { this.logger.warn("Examine repo " + repo.getSlug() + " Careful the following build " + build.getId() + " is not in java but language: " + language); } return false; } }
ProjectScanner { protected boolean testBuild(Build build) { if (build.isPullRequest()) { this.totalPRBuilds++; } Repository repo = build.getRepository(); String language = build.getLanguage(); if ("java".equals(language)) { this.totalBuildInJava++; this.logger.debug("Repo " + repo.getSlug() + " with java language - build " + build.getId() + " - Status : " + build.getState().name()); if (build.getState() == StateType.FAILED) { this.totalBuildInJavaFailing++; if (isFailedBuildFailingByTestFailure(build)) { this.totalBuildInJavaFailingWithFailingTests++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { return false; } } } else if (build.getState() == StateType.PASSED) { this.totalJavaPassingBuilds++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (jobLog.getBuildTool() == BuildTool.MAVEN) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { logger.debug("Maven is not used in the build " + build.getId()); } } } } } } } else { this.logger.warn("Examine repo " + repo.getSlug() + " Careful the following build " + build.getId() + " is not in java but language: " + language); } return false; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); }
ProjectScanner { protected boolean testBuild(Build build) { if (build.isPullRequest()) { this.totalPRBuilds++; } Repository repo = build.getRepository(); String language = build.getLanguage(); if ("java".equals(language)) { this.totalBuildInJava++; this.logger.debug("Repo " + repo.getSlug() + " with java language - build " + build.getId() + " - Status : " + build.getState().name()); if (build.getState() == StateType.FAILED) { this.totalBuildInJavaFailing++; if (isFailedBuildFailingByTestFailure(build)) { this.totalBuildInJavaFailingWithFailingTests++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { return false; } } } else if (build.getState() == StateType.PASSED) { this.totalJavaPassingBuilds++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (jobLog.getBuildTool() == BuildTool.MAVEN) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { logger.debug("Maven is not used in the build " + build.getId()); } } } } } } } else { this.logger.warn("Examine repo " + repo.getSlug() + " Careful the following build " + build.getId() + " is not in java but language: " + language); } return false; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); String getRunId(); int getTotalRepoNumber(); int getTotalRepoUsingTravis(); int getTotalScannedBuilds(); int getTotalPRBuilds(); int getTotalBuildInJava(); int getTotalJavaPassingBuilds(); int getTotalBuildInJavaFailing(); int getTotalBuildInJavaFailingWithFailingTests(); int getTotalNumberOfFailingAndPassingBuildPairs(); int getTotalNumberOfPassingAndPassingBuildPairs(); Date getLookFromDate(); Date getLookToDate(); Date getScannerRunningBeginDate(); Date getScannerRunningEndDate(); String getScannerDuration(); Map<ScannedBuildStatus, List<BuildToBeInspected>> getListOfBuildsToBeInspectedFromProjects(String path); Map<ScannedBuildStatus, List<BuildToBeInspected>> getBuildsGivenSlug(String slug); BuildToBeInspected getBuildToBeInspected(Build build); }
ProjectScanner { protected boolean testBuild(Build build) { if (build.isPullRequest()) { this.totalPRBuilds++; } Repository repo = build.getRepository(); String language = build.getLanguage(); if ("java".equals(language)) { this.totalBuildInJava++; this.logger.debug("Repo " + repo.getSlug() + " with java language - build " + build.getId() + " - Status : " + build.getState().name()); if (build.getState() == StateType.FAILED) { this.totalBuildInJavaFailing++; if (isFailedBuildFailingByTestFailure(build)) { this.totalBuildInJavaFailingWithFailingTests++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { return false; } } } else if (build.getState() == StateType.PASSED) { this.totalJavaPassingBuilds++; if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job); if (job.getState() == StateType.PASSED) { Optional<Log> optionalLog = job.getLog(); if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (jobLog.getBuildTool() == BuildTool.MAVEN) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); return true; } else { logger.debug("Maven is not used in the build " + build.getId()); } } } } } } } else { this.logger.warn("Examine repo " + repo.getSlug() + " Careful the following build " + build.getId() + " is not in java but language: " + language); } return false; } ProjectScanner(Date lookFromDate, Date lookToDate, String runId); String getRunId(); int getTotalRepoNumber(); int getTotalRepoUsingTravis(); int getTotalScannedBuilds(); int getTotalPRBuilds(); int getTotalBuildInJava(); int getTotalJavaPassingBuilds(); int getTotalBuildInJavaFailing(); int getTotalBuildInJavaFailingWithFailingTests(); int getTotalNumberOfFailingAndPassingBuildPairs(); int getTotalNumberOfPassingAndPassingBuildPairs(); Date getLookFromDate(); Date getLookToDate(); Date getScannerRunningBeginDate(); Date getScannerRunningEndDate(); String getScannerDuration(); Map<ScannedBuildStatus, List<BuildToBeInspected>> getListOfBuildsToBeInspectedFromProjects(String path); Map<ScannedBuildStatus, List<BuildToBeInspected>> getBuildsGivenSlug(String slug); BuildToBeInspected getBuildToBeInspected(Build build);  }