Code Monkey home page Code Monkey logo

gradle-bitbucket-code-coverage-plugin's Introduction

Hi, I'm Marcel ๐Ÿ‘‹

gradle-bitbucket-code-coverage-plugin's People

Contributors

madisparn avatar marcelkliemannel avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gradle-bitbucket-code-coverage-plugin's Issues

`publishJacocoCodeCoverageToBitbucket` wants the JaCoCo report tasks executed in the same Gradle build execution

I noticed this code:

      task.onlyIf { jacocoReportTasks.any { task -> task.didWork } }

However, according to the API docs, didWork may return true even if the task was run in a previous Gradle execution, but after when running the publication task separately. So in other words, this forces us to execute the publication tasks in the same run as the tasks that execute the tests and generate coverage.

In other words only this works, which is not so nice:

gw check
gw --rerun-tasks publishJacocoCodeCoverageToBitbucket

Gradle plugin does not like my coverage data

When I debug my Gradle build, it seems the plugin wants to send data like this to Bitbucket:

{
  "files": [
    {
      "path": "my-submodule/src/main/java/com/example/service/somePackage/SomeFile.java",
      "coverage": "C:;P:;U:"
    },
    {
      "path": "my-submodule/src/main/java/com/example/service/someOtherPackage/SomeOtherFile.java",
      "coverage": "C:;P:;U:13,17,18"
    },
    {
      "path": "my-submodule/src/main/java/com/example/service/someThirdPackage/SomeThirdFile.java",
      "coverage": "C:;P:;U:"
    },
	// ...
  ]
}

If I try it on the command line, it fails:

curl --verbose -X POST -H "Content-Type: application/json" --data @data.json -u "myuser:$BITBUCKET_TOKEN" "https://my.bitbucket.host/bitbucket/rest/code-coverage/1.0/commits/63642f1b842e22d1e1218cc2404adabb8dd42b41"
(...)
< HTTP/1.1 400 
(...)
{"context":null,"message":"Invalid or empty coverage data was supplied for one or more files.","exceptionName":null,"invalidEntities":[{"path":"my-submodule/src/main/java/com/example/service/somePackage/SomeFile.java","coverage":"C:;P:;U:"},
(...)
]}

So it has an issue with files for which only empty coverage was found.

Gradle however, does not detect this outcome, despite of the same HTTP response code (400) that I detect in the access log of Bitbucket server, and does not report this to the user, but something else:

2023-07-27T16:21:21.998+0200 [DEBUG] [jdk.internal.httpclient.debug] [HttpClient-6-Worker-0] [2923s 652ms] Http1Exchange getResponseAsync completed java.net.http.HttpTimeoutException: request timed out
2023-07-27T16:21:21.998+0200 [DEBUG] [jdk.internal.httpclient.debug] [HttpClient-6-SelectorManager] [2923s 652ms] SocketTube(6) got read error: java.io.IOException: connection closed locally
2023-07-27T16:21:21.998+0200 [DEBUG] [jdk.internal.httpclient.debug] [HttpClient-6-Worker-0] [2923s 652ms] Http1Exchange https://my.bitbucket.host/bitbucket/rest/code-coverage/1.0/commits/63642f1b842e22d1e1218cc2404adabb8dd42b41: completed cf with java.net.http.HttpTimeoutException: request timed out

So the outcome is a Gradle exception saying:

2023-07-27T16:21:22.010+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
2023-07-27T16:21:22.010+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':my-project-subproject:publishJacocoCodeCoverageToBitbucket'.
(...)
2023-07-27T16:21:22.010+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Failed to send code coverage to Bitbucket.
(...)
2023-07-27T16:21:22.012+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.net.http.HttpTimeoutException: request timed out
2023-07-27T16:21:22.012+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:559)
2023-07-27T16:21:22.012+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
2023-07-27T16:21:22.012+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at dev.turingcomplete.bitbucketcodecoverage.PublishCodeCoverageToBitbucketTask.publishCodeCoverageToBitbucketApi(PublishCodeCoverageToBitbucketTask.kt:221)

At least that's what I think is going on. I couldn't find a way to look into the HTTPS traffic via Gradle.

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.