Search in sources :

Example 51 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestBuildProject method testBuildProjectWithPomNotInRoot.

@Test
public void testBuildProjectWithPomNotInRoot() throws IOException {
    int buildId = 218036343;
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_build");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = new ProjectInspector(toBeInspected, tmpDir.getAbsolutePath(), Collections.EMPTY_LIST, Collections.EMPTY_LIST);
    JobStatus jobStatus = inspector.getJobStatus();
    CloneRepository cloneStep = new CloneRepository(inspector);
    BuildProject buildStep = new BuildProject(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(buildStep);
    cloneStep.execute();
    assertThat(buildStep.shouldStop, is(false));
    assertThat(buildStep.getPipelineState(), is(PipelineState.BUILDABLE));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.BUILDABLE));
}
Also used : Path(java.nio.file.Path) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) File(java.io.File) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Test(org.junit.Test)

Example 52 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class TestCommitPatch method testPushHumanPatchSimpleCase.

@Test
public void testPushHumanPatchSimpleCase() throws IOException, GitAPIException, RepairnatorConfigException {
    // surli/failingProject build
    int buildId = 207924136;
    RepairnatorConfig repairnatorConfig = RepairnatorConfig.getInstance();
    repairnatorConfig.setClean(false);
    repairnatorConfig.setPush(true);
    Build build = BuildHelper.getBuildFromId(buildId, null);
    assertThat(build, notNullValue());
    assertThat(buildId, is(build.getId()));
    Path tmpDirPath = Files.createTempDirectory("test_pushPatch");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    BuildToBeInspected toBeInspected = new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, "");
    ProjectInspector inspector = mock(ProjectInspector.class);
    when(inspector.getWorkspace()).thenReturn(tmpDir.getAbsolutePath());
    when(inspector.getRepoLocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getRepoToPushLocalPath()).thenReturn(tmpDir.getAbsolutePath() + "/repotopush");
    when(inspector.getBuildToBeInspected()).thenReturn(toBeInspected);
    when(inspector.getBuggyBuild()).thenReturn(build);
    when(inspector.getGitHelper()).thenReturn(new GitHelper());
    JobStatus jobStatus = new JobStatus(tmpDir.getAbsolutePath() + "/repo");
    when(inspector.getJobStatus()).thenReturn(jobStatus);
    CloneRepository cloneStep = new CloneRepository(inspector);
    cloneStep.setNextStep(new CheckoutBuggyBuild(inspector)).setNextStep(new InitRepoToPush(inspector)).setNextStep(new CommitPatch(inspector, true));
    cloneStep.execute();
    assertThat(jobStatus.getPushState(), is(PushState.PATCH_COMMITTED));
    Git gitDir = Git.open(new File(tmpDir, "repotopush"));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    assertThat(iterator.hasNext(), is(true));
    RevCommit commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("End of the repairnator process"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Human patch"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : Path(java.nio.file.Path) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) GitHelper(fr.inria.spirals.repairnator.process.git.GitHelper) ProjectInspector(fr.inria.spirals.repairnator.process.inspectors.ProjectInspector) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) JobStatus(fr.inria.spirals.repairnator.process.inspectors.JobStatus) CloneRepository(fr.inria.spirals.repairnator.process.step.CloneRepository) Git(org.eclipse.jgit.api.Git) Build(fr.inria.jtravis.entities.Build) CheckoutBuggyBuild(fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 53 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class BuildRunner method removeSubmittedRunnablePipelineContainer.

@Override
public void removeSubmittedRunnablePipelineContainer(RunnablePipelineContainer pipelineContainer) {
    LOGGER.info("Build (id: " + pipelineContainer.getInputBuildId().getBuggyBuildId() + ") has finished.");
    super.removeSubmittedRunnablePipelineContainer(pipelineContainer);
    if (!this.waitingBuilds.isEmpty()) {
        Build build = this.waitingBuilds.pollFirst();
        this.submitBuild(build);
    }
}
Also used : Build(fr.inria.jtravis.entities.Build)

Example 54 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class InspectBuilds method run.

@Override
public void run() {
    LOGGER.debug("Start running inspect builds....");
    if (this.sleepTime == -1) {
        throw new RuntimeException("You must set sleepTime before running this.");
    }
    while (!this.shouldStop) {
        LOGGER.info("Refresh all inspected build status (nb builds: " + this.nbSubmittedBuilds + ")");
        for (Build build : this.waitingBuilds) {
            build.refreshStatus();
            if (build.getFinishedAt() != null) {
                LOGGER.debug("Build finished (id:" + build.getId() + " | Status: " + build.getBuildStatus() + ")");
                if (build.getBuildStatus() == BuildStatus.FAILED) {
                    this.rtScanner.submitBuildToExecution(build);
                }
                try {
                    this.watchedBuildSerializer.serialize(build);
                } catch (Throwable e) {
                    LOGGER.error("Error while serializing", e);
                }
                this.waitingBuilds.remove(build);
                synchronized (this) {
                    this.nbSubmittedBuilds--;
                }
            }
        }
        try {
            Thread.sleep(this.sleepTime * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    LOGGER.info("This will now stop.");
}
Also used : Build(fr.inria.jtravis.entities.Build)

Example 55 with Build

use of fr.inria.jtravis.entities.Build in project repairnator by Spirals-Team.

the class ScannerDetailedDataSerializer method serializeAsList.

private List<Object> serializeAsList(BuildToBeInspected buildToBeInspected) {
    List<Object> dataCol = new ArrayList<Object>();
    Build build = buildToBeInspected.getPatchedBuild();
    Build previousBuild = buildToBeInspected.getBuggyBuild();
    int previousBuildId = (previousBuild != null) ? previousBuild.getId() : -1;
    String committerEmail = (build.getCommit().getCommitterEmail() != null) ? build.getCommit().getCommitterEmail() : "-";
    Date date = new Date();
    dataCol.add(build.getId() + "");
    dataCol.add(previousBuildId + "");
    dataCol.add(buildToBeInspected.getStatus().name());
    dataCol.add(build.getRepository().getSlug());
    dataCol.add(Utils.formatCompleteDate(date));
    dataCol.add(Utils.formatOnlyDay(date));
    dataCol.add(Utils.getHostname());
    dataCol.add(Utils.getTravisUrl(build.getId(), build.getRepository().getSlug()));
    dataCol.add(Utils.getTravisUrl(previousBuildId, build.getRepository().getSlug()));
    dataCol.add(committerEmail);
    dataCol.add(buildToBeInspected.getRunId());
    return dataCol;
}
Also used : Build(fr.inria.jtravis.entities.Build) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Date(java.util.Date)

Aggregations

Build (fr.inria.jtravis.entities.Build)60 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)44 File (java.io.File)41 Path (java.nio.file.Path)40 Test (org.junit.Test)40 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)37 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)33 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)31 CheckoutBuggyBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutBuggyBuild)28 ArrayList (java.util.ArrayList)15 Git (org.eclipse.jgit.api.Git)13 JsonObject (com.google.gson.JsonObject)12 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)12 RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)11 Date (java.util.Date)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 CheckoutPatchedBuild (fr.inria.spirals.repairnator.process.step.checkoutrepository.CheckoutPatchedBuild)10 GatherTestInformation (fr.inria.spirals.repairnator.process.step.gatherinfo.GatherTestInformation)9 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7