Search in sources :

Example 1 with Repository

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

the class TransformRepoSlugToRepoId method main.

public static void main(String[] args) throws IOException {
    if (args.length != 2) {
        System.err.println("Usage: TransformRepoSlugToRepoId <input> <output>");
        System.exit(-1);
    }
    File input = new File(args[0]);
    File output = new File(args[1]);
    if (output.exists()) {
        System.err.println("Please give the path of a file that does not exist for output: " + args[1]);
        System.exit(-1);
    }
    if (input.exists()) {
        List<String> slugs = Files.readAllLines(input.toPath());
        FileWriter fw = new FileWriter(output);
        int i = 0;
        for (String slug : slugs) {
            Repository repo = RepositoryHelper.getRepositoryFromSlug(slug);
            if (repo != null) {
                fw.append(repo.getId() + "");
                fw.append("\n");
                fw.flush();
                i++;
            }
        }
        fw.close();
        System.out.println(i + " entries written in " + args[1]);
    } else {
        System.err.println("The given input files does not exist: " + args[0]);
    }
}
Also used : Repository(fr.inria.spirals.jtravis.entities.Repository) FileWriter(java.io.FileWriter) File(java.io.File)

Example 2 with Repository

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

the class CleanProjectList method main.

public static void main(String[] args) throws IOException {
    String projectPath = args[0];
    String dbUrl = args[1];
    String dbName = args[2];
    String collectionName = args[3];
    String destList = args[4];
    List<String> allProjects = Files.readAllLines(new File(projectPath).toPath());
    MongoConnection mongoConnection = new MongoConnection(dbUrl, dbName);
    MongoDatabase database = mongoConnection.getMongoDatabase();
    MongoCollection collection = database.getCollection(collectionName);
    List<String> selectedProjects = new ArrayList<>();
    for (String project : allProjects) {
        Repository repo = RepositoryHelper.getRepositoryFromSlug(project);
        if (repo != null) {
            Build b = repo.getLastBuild(false);
            if (b != null) {
                if (b.getBuildTool() == BuildTool.MAVEN) {
                    long results = collection.count(and(eq("repositoryName", project), ne("typeOfFailures", null)));
                    if (results > 0) {
                        selectedProjects.add(project);
                    }
                }
            }
        }
    }
    File outputFile = new File(destList);
    BufferedWriter buffer = new BufferedWriter(new FileWriter(outputFile));
    buffer.write(StringUtils.join(selectedProjects, "\n"));
    buffer.close();
    System.out.println("Read projects: " + allProjects.size() + " | Selected projects : " + selectedProjects.size());
    System.out.println(StringUtils.join(selectedProjects, "\n"));
}
Also used : MongoCollection(com.mongodb.client.MongoCollection) Repository(fr.inria.spirals.jtravis.entities.Repository) Build(fr.inria.spirals.jtravis.entities.Build) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) File(java.io.File) MongoConnection(fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection) MongoDatabase(com.mongodb.client.MongoDatabase) BufferedWriter(java.io.BufferedWriter)

Example 3 with Repository

use of fr.inria.spirals.jtravis.entities.Repository 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 4 with Repository

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

the class GetTrendingsFromGithub method main.

public static void main(String[] args) throws IOException {
    String githubTrendingUrl = "https://github.com/trending/java/?since=weekly";
    Document doc = Jsoup.connect(githubTrendingUrl).get();
    Elements e = doc.getElementsByAttributeValue("class", "explore-content");
    if (e.size() != 1) {
        System.err.println("Error when parsing the page (explore-content)");
        System.exit(-1);
    }
    Elements ol = e.get(0).getElementsByTag("ol");
    if (ol.size() != 1) {
        System.err.println("Error when parsing the page (ol)");
        System.exit(-1);
    }
    Elements h3 = ol.get(0).getElementsByTag("h3");
    List<String> results = new ArrayList<String>();
    System.out.println("Nb trendings: " + h3.size());
    for (Element project : h3) {
        String link = project.getElementsByTag("a").get(0).attr("href");
        String slugName = link.substring(1);
        Repository repo = RepositoryHelper.getRepositoryFromSlug(slugName);
        if (repo != null) {
            Build b = repo.getLastBuild(false);
            if (b != null && b.getBuildTool() == BuildTool.MAVEN) {
                results.add(slugName);
            }
        }
    }
    System.out.println(StringUtils.join(results, "\n"));
}
Also used : Repository(fr.inria.spirals.jtravis.entities.Repository) Build(fr.inria.spirals.jtravis.entities.Build) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 5 with Repository

use of fr.inria.spirals.jtravis.entities.Repository 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

Repository (fr.inria.spirals.jtravis.entities.Repository)5 Build (fr.inria.spirals.jtravis.entities.Build)4 File (java.io.File)4 FileWriter (java.io.FileWriter)3 ArrayList (java.util.ArrayList)3 BuildTool (fr.inria.spirals.jtravis.entities.BuildTool)2 BufferedWriter (java.io.BufferedWriter)2 MongoCollection (com.mongodb.client.MongoCollection)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 MongoConnection (fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection)1 HashSet (java.util.HashSet)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1