Search in sources :

Example 1 with BuildTool

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

the class GetProjectsWithUnknownBuildTool method main.

public static void main(String[] args) throws IOException {
    List<String> allProjects = Files.readAllLines(new File(args[0]).toPath());
    List<String> results = new ArrayList<>();
    for (String project : allProjects) {
        Repository repo = RepositoryHelper.getRepositoryFromSlug(project);
        if (repo != null) {
            Build b = repo.getLastBuild(false);
            if (b != null) {
                BuildTool tool = b.getBuildTool();
                if (b.getBuildStatus() == BuildStatus.PASSED && tool == BuildTool.UNKNOWN) {
                    results.add("https://travis-ci.org/" + project);
                }
            }
        }
    }
    System.out.println(results.size() + " results");
    System.out.println(StringUtils.join(results, "\n"));
}
Also used : Repository(fr.inria.spirals.jtravis.entities.Repository) Build(fr.inria.spirals.jtravis.entities.Build) BuildTool(fr.inria.spirals.jtravis.entities.BuildTool) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with BuildTool

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

the class ShowBuildToolUsage method main.

public static void main(String[] args) throws IOException {
    List<String> allProjects = Files.readAllLines(new File(args[0]).toPath());
    String pathOutput = args[1];
    File outputFile = new File(pathOutput);
    Set<String> notOnTravis = new HashSet<>();
    Set<String> useMavenTool = new HashSet<>();
    Set<String> useGradleTool = new HashSet<>();
    Set<String> useUnknownTool = new HashSet<>();
    Set<String> noBuildPassOnMaster = new HashSet<>();
    for (String project : allProjects) {
        Repository repo = RepositoryHelper.getRepositoryFromSlug(project);
        if (repo == null || !repo.isActive()) {
            notOnTravis.add(project);
        } else {
            Build build = BuildHelper.getLastBuildFromMaster(repo);
            if (build == null) {
                noBuildPassOnMaster.add(project);
                continue;
            }
            if (build.getBuildStatus() != BuildStatus.PASSED) {
                build = BuildHelper.getLastBuildOfSameBranchOfStatusBeforeBuild(build, BuildStatus.PASSED, true);
                if (build == null) {
                    noBuildPassOnMaster.add(project);
                    continue;
                }
            }
            BuildTool buildTool = build.getBuildTool();
            switch(buildTool) {
                case MAVEN:
                    useMavenTool.add(project);
                    break;
                case GRADLE:
                    useGradleTool.add(project);
                    break;
                case UNKNOWN:
                    useUnknownTool.add(project);
                    break;
            }
        }
    }
    System.out.println("Computed statistics");
    System.out.println("Total number of projects: " + allProjects.size());
    System.out.println("Not using travis: " + notOnTravis.size());
    System.out.println("No build passing on master: " + noBuildPassOnMaster.size());
    System.out.println("Using maven: " + useMavenTool.size());
    System.out.println("Using gradle: " + useGradleTool.size());
    System.out.println("Using unknown: " + useUnknownTool.size());
    BufferedWriter buffer = new BufferedWriter(new FileWriter(outputFile));
    buffer.write("name\tuse Travis\thas Passing build on master\tUse Maven\tUse Gradle\n");
    buffer.flush();
    for (String s : notOnTravis) {
        buffer.write(s + "\t0\t0\t0\t0\n");
        buffer.flush();
    }
    for (String s : noBuildPassOnMaster) {
        buffer.write(s + "\t1\t0\t0\t0\n");
        buffer.flush();
    }
    for (String s : useUnknownTool) {
        buffer.write(s + "\t1\t1\t0\t0\n");
        buffer.flush();
    }
    for (String s : useMavenTool) {
        buffer.write(s + "\t1\t1\t1\t0\n");
        buffer.flush();
    }
    for (String s : useGradleTool) {
        buffer.write(s + "\t1\t1\t0\t1\n");
        buffer.flush();
    }
    buffer.close();
    System.out.println("All results written in " + pathOutput);
}
Also used : Repository(fr.inria.spirals.jtravis.entities.Repository) Build(fr.inria.spirals.jtravis.entities.Build) BuildTool(fr.inria.spirals.jtravis.entities.BuildTool) FileWriter(java.io.FileWriter) File(java.io.File) HashSet(java.util.HashSet) BufferedWriter(java.io.BufferedWriter)

Aggregations

Build (fr.inria.spirals.jtravis.entities.Build)2 BuildTool (fr.inria.spirals.jtravis.entities.BuildTool)2 Repository (fr.inria.spirals.jtravis.entities.Repository)2 File (java.io.File)2 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1