Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trautonen/coveralls-maven-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.1.0
Choose a base ref
...
head repository: trautonen/coveralls-maven-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.2.0
Choose a head ref
  • 15 commits
  • 11 files changed
  • 1 contributor

Commits on Mar 18, 2015

  1. Verified

    This commit was signed with the committer’s verified signature.
    renovate-bot Mend Renovate
    Copy the full SHA
    a90a3db View commit details
  2. Fixed typo.

    trautonen committed Mar 18, 2015
    Copy the full SHA
    21acf60 View commit details
  3. Credit for Marvin Froeder.

    trautonen committed Mar 18, 2015
    Copy the full SHA
    4e014ff View commit details
  4. Fixed typo.

    trautonen committed Mar 18, 2015
    Copy the full SHA
    d08f0ba View commit details
  5. Copy the full SHA
    019c1c9 View commit details
  6. Copy the full SHA
    bd4426d View commit details

Commits on Jun 16, 2015

  1. Copy the full SHA
    20490f6 View commit details

Commits on Jul 10, 2015

  1. Copy the full SHA
    66b7f28 View commit details
  2. Copy the full SHA
    3583c70 View commit details

Commits on Aug 18, 2015

  1. Copy the full SHA
    fa7830f View commit details
  2. Copy the full SHA
    183fcf5 View commit details
  3. Dependency updates.

    trautonen committed Aug 18, 2015
    Copy the full SHA
    94bec51 View commit details
  4. Run container based travis.

    trautonen committed Aug 18, 2015
    Copy the full SHA
    40da493 View commit details

Commits on Aug 19, 2015

  1. Gitter integration.

    trautonen committed Aug 19, 2015
    Copy the full SHA
    b3f0c3f View commit details
  2. Updated to version 3.2.0.

    trautonen committed Aug 19, 2015
    Copy the full SHA
    bd92092 View commit details
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: java

sudo: false

jdk:
- oraclejdk7
# - openjdk7
@@ -20,3 +22,11 @@ script: python etc/travis-build.py --settings ~/.m2/sonatype.xml

after_success:
- mvn clean cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report

notifications:
webhooks:
urls:
- $GITTER_URL
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 3.1.0

- #63: Directory scanning source loader
- #65, #66, #68: Support for Shippable CI
- #67: Configurable project basedir


## 3.0.1

- #53: Improved error message for missing source encoding
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ Set up the Coveralls maven plugin in the build section of the project pom.xml:
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<configuration>
<repoToken>yourcoverallsprojectrepositorytoken</repoToken>
</configuration>
@@ -217,8 +217,9 @@ service environment will not override it.
| `pullRequest` | `String` | GitHub pull request identifier. If not provided the supported service environments are used. |
| `timestamp` | `Date` | **Default: ${timestamp}**<br>Build timestamp. Must be in Maven supported 'yyyy-MM-dd HH:mm:ssa' format. |
| `dryRun` | `boolean` | **Default: false**<br>Dry run Coveralls report without actually sending it. |
| `failOnServiceError` | `boolean` | **Default: true**<br> Fail build if Coveralls service is not available or submission fails for internal errors. |
| `scanForSources` | `boolean` | **Default: false**<br>Scan subdirectories for source files. |
| `coveralls.basedir` | `File` | **Default: ${project.basedir}<br>Base directory of the project. |
| `coveralls.basedir` | `File` | **Default: ${project.basedir}**<br>Base directory of the project. |
| `coveralls.skip` | `boolean` | **Default: false**<br>Skip the plugin execution. |


@@ -308,7 +309,8 @@ See [migration](MIGRATION.md) documentation for more information.
- Jakub Bednář (@bednar) for Saga integration and the idea of chaining multiple reports provided
by different coverage tools.
- Marvin Froeder (@velo) for Shippable support, configurable basedir and directory scanning source
loader.
### Continuous integration
26 changes: 20 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@
<parent>
<groupId>org.eluder</groupId>
<artifactId>eluder-parent</artifactId>
<version>6</version>
<version>7</version>
</parent>

<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<packaging>maven-plugin</packaging>

<name>coveralls-maven-plugin</name>
@@ -47,9 +47,9 @@
</scm>

<properties>
<httpclient.version>4.3.5</httpclient.version>
<jackson.version>2.4.2</jackson.version>
<jgit.version>3.4.1.201406201815-r</jgit.version>
<httpclient.version>4.5</httpclient.version>
<jackson.version>2.6.1</jackson.version>
<jgit.version>4.0.1.201506240215-r</jgit.version>
<maven.version>3.0</maven.version>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ssa</maven.build.timestamp.format>
<timestamp>${maven.build.timestamp}</timestamp>
@@ -59,6 +59,12 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -98,6 +104,14 @@
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
@@ -107,7 +121,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<version>3.4</version>
<scope>test</scope>
</dependency>
</dependencies>
4 changes: 2 additions & 2 deletions sample/pom.xml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<parent>
<groupId>org.eluder</groupId>
<artifactId>eluder-parent</artifactId>
<version>5</version>
<version>6</version>
<relativePath></relativePath>
</parent>

@@ -31,7 +31,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
<configuration>
<sourceDirectories>
<sourceDirectory>module1/src/main/resources</sourceDirectory>
Original file line number Diff line number Diff line change
@@ -176,6 +176,12 @@ public class CoverallsReportMojo extends AbstractMojo {
@Parameter(property = "dryRun", defaultValue = "false")
protected boolean dryRun;

/**
* Fail build if Coveralls service is not available or submission fails for internal errors.
*/
@Parameter(property = "failOnServiceError", defaultValue = "true")
protected boolean failOnServiceError;

/**
* Scan subdirectories for source files.
*/
@@ -367,12 +373,21 @@ private void submitData(final CoverallsClient client, final File coverallsFile)
getLog().info(" If you see question marks in the report, please be patient");
} catch (ProcessingException ex) {
long duration = System.currentTimeMillis() - now;
getLog().error("Submission failed in " + duration + "ms while processing data");
throw ex;
String message = "Submission failed in " + duration + "ms while processing data";
handleSubmissionError(ex, message, true);
} catch (IOException ex) {
long duration = System.currentTimeMillis() - now;
getLog().error("Submission failed in " + duration + "ms while handling I/O operations");
String message = "Submission failed in " + duration + "ms while handling I/O operations";
handleSubmissionError(ex, message, failOnServiceError);
}
}

private <T extends Exception> void handleSubmissionError(final T ex, final String message, final boolean failOnException) throws T {
if (failOnException) {
getLog().error(message);
throw ex;
} else {
getLog().warn(message);
}
}

Original file line number Diff line number Diff line change
@@ -26,12 +26,12 @@
* %[license]
*/

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class Source implements JsonObject {

private static final Pattern NEWLINE = Pattern.compile("\r\n|\r|\n");
@@ -89,6 +89,10 @@ public void setClassifier(final String classifier) {
}

public void addCoverage(final int lineNumber, final Integer coverage) {
int index = lineNumber - 1;
if (index >= this.coverage.length) {
throw new IllegalArgumentException("Line number " + lineNumber + " is greater than the source file " + name + " size");
}
this.coverage[lineNumber - 1] = coverage;
}
}
Original file line number Diff line number Diff line change
@@ -26,16 +26,11 @@
* %[license]
*/

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.Provider;
import java.security.Security;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
@@ -48,6 +43,12 @@
import org.eluder.coveralls.maven.plugin.ProcessingException;
import org.eluder.coveralls.maven.plugin.domain.CoverallsResponse;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.Provider;
import java.security.Security;

public class CoverallsClient {

static {
@@ -94,6 +95,9 @@ private CoverallsResponse parseResponse(final HttpResponse response) throws Proc
ContentType contentType = ContentType.getOrDefault(entity);
InputStreamReader reader = null;
try {
if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
throw new IOException("Coveralls API interal error");
}
reader = new InputStreamReader(entity.getContent(), contentType.getCharset());
CoverallsResponse cr = objectMapper.readValue(reader, CoverallsResponse.class);
if (cr.isError()) {
Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ public Log getLog() {
};
mojo.project = projectMock;
mojo.sourceEncoding = "UTF-8";
mojo.failOnServiceError = true;

when(modelMock.getReporting()).thenReturn(reportingMock);
when(reportingMock.getOutputDirectory()).thenReturn(folder.getRoot().getAbsolutePath());
@@ -232,12 +233,6 @@ public void testSuccesfullSubmission() throws Exception {

verifySuccessfullSubmit(logMock, fixture);
}

@Test(expected = MojoFailureException.class)
public void testFailedSubmission() throws Exception {
when(coverallsClientMock.submit(any(File.class))).thenThrow(ProcessingException.class);
mojo.execute();
}

@Test
public void testFailWithProcessingException() throws Exception {
@@ -249,6 +244,18 @@ public void testFailWithProcessingException() throws Exception {
assertEquals(ex.getCause().getClass(), ProcessingException.class);
}
}

@Test
public void testProcessingExceptionWithAllowedServiceFailure() throws Exception {
mojo.failOnServiceError = false;
when(coverallsClientMock.submit(any(File.class))).thenThrow(new ProcessingException());
try {
mojo.execute();
fail("Should have failed with MojoFailureException");
} catch (MojoFailureException ex) {
assertEquals(ex.getCause().getClass(), ProcessingException.class);
}
}

@Test
public void testFailWithIOException() throws Exception {
@@ -260,6 +267,14 @@ public void testFailWithIOException() throws Exception {
assertEquals(ex.getCause().getClass(), IOException.class);
}
}

@Test
public void testIOExceptionWithAllowedServiceFailure() throws Exception {
mojo.failOnServiceError = false;
when(coverallsClientMock.submit(any(File.class))).thenThrow(new IOException());
mojo.execute();
verify(logMock).warn(anyString());
}

@Test
public void testFailWithNullPointerException() throws Exception {
Original file line number Diff line number Diff line change
@@ -26,11 +26,12 @@
* %[license]
*/

import static org.junit.Assert.*;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

public class SourceTest {

@Test
@@ -40,6 +41,12 @@ public void testAddCoverage() {
source.addCoverage(3, 3);
assertArrayEquals(new Integer[] { 3, null, 3, null }, source.getCoverage());
}

@Test(expected = IllegalArgumentException.class)
public void testAddCoverageForSourceOutOfBounds() {
Source source = new Source("src/main/java/Hello.java", "public class Hello {\n \n}\n");
source.addCoverage(5, 1);
}

@Test
@Ignore("#45: https://github.com/trautonen/coveralls-maven-plugin/issues/45")
Original file line number Diff line number Diff line change
@@ -26,15 +26,6 @@
* %[license]
*/

import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -53,6 +44,15 @@
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class CoverallsClientTest {

@@ -83,12 +83,23 @@ public void testConstructors() {

@Test
public void testSubmit() throws Exception {
StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK");
when(httpResponseMock.getStatusLine()).thenReturn(statusLine);
when(httpClientMock.execute(any(HttpUriRequest.class))).thenReturn(httpResponseMock);
when(httpResponseMock.getEntity()).thenReturn(httpEntityMock);
when(httpEntityMock.getContent()).thenReturn(coverallsResponse(new CoverallsResponse("success", false, "")));
CoverallsClient client = new CoverallsClient("http://test.com/coveralls", httpClientMock, new ObjectMapper());
client.submit(file);
}

@Test(expected = IOException.class)
public void testFailOnServiceError() throws Exception {
StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, 500, "Internal Error");
when(httpClientMock.execute(any(HttpUriRequest.class))).thenReturn(httpResponseMock);
when(httpResponseMock.getStatusLine()).thenReturn(statusLine);
CoverallsClient client = new CoverallsClient("http://test.com/coveralls", httpClientMock, new ObjectMapper());
client.submit(file);
}

@Test(expected = ProcessingException.class)
public void testParseInvalidResponse() throws Exception {