Search in sources :

Example 6 with Metrics

use of fr.inria.spirals.repairnator.process.inspectors.Metrics in project repairnator by Spirals-Team.

the class AbstractStep method execute.

public void execute() {
    this.dateBegin = new Date().getTime();
    this.businessExecute();
    this.dateEnd = new Date().getTime();
    Metrics metric = this.inspector.getJobStatus().getMetrics();
    metric.addStepDuration(this.name, getDuration());
    metric.addFreeMemoryByStep(this.name, Runtime.getRuntime().freeMemory());
    this.inspector.getJobStatus().setPipelineState(this.pipelineState);
    if (!shouldStop) {
        this.executeNextStep();
    } else {
        this.terminatePipeline();
    }
}
Also used : Metrics(fr.inria.spirals.repairnator.process.inspectors.Metrics) Date(java.util.Date)

Example 7 with Metrics

use of fr.inria.spirals.repairnator.process.inspectors.Metrics in project repairnator by Spirals-Team.

the class AbstractStep method recordMetrics.

private void recordMetrics() {
    Metrics metric = this.inspector.getJobStatus().getMetrics();
    metric.setFreeMemory(Runtime.getRuntime().freeMemory());
    metric.setTotalMemory(Runtime.getRuntime().totalMemory());
    metric.setNbCPU(Runtime.getRuntime().availableProcessors());
}
Also used : Metrics(fr.inria.spirals.repairnator.process.inspectors.Metrics)

Example 8 with Metrics

use of fr.inria.spirals.repairnator.process.inspectors.Metrics in project repairnator by Spirals-Team.

the class CommitPatch method businessExecute.

@Override
protected void businessExecute() {
    if (RepairnatorConfig.getInstance().isPush()) {
        this.getLogger().info("Start the step push patch");
        File sourceDir = new File(this.getInspector().getRepoLocalPath());
        File targetDir = new File(this.getInspector().getRepoToPushLocalPath());
        try {
            Git git = Git.open(targetDir);
            Ref oldHeadRef = git.getRepository().exactRef("HEAD");
            RevWalk revWalk = new RevWalk(git.getRepository());
            RevCommit headRev = revWalk.parseCommit(oldHeadRef.getObjectId());
            revWalk.dispose();
            FileUtils.copyDirectory(sourceDir, targetDir, new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    return !pathname.toString().contains(".git") && !pathname.toString().contains(".m2");
                }
            });
            git.add().addFilepattern(".").call();
            for (String fileToPush : this.getInspector().getJobStatus().getCreatedFilesToPush()) {
                // add force is not supported by JGit...
                ProcessBuilder processBuilder = new ProcessBuilder("git", "add", "-f", fileToPush).directory(git.getRepository().getDirectory().getParentFile()).inheritIO();
                try {
                    Process p = processBuilder.start();
                    p.waitFor();
                } catch (InterruptedException | IOException e) {
                    this.getLogger().error("Error while executing git command to add files: " + e);
                }
            }
            String commitMsg;
            if (pushHumanPatch) {
                commitMsg = "Human patch from the following repository " + this.getInspector().getRepoSlug() + "\n";
                Metrics metrics = this.getInspector().getJobStatus().getMetrics();
                commitMsg += "This commit is a reflect of the following : " + metrics.getPatchCommitUrl() + ".";
            } else {
                commitMsg = "Automatic repair information (optionally automatic patches).";
            }
            PersonIdent personIdent = new PersonIdent("Luc Esape", "luc.esape@gmail.com");
            RevCommit commit = git.commit().setMessage(commitMsg).setAuthor(personIdent).setCommitter(personIdent).call();
            this.computePatchStats(git, headRev, commit);
            if (this.getInspector().getJobStatus().isHasBeenPushed()) {
                CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(this.getConfig().getGithubToken(), "");
                git.push().setRemote(PushIncriminatedBuild.REMOTE_NAME).setCredentialsProvider(credentialsProvider).call();
            }
            if (pushHumanPatch) {
                this.setPushState(PushState.PATCH_COMMITTED);
            } else {
                this.setPushState(PushState.REPAIR_INFO_COMMITTED);
            }
            return;
        } catch (IOException e) {
            this.addStepError("Error while copying the folder to prepare the git repository.", e);
        } catch (GitAPIException e) {
            this.addStepError("Error while opening the git repository, maybe it has not been initialized yet.", e);
        }
        if (pushHumanPatch) {
            this.setPushState(PushState.PATCH_COMMITTED);
        } else {
            this.setPushState(PushState.REPAIR_INFO_COMMITTED);
        }
    } else {
        this.getLogger().info("Repairnator is configured to not push anything. This step will be bypassed.");
    }
}
Also used : UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) IOException(java.io.IOException) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider) RevWalk(org.eclipse.jgit.revwalk.RevWalk) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Ref(org.eclipse.jgit.lib.Ref) Metrics(fr.inria.spirals.repairnator.process.inspectors.Metrics) Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) FileFilter(java.io.FileFilter) File(java.io.File) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

Metrics (fr.inria.spirals.repairnator.process.inspectors.Metrics)8 IOException (java.io.IOException)6 File (java.io.File)5 Git (org.eclipse.jgit.api.Git)3 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)3 PersonIdent (org.eclipse.jgit.lib.PersonIdent)3 FailureLocation (fr.inria.spirals.repairnator.process.testinformation.FailureLocation)2 Build (fr.inria.jtravis.entities.Build)1 PRInformation (fr.inria.jtravis.entities.PRInformation)1 SolverFactory (fr.inria.lille.commons.synthesis.smt.solver.SolverFactory)1 NopolContext (fr.inria.lille.repair.common.config.NopolContext)1 Patch (fr.inria.lille.repair.common.patch.Patch)1 NoPol (fr.inria.lille.repair.nopol.NoPol)1 NopolResult (fr.inria.lille.repair.nopol.NopolResult)1 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)1 NopolInformation (fr.inria.spirals.repairnator.process.nopol.NopolInformation)1 PatchAndDiff (fr.inria.spirals.repairnator.process.nopol.PatchAndDiff)1 ComparatorFailureLocation (fr.inria.spirals.repairnator.process.testinformation.ComparatorFailureLocation)1 FailureType (fr.inria.spirals.repairnator.process.testinformation.FailureType)1 BufferedWriter (java.io.BufferedWriter)1