Code Monkey home page Code Monkey logo

jtravis's Introduction

jtravis Maven metadata URI Build Status Coverage Status

The purpose of this project is to propose a Java API in order to use Travis-CI API.

Install

mvn install

Usage

The API can be immediately used after specifying the following dependency in your pom.xml:

<dependency>
    <groupId>fr.inria.jtravis</groupId>
    <artifactId>jtravis</artifactId>
    <version>2.0</version>
</dependency>

The API rely on Travis CI API V3 for most of its part, but some endpoints of Travis CI API V2 are still available (like /jobs endpoint). It does not allow to trigger new builds for now. But it does not require to use TravisCI authentication either.

Limitations

This tool has primarily been developed in order to study Java builds using Maven tools: so, most features rely on that choice. Don't hesitate to propose pull requests in order to enhance the current state of this library.

Github Integration

JTravis uses Github API in order to get useful information about pull requests when builds has been triggered by pull requests.

See javadoc from github-api library for more information.

Usage example

JTravis jTravis = new JTravis.Builder().build(); // you can specify in the builder the Github API token and/or the Travis CI API token
Optional<Repository> repository = jTravis.repository().fromSlug("Spirals-Team/jtravis");

if (repository.isPresent()) {
    Optional<Builds> optionalBuilds = jTravis.build().fromRepository(repository.get());

    if (optionalBuilds.isPresent()) {
        for (Build build : optionalBuilds.get().getBuilds()) {
            System.out.println("build id: "+build.getId()+" status: "+build.getState().name());
        }
    }
}

Aknowledgement

This project has been funded by the InriaHub / ADT LibRepair.

jtravis's People

Contributors

andre15silva avatar dependabot[bot] avatar fermadeiral avatar monperrus avatar surli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jtravis's Issues

Root logging level

Currently root logging level of the library is debug which may lead to bad consequences.

F.i. I try to use jtravis with my spring boot app and what happens is spring searches for logback.xml and changes my app logging level to debug according to jtravis's logback.xml.

I think it may be useful to add logging profiles, f.e. dev and prod.

Bug in BuildHelper.getBefore?

When obtaining a build with the method BuildHelper.getBefore() like this:

Optional<Build> optionalBeforeBuild = jTravis.build().getBefore(build, true);

All Optional<Log> returned with job.getLog() from the build in optionalBeforeBuild are Optional.empty:

if (optionalBeforeBuild.isPresent()) {
   Build previousBuild = optionalBeforeBuild.get();
   for (Job job : previousBuild.getJobs()) {
      jTravis.refresh(job);
      if (job.getState() == StateType.FAILED) {
         Optional<Log> optionalLog = job.getLog();
         if (optionalLog.isPresent()) {
            ...
         } else {
            // the code here is executed
         }
      }
   }
}

And the job logs should be present.

To make it work for the moment:

Build previousBuild = optionalBeforeBuild.get();
previousBuild = jTravis.build().getEntityFromUri(Build.class, previousBuild.getUri()).get(); // to add this line

For reproduction of the bug: BuildHelper.getBefore() should be called from build 324525330 (INRIA/spoon), and the job logs will not be present for the before build returned.

bug: crash on NumberFormatException when parsing test

Crash with the following error:

Exception in thread "Thread-2" java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:542)
        at java.lang.Integer.parseInt(Integer.java:615)
        at fr.inria.jtravis.parsers.MavenLogParser.parseTestLine(MavenLogParser.java:52)
        at fr.inria.jtravis.parsers.MavenLogParser.advancedParseLog(MavenLogParser.java:102)
        at fr.inria.jtravis.parsers.MavenLogParser.parseLog(MavenLogParser.java:67)
        at fr.inria.jtravis.parsers.LogParser.getTestsInformation(LogParser.java:113)
        at fr.inria.jtravis.entities.Log.getTestsInformation(Log.java:52)
        at fr.inria.spirals.repairnator.realtime.RTScanner.isRepositoryInteresting(RTScanner.java:261)
        at fr.inria.spirals.repairnator.realtime.InspectJobs.run(InspectJobs.java:47)
        at java.lang.Thread.run(Thread.java:748)

Reported from eclipse/repairnator#791

Java Heap Space in case the logs are really big

Just got the following stack trace:

22:07:43.831 [main] DEBUG fr.inria.jtravis.helpers.LogHelper - Get request to :https://api.travis-ci.org/job/333285507/log done after 1153 ms
Exception in thread "main" com.google.gson.JsonParseException: Failed parsing JSON source: JsonReader at line 16 column 2437850 path $.log_parts[0].content to Json
        at com.google.gson.JsonParser.parse(JsonParser.java:88)
        at com.google.gson.JsonParser.parse(JsonParser.java:59)
        at com.google.gson.JsonParser.parse(JsonParser.java:45)
        at fr.inria.jtravis.helpers.AbstractHelper.getJsonFromStringContent(AbstractHelper.java:129)
        at fr.inria.jtravis.helpers.EntityHelper.getEntityFromUri(EntityHelper.java:36)
        at fr.inria.jtravis.helpers.LogHelper.from(LogHelper.java:23)
        at fr.inria.jtravis.entities.Job.fetchLog(Job.java:160)
        at fr.inria.jtravis.entities.Job.getLog(Job.java:172)
        at fr.inria.spirals.repairnator.scanner.ProjectScanner.testBuild(ProjectScanner.java:311)
        at fr.inria.spirals.repairnator.scanner.ProjectScanner.getBuildToBeInspected(ProjectScanner.java:224)
        at fr.inria.spirals.repairnator.scanner.ProjectScanner.getListOfBuildsFromRepo(ProjectScanner.java:212)
        at fr.inria.spirals.repairnator.scanner.ProjectScanner.getListOfBuildsToBeInspectedFromProjects(ProjectScanner.java:162)
        at fr.inria.spirals.repairnator.scanner.Launcher.runScanner(Launcher.java:228)
        at fr.inria.spirals.repairnator.scanner.Launcher.mainProcess(Launcher.java:203)
        at fr.inria.spirals.repairnator.scanner.Launcher.main(Launcher.java:331)
Caused by: java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3332)
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:596)
        at java.lang.StringBuilder.append(StringBuilder.java:190)
        at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1003)
        at com.google.gson.stream.JsonReader.nextString(JsonReader.java:815)
        at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:718)
        at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739)
        at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:731)
        at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739)
        at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714)

Find a way to retrieve committerEmail

In Travis API V2 the commit object was also returning the committer email. It seems it's not the case anymore in V3. We might be able to retrieve it by using GH API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.