codeclimate / test-reporter

Code Climate Test Reporter
MIT License
155 stars 76 forks source link

Travis Jacoco setup: Error: could not find any viable formatter #397

Open efueger opened 5 years ago

efueger commented 5 years ago

Customer using jacoco and couldn't figure out how to set it up. They were able to point it to the xml file. But then it complaints about the source.

image image
rhwood commented 5 years ago

See the callout on using JaCoCo at https://docs.codeclimate.com/docs/configuring-test-coverage and also https://github.com/codeclimate/test-reporter/issues/259#issuecomment-374280649

khatkarr commented 4 years ago

@rhwood I am facing the same issue. I followed the documentation and used alternate command.

$ echo "Step Name - after_script"
$ JACOCO_SOURCE_PATH=report/src/main/java ./cc-test-reporter -d format-coverage ./report/target/site/jacoco-aggregate/jacoco.xml --input-type jacoco
time="2020-04-02T21:50:48Z" level=debug msg="coverage path ./report/target/site/jacoco-aggregate/jacoco.xml" 
time="2020-04-02T21:50:48Z" level=debug msg="using formatter jacoco" 
time="2020-04-02T21:50:48Z" level=debug msg="checking search path ./report/target/site/jacoco-aggregate/jacoco.xml for jacoco formatter" 
time="2020-04-02T21:50:48Z" level=debug msg="couldn't load committed at from ENV, trying git..." 
Error: could not find coverage info for source files
Usage:
  cc-test-reporter format-coverage [coverage file] [flags]
Flags:
      --add-prefix string   add this prefix to file paths
  -t, --input-type string   type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov, xccov]
  -o, --output string       output path (default "coverage/codeclimate.json")
  -p, --prefix string       the root directory where the coverage analysis was performed (default "/home/travis/build/WW-Digital/wcp-broadleaf")
Global Flags:
  -d, --debug   run in debug mode
$ ./cc-test-reporter -d upload-coverage
Error: open coverage/codeclimate.json: no such file or directory
Usage:
  cc-test-reporter upload-coverage [flags]
Flags:
  -s, --batch-size int    batch size for source files (default 500)
  -e, --endpoint string   endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
  -r, --id string         reporter identifier (default "[secure]")
  -i, --input string      input path (default "coverage/codeclimate.json")
      --insecure          send coverage insecurely (without HTTPS)

There are multiple modules in the project and an aggregate jacoco.xml file is generated. But rest-reporter is not able to find it. Though the build is running in TravisCI but when I run the build in my local than I get almost 3.49MB file jacoco.xml at report/target/site/jacoco-aggregate/. I am pretty sure the file is there. There are 4 files at report/target/site/jacoco-aggregate/:

index.html
jacoco.csv
jacoco.xml
jacoco-sessions.html

@efueger did you find any solution to this issue. Pls share.