Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting CodeCoverage with Circle CI #11

Closed
amitmawkin opened this issue Nov 20, 2015 · 25 comments
Closed

Reporting CodeCoverage with Circle CI #11

amitmawkin opened this issue Nov 20, 2015 · 25 comments

Comments

@amitmawkin
Copy link
Contributor

I am getting the following error when I am trying to report codacy code coverage feature language is java

sudo codacy-coverage-reporter -l Java -r /home/ubuntu/lcd/api/target/surefire-reports/cobertura/coverage.xml -t $CODACY_PROJECT_TOKEN
2015-11-20 04:06:58,887 [info]  com.codacy Parsing coverage data... 
2015-11-20 04:06:59,506 [info]  com.codacy Uploading coverage data... 

2015-11-20 04:07:00,639 [error] com.codacy Failed to upload report: Not Found sudo codacy-coverage-reporter -l Java -r /home/ubuntu/lcd/api/target/surefire-reports/cobertura/coverage.xml -t $CODACY_PROJECT_TOKEN returned exit code 1
@amitmawkin
Copy link
Contributor Author

adding detail debug output below, masking my api token

ubuntu@box389:~/lcd$ sudo codacy-coverage-reporter -l Java -r /home/ubuntu/lcd/api/target/surefire-reports/cobertura/coverage.xml -t $CODACY_PROJECT_TOKEN --debug
2015-11-20 04:15:11,076 [debug] com.codacy Config(Java,********************,/home/ubuntu/lcd/api/target/surefire-reports/cobertura/coverage.xml,https://api.codacy.com,,true)
2015-11-20 04:15:11,197 [debug] com.codacy Project token: ********************
2015-11-20 04:15:11,197 [info]  com.codacy Parsing coverage data...
2015-11-20 04:15:11,583 [debug] com.codacy Saving parsed report to /home/ubuntu/lcd/api/target/surefire-reports/cobertura/codacy-coverage.json
2015-11-20 04:15:11,586 [debug] com.codacy CoverageReport(Java,59,ArrayBuffer(CoverageFileReport(com/lightningcd/api/model/DeployApplication.java,100,Map(67 -> 1)), CoverageFileReport(com/lightningcd/api/service/DeployApplicationService.java,100,Map()), CoverageFileReport(com/lightningcd/api/model/ProvisioningTypes.java,50,Map()), CoverageFileReport(com/lightningcd/api/request/DeployApplicationRequest.java,0,Map()), CoverageFileReport(com/lightningcd/api/exception/DeployApplicationNotFoundException.java,100,Map()), CoverageFileReport(com/lightningcd/api/exception/ConfigurationNotFoundException.java,100,Map()), CoverageFileReport(com/lightningcd/api/model/BaseModel.java,100,Map()), CoverageFileReport(com/lightningcd/api/request/ProvisioningConfRequest.java,0,Map()), CoverageFileReport(com/lightningcd/api/model/ProvisionEnv.java,100,Map()), CoverageFileReport(com/lightningcd/api/model/Component.java,100,Map()), CoverageFileReport(com/lightningcd/api/repository/DeployApplicationRepository.java,100,Map()), CoverageFileReport(com/lightningcd/api/config/ApiDocumentationConfiguration.java,100,Map(18 -> 1, 33 -> 1, 29 -> 1)), CoverageFileReport(com/lightningcd/api/model/Environment.java,100,Map()), CoverageFileReport(com/lightningcd/api/rest/ProvisioningConfController.java,79,Map(52 -> 1, 61 -> 1, 45 -> 1, 39 -> 1)), CoverageFileReport(com/lightningcd/api/repository/ProvisioningConfRepository.java,100,Map()), CoverageFileReport(com/lightningcd/api/Application.java,0,Map()), CoverageFileReport(com/lightningcd/api/service/ProvisioningConfService.java,100,Map()), CoverageFileReport(com/lightningcd/api/service/DeployApplicationServiceImpl.java,56,Map(69 -> 1, 88 -> 1, 115 -> 1, 84 -> 1, 116 -> 1, 117 -> 1, 85 -> 1, 53 -> 2, 54 -> 2, 80 -> 1, 67 -> 1, 87 -> 1, 79 -> 1, 68 -> 1, 83 -> 1)), CoverageFileReport(com/lightningcd/api/rest/DeployApplicationController.java,84,Map(56 -> 1, 66 -> 1, 40 -> 2, 58 -> 1, 47 -> 1)), CoverageFileReport(com/lightningcd/api/service/ProvisioningConfServiceImpl.java,68,Map(69 -> 1, 56 -> 1, 57 -> 1, 84 -> 1, 85 -> 1, 70 -> 1, 97 -> 1, 96 -> 1, 71 -> 1, 86 -> 1, 98 -> 1, 82 -> 1, 83 -> 1)), CoverageFileReport(com/lightningcd/api/model/ProvisioningConf.java,100,Map())))
2015-11-20 04:15:11,810 [info]  com.codacy Uploading coverage data...
2015-11-20 04:15:13,044 [error] com.codacy Failed to upload report: Not Found

@pedrorijo91
Copy link
Contributor

Hi @amitmawkin,

I'm sorry you are getting that error. We found a bug some days ago, and we released a new version (1.0.4) that solves that problem. Unfortunately, JPM still hasn't fetch the new version.

A temporary solution is to build from source:

1- Clone our repository https://github.com/codacy/codacy-coverage-reporter

2- run the command sbt assembly. This will produce a .jar that you can run in the codacy-coverage-reporter/target/codacy-coverage-reporter-assembly-1.0.4.jar

3- in the project you want to send the coverage, instead of run with the codacy-coverage-reporter from JPM use the jar. Example:

~/git/codacy/java-project$ java -cp ../codacy-coverage-reporter/target/codacy-coverage-reporter-assembly-1.0.4.jar com.codacy.CodacyCoverageReporter -l Java -r jacoco.xml

Please, let us know if this temporary fix worked for you. And we are going to pressure JPM to update to our latest release.

Note: please be careful about publishing project tokens. You should revoke the current token and produce a new one, for security reasons

@pedrorijo91
Copy link
Contributor

@amitmawkin I'll assume the temporary fix worked for you. Nevertheless we just worked with JPM and everything must be working.

Closing the issue.

pedrorijo91 added a commit that referenced this issue Nov 22, 2015
Add issue troubleshooting #11
pedrorijo91 added a commit that referenced this issue Nov 22, 2015
Add issue troubleshooting #11
@amitmawkin
Copy link
Contributor Author

its still the same 1.0.3 version in jpm, i prefer the jpm version ,
image

@pedrorijo91
Copy link
Contributor

If you click the link (https://jpm4j.org/#!/p/com.codacy/codacy-coverage-reporter) you'll see the version 1.0.4 is already available.

If you remove it and uninstall it, you should have no errors.

image

@amitmawkin
Copy link
Contributor Author

I am giving it up this time got the jar , still unsuccessful look at the version it still shows 1.0.0

ubuntu@box3130:~/lcd$ sudo java -jar codacy-coverage-reporter-1.0.4-assembly.jar --help
codacy-coverage-reporter 1.0.0
Usage: codacy-coverage-reporter [options]

-l | --language
your project language
-t | --projectToken
your project API token
-r | --coverageReport
your project coverage file name
--codacyApiBaseUrl
the base URL for the Codacy API
--prefix
the project path prefix
--help
prints this usage text

@amitmawkin
Copy link
Contributor Author

will try compiling from source, looks like jpm is all messed up

@pedrorijo91
Copy link
Contributor

please, ignore the printed version. It's a known bug that's already being fixed: #8

As you may see, if everything is well configured, you should have no problems running the coverage step:

https://circleci.com/gh/codacy/codacy-api-java/21

@pjwalstrom
Copy link

just installed codacy-coverage-reporter using jpm. Still get the error

$ codacy-coverage-reporter -l Java -r coverage.xml 
2016-02-25 09:27:49,834 [info]  com.codacy Parsing coverage data... 
2016-02-25 09:27:50,302 [info]  com.codacy Uploading coverage data... 
2016-02-25 09:27:51,576 [error] com.codacy Failed to upload report: Not Found 

using java 8

@pedrorijo91
Copy link
Contributor

Hey @pjwalstrom

can you provide us more details about your issue? everything should be fixed currently, it seems to be specific for your case.

make sure you have the latest version:

[sudo] jpm remove codacy-coverage-reporter
[sudo] jpm install com.codacy:codacy-coverage-reporter:assembly

if the error persists, provide us the information outputted by running with the debug flag (--debug)

@pjwalstrom
Copy link

I did jpm install today, but not sure which version it is. How can I figure that out? Still getting the error, though. Here is the info with --debug

$ codacy-coverage-reporter -l Java -r coverage.xml --debug
2016-02-25 12:42:40,016 [debug] com.codacy Config(Java,*****,coverage.xml,https://api.codacy.com,,true) 
2016-02-25 12:42:40,106 [debug] com.codacy Project token: ***** 
2016-02-25 12:42:40,107 [info]  com.codacy Parsing coverage data... 
2016-02-25 12:42:40,262 [debug] com.codacy Saving parsed report to /Users/foobar/dev/foo-baz-api/codacy-coverage.json 
2016-02-25 12:42:40,264 [debug] com.codacy CoverageReport(Java,4,List(CoverageFileReport(com/foo/baz/model/NotifyRequest.java,0,Map()), CoverageFileReport(com/foo/baz/model/SubscribeRequest.java,0,Map()), CoverageFileReport(com/foo/baz/bar/auth/AuthenticationServiceImpl.java,0,Map()), CoverageFileReport(com/foo/baz/bar/auth/AuthInterceptor.java,0,Map()), CoverageFileReport(com/foo/baz/bar/BytesSerializable.java,0,Map()), CoverageFileReport(com/foo/baz/bar/LoggingInterceptor.java,0,Map()), CoverageFileReport(com/foo/baz/bar/Response.java,0,Map()), CoverageFileReport(com/foo/baz/bar/HealthCheck.java,0,Map()), CoverageFileReport(com/foo/baz/AppRouter.java,0,Map()), CoverageFileReport(com/foo/baz/RouterProvider.java,0,Map()), CoverageFileReport(com/foo/baz/PushAPIApp.java,0,Map()), CoverageFileReport(com/foo/baz/exception/InternalError.java,0,Map()), CoverageFileReport(com/foo/baz/exception/BadMethodError.java,0,Map()), CoverageFileReport(com/foo/baz/exception/BadRequestError.java,0,Map()), CoverageFileReport(com/foo/baz/exception/BaseError.java,0,Map()), CoverageFileReport(com/foo/baz/handler/BaseHandler.java,39,Map(37 -> 1, 25 -> 1, 29 -> 1, 28 -> 1, 33 -> 1, 32 -> 1, 34 -> 1, 27 -> 1, 35 -> 1)), CoverageFileReport(com/foo/baz/handler/SubscribeHandler.java,0,Map()), CoverageFileReport(com/foo/baz/handler/NotifyHandler.java,0,Map()), CoverageFileReport(com/foo/baz/service/bazservice/SNSPushService.java,0,Map()), CoverageFileReport(com/foo/baz/service/bazservice/AbstractPushService.java,0,Map()), CoverageFileReport(com/foo/baz/service/bazservice/DummyPushService.java,0,Map()), CoverageFileReport(com/foo/baz/service/storageservice/CassandraStorageService.java,0,Map()), CoverageFileReport(com/foo/baz/service/storageservice/AbstractStorageService.java,0,Map()), CoverageFileReport(com/foo/baz/service/storageservice/DummyStorageService.java,0,Map()))) 
2016-02-25 12:42:40,440 [info]  com.codacy Uploading coverage data... 
2016-02-25 12:42:41,448 [error] com.codacy Failed to upload report: Not Found 

@pedrorijo91
Copy link
Contributor

Is the project public so we can look at it? It seems that you are not providing the correct path to the file, but it's hard to reproduce the error without any more information (like a concrete example)

Have you look at our troubleshooting section? https://github.com/codacy/codacy-coverage-reporter#troubleshooting

@pjwalstrom
Copy link

yes, I've looked at the troubleshooting, didn't help much. The file is there in the root directory

$ ls -l *.xml
-rw-rw-rw-  1 foobar  1503010931  50530 Feb 25 09:01 coverage.xml
$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

and I have the following config in my build.gradle, to be able to use jacoco

apply plugin: 'jacoco'

jacocoTestReport {
    reports {
        xml.enabled true
    }
}

repo is not public, unfortunately

@pjwalstrom
Copy link

$ cat coverage.xml 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd"><report name="foo-api"><sessioninfo id="local.foo.com-b025f79e" start="1456387172910" dump="1456387175196"/><package name="com/foo/bar/model">....

@pedrorijo91
Copy link
Contributor

can you confirm you are using the version 1.0.5 ? You can get the version through codacy-coverage-reporter --help

@pedrorijo91
Copy link
Contributor

also, make sure the token you are using is updated: on Codacy platform, go to project settings, integrations, (add) Project API

@pjwalstrom
Copy link

well, seems like it's version 1.0.0, but that does is not correct as far as I understand from the previous messages in this thread.

The token is correct as according to the Project API Token

$ codacy-coverage-reporter --help
codacy-coverage-reporter 1.0.0
Usage: codacy-coverage-reporter [options]

  -l <value> | --language <value>
        your project language
  -t <value> | --projectToken <value>
        your project API token
  -r <value> | --coverageReport <value>
        your project coverage file name
  --codacyApiBaseUrl <value>
        the base URL for the Codacy API
  --prefix <value>
        the project path prefix
  --help
        prints this usage text

@pedrorijo91
Copy link
Contributor

we released a new version yesterday (1.0.5) that fixes some bugs, and also fixes the print version. Try with the updated version.

Instructions on how to remove installed version on https://github.com/codacy/codacy-coverage-reporter#build-from-source:

[sudo] jpm remove codacy-coverage-reporter

@pjwalstrom
Copy link

same problem with the new version

$ codacy-coverage-reporter --help
codacy-coverage-reporter 1.0.5

$ codacy-coverage-reporter -l Java -r coverage.xml --debug
2016-02-26 10:16:39,668 [debug] com.codacy Config(Java,*****,coverage.xml,https://api.codacy.com,,true) 
2016-02-26 10:16:39,758 [debug] com.codacy Project token: *****
2016-02-26 10:16:39,759 [info]  com.codacy Parsing coverage data... 
2016-02-26 10:16:39,920 [debug] com.codacy Saving parsed report to /Users/foobar/dev/foo/foo-bar-api/codacy-coverage.json 
2016-02-26 10:16:39,922 [debug] com.codacy CoverageReport(Java,4,List(CoverageFileReport(com/foo/bar/model/NotifyRequest.java,0,Map()), CoverageFileReport(com/foo/bar/model/SubscribeRequest.java,0,Map()), CoverageFileReport(com/foo/bar/common/auth/AuthenticationServiceImpl.java,0,Map()), CoverageFileReport(com/foo/bar/common/auth/AuthInterceptor.java,0,Map()), CoverageFileReport(com/foo/bar/common/BytesSerializable.java,0,Map()), CoverageFileReport(com/foo/bar/common/LoggingInterceptor.java,0,Map()), CoverageFileReport(com/foo/bar/common/Response.java,0,Map()), CoverageFileReport(com/foo/bar/common/HealthCheck.java,0,Map()), CoverageFileReport(com/foo/bar/AppRouter.java,0,Map()), CoverageFileReport(com/foo/bar/RouterProvider.java,0,Map()), CoverageFileReport(com/foo/bar/PushAPIApp.java,0,Map()), CoverageFileReport(com/foo/bar/exception/InternalError.java,0,Map()), CoverageFileReport(com/foo/bar/exception/BadMethodError.java,0,Map()), CoverageFileReport(com/foo/bar/exception/BadRequestError.java,0,Map()), CoverageFileReport(com/foo/bar/exception/BaseError.java,0,Map()), CoverageFileReport(com/foo/bar/handler/BaseHandler.java,39,Map(37 -> 1, 25 -> 1, 29 -> 1, 28 -> 1, 33 -> 1, 32 -> 1, 34 -> 1, 27 -> 1, 35 -> 1)), CoverageFileReport(com/foo/bar/handler/SubscribeHandler.java,0,Map()), CoverageFileReport(com/foo/bar/handler/NotifyHandler.java,0,Map()), CoverageFileReport(com/foo/bar/service/barservice/SNSPushService.java,0,Map()), CoverageFileReport(com/foo/bar/service/barservice/AbstractPushService.java,0,Map()), CoverageFileReport(com/foo/bar/service/barservice/DummyPushService.java,0,Map()), CoverageFileReport(com/foo/bar/service/storageservice/CassandraStorageService.java,0,Map()), CoverageFileReport(com/foo/bar/service/storageservice/AbstractStorageService.java,0,Map()), CoverageFileReport(com/foo/bar/service/storageservice/DummyStorageService.java,0,Map()))) 
2016-02-26 10:16:40,087 [info]  com.codacy Uploading coverage data... 
2016-02-26 10:16:40,914 [error] com.codacy Failed to upload report: Not Found 

@pjwalstrom
Copy link

ok, I just realized we might be trying to send the file to api.codacy.com, whereas we are not on your hosted solution, but on amazonws... How would we go about to upload there? Didn't occur to me before that this could be a problem

@caxaria
Copy link
Member

caxaria commented Feb 26, 2016

Hi,

Sorry for this! In custom urls, you should use http://YOUR_URL:16006. If you curl to that port, you should get the component name back (api).

@caxaria caxaria reopened this Feb 26, 2016
@pedrorijo91
Copy link
Contributor

As you can see in the code (we are going to improve the docs soon), you can set up a env variable to change the API url: CODACY_API_BASE_URL

@tonilz
Copy link

tonilz commented Feb 29, 2016

Still having some issues, even if I curl (from https://api.codacy.com/swagger#!/commit/delta).

We host codacy on our AWS, so we cannot use the Java library to upload the JSON.

Note that even the GETs are returning a {error: "not found"} so I understand that there is something wrong on either the URL or the way we configured our project.

# Response: "api" (so I understand the port is open and the API is listening there…)
curl http://<our hostname in amazon>:16006/2.0/coverage/1968569bd24b425f927c15b25b544265/Java"

# The json is empty, but when including a valid one returns the same response
# Response: {"error":"not found"}
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "api_token: <my api token>" "http://<our hostname in amazon>:16006/2.0/coverage/1968569bd24b425f927c15b25b544265/java"  -d '{}'

# Any other endpoint returns a {"error":"Request handler not found: …"}

Can anyone put some light?

@caxaria
Copy link
Member

caxaria commented Feb 29, 2016

Hi,

Please contact me at joao@codacy.com, as I will be checking on this today.

Thanks,

@tonilz
Copy link

tonilz commented Feb 29, 2016

For those who are trying CURL as I did... the header for the API token is project_token and not api_token as the docs mention.

@caxaria caxaria closed this as completed Mar 30, 2016
ljmf00 pushed a commit to ljmf00/codacy-coverage-reporter that referenced this issue Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants