test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

no such file or directory when test reporter is run in travis

Open lapots opened this issue 8 years ago • 9 comments

I am trying to integrate travis with code climate. I have java project and use jacoco for coverage. My .travis.yml looks like this and I encrypted CC_TEST_REPORTER_ID

language: java
jdk: oraclejdk8
dist: trusty
sudo: true
before_script:
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
  - chmod +x ./cc-test-reporter
  - ./cc-test-reporter before-build
before_deploy:
  - ./cc-test-reporter format-coverage -d -t jacoco /home/travis/build/lapots/judge-rule-engine/build/reports/jacoco/test/jacocoTestReport.xml
  - ./cc-test-reporter upload-coverage -d
...
env:
  global:
  - secure: g7mSMZ4
  - secure: eDMCjJK

When it invokes test-reporter the logs look like this

$ ./cc-test-reporter format-coverage -d -t jacoco /home/travis/build/lapots/judge-rule-engine/build/reports/jacoco/test/jacocoTestReport.xml
time="2018-02-17T14:49:31Z" level=debug msg="coverage path /home/travis/build/lapots/judge-rule-engine/build/reports/jacoco/test/jacocoTestReport.xml" 
time="2018-02-17T14:49:31Z" level=debug msg="using formatter jacoco" 
time="2018-02-17T14:49:31Z" level=debug msg="checking search path /home/travis/build/lapots/judge-rule-engine/build/reports/jacoco/test/jacocoTestReport.xml for jacoco formatter" 
time="2018-02-17T14:49:31Z" level=debug msg="couldn't load committed at from ENV, trying git..." 
time="2018-02-17T14:49:31Z" level=info msg="trimming with prefix /home/travis/build/lapots/judge-rule-engine/" 
time="2018-02-17T14:49:31Z" level=debug msg="getting fallback blob_id for source file com/lapots/breed/judge/controller/BasicController.java" 
time="2018-02-17T14:49:31Z" level=error msg="failed to read file com/lapots/breed/judge/controller/BasicController.java\nopen com/lapots/breed/judge/controller/BasicController.java: no such file or directory" 
Error: open com/lapots/breed/judge/controller/BasicController.java: no such file or directory
Usage:
  cc-test-reporter format-coverage [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]
  -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/lapots/judge-rule-engine")
Global Flags:
  -d, --debug   run in debug mode
The command "./cc-test-reporter format-coverage -d -t jacoco /home/travis/build/lapots/judge-rule-engine/build/reports/jacoco/test/jacocoTestReport.xml" failed and exited with 255 during .

It seems to unable to find .java files. Why is that?

The build log is here link to travis build

lapots avatar Feb 17 '18 14:02 lapots

Getting a similar error with Travis + Python: time="2018-02-28T03:33:53Z" level=error msg="failed to read file lib.py\nopen lib.py: no such file or directory" Error: open lib.py: no such file or directory

If I had to hazard a guess it looks like it tries to open my lib directory as a lib.py file 🤔 (either the /lib one or the /tests/lib one) Not sure how long this has been going on though. Just realized today by working on that repo.

jcrevits avatar Feb 28 '18 03:02 jcrevits

Hey @lapots , sorry for the delay with getting to this. I've forked a copy of your repo, and I'm currently taking a look at your setup. I'll get back to as soon as I have an update on that.

@jcrevits , do you mind opening up a ticket at https://codeclimate.com/help ?

To help troubleshoot, please include in the ticket:

Please Include:

  • Repo name
  • CI name
  • If you use single, parallel or multi-suite builds
  • A copy of your CI configuration file
  • Output from your CI when using the --debug flag in your CI configuration
  • Any relevant screenshots of your setup

I'll take a look at your configuration as soon as you get that in. Thanks so much for your patience here, folks.

davehenton avatar Mar 02 '18 21:03 davehenton

Same problem here and I'm also using Travis, Code Climate, and Jacoco.

yurifds avatar Mar 10 '18 02:03 yurifds

Hey @yurifds , do you mind opening a ticket at https://codeclimate.com/help? With that, please include:

  • Repo name
  • If you use single, parallel or multi-suite builds
  • A copy of your CI configuration file
  • Output from your CI when using the --debug flag in your CI configuration
  • Any relevant screenshots of your setup

I'll keep an eye out, and get back to you as soon as I have a chance to look at your setup. Thanks!

davehenton avatar Mar 14 '18 17:03 davehenton

I'm running into a similar issue with TravisCI and Jacoco. Has anyone determined potential culprits for this? Happy to provide additional details

seancarroll avatar Nov 18 '18 02:11 seancarroll

Any update? Running into this issue as well. Thinking it's a problem with the working folder as I'm running it from the root of a parent project with GIT and Maven submodules.

bbottema avatar Jan 12 '19 17:01 bbottema

HI @bbottema,

It sounds like you might need to change where the test reporter is looking. Can you send me your info via our help form?

  • Repo name
  • If you use single, parallel or multi-suite builds
  • A copy of your CI configuration file
  • Output from your CI when using the --debug flag in your CI configuration
  • Any relevant screenshots of your setup

Thanks! Happy to take a closer look. We'll follow up here with our findings.

efueger avatar Apr 23 '19 15:04 efueger

It would be really nice if instead of sending everyone to a private help form you'll would put details here. This way the community can self help and learn from one another.

awentzel avatar Apr 21 '20 20:04 awentzel

I finally found a workaround which worked for me, it took me a while and the support from CC was inconclusive :(

Bear in mind that my project is in golang, so it can be slightly different in other languages, but the idea should be the same...

This was the error I got:

go tool cover -html=c.out
./test-reporter --debug after-build
DEBU[0000] about to run format-coverage                 
DEBU[0000] searching for a formatter to use             
DEBU[0000] checking clover formatter                    
DEBU[0000] checking search path build/logs/clover.xml for clover formatter 
DEBU[0000] checking search path clover.xml for clover formatter 
DEBU[0000] checking excoveralls formatter               
DEBU[0000] checking search path cover/excoveralls.json for excoveralls formatter 
DEBU[0000] checking gcov formatter                      
DEBU[0000] checking search path ./ for GCov formatter   
DEBU[0000] checking lcov-json formatter                 
DEBU[0000] checking cobertura formatter                 
DEBU[0000] checking search path cobertura.xml for cobertura formatter 
DEBU[0000] checking coverage.py formatter               
DEBU[0000] checking search path coverage.xml for coverage.py formatter 
DEBU[0000] checking gocov formatter                     
DEBU[0000] checking search path c.out for gocov formatter 
DEBU[0000] found file c.out for gocov formatter         
DEBU[0000] couldn't load branch from ENV, trying git... 
DEBU[0000] couldn't load commit sha from ENV, trying git... 
DEBU[0000] couldn't load committed at from ENV, trying git... 
INFO[0000] trimming with prefix /Users/fabio/Personal/go-proxy-cache/ 
DEBU[0000] getting fallback blob_id for source file github.com/fabiocicerchia/go-proxy-cache/cache/engine/client/client.go 
ERRO[0000] failed to read file github.com/fabiocicerchia/go-proxy-cache/cache/engine/client/client.go
open github.com/fabiocicerchia/go-proxy-cache/cache/engine/client/client.go: no such file or directory 
Error: open github.com/fabiocicerchia/go-proxy-cache/cache/engine/client/client.go: no such file or directory
Usage:
  cc-test-reporter after-build [flags]

Flags:
  -s, --batch-size int               batch size for source files (default 500)
  -e, --coverage-endpoint string     endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
  -t, --coverage-input-type string   type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, lcov-json, simplecov, xccov]
      --exit-code int                exit code of the test run
  -r, --id string                    reporter identifier (default "1e7436a6daf59f7ee46b5f716eaf8822f549aeca8169ad67a7635d496d69cf6f")
      --insecure                     send coverage insecurely (without HTTPS)
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/Users/fabio/Personal/go-proxy-cache")

Global Flags:
  -d, --debug   run in debug mode

make: *** [codeclimate] Error 255

The culprit was open github.com/fabiocicerchia/go-proxy-cache/cache/engine/client/client.go: no such file or directory

So I had to be creative, and I'm sorry for such ugly workaround (but as long as it works we're all happy):

mkdir -p <PROJECT_ROOT_FOLDER>/github.com/<USER>
ln -s <PROJECT_ROOT_FOLDER> <PROJECT_ROOT_FOLDER>/github.com/<USER>/<PROJECT_NAME>

hence, in my case:

cd <PROJECT_ROOT_FOLDER>
mkdir -p ./github.com/fabiocicerchia
ln -s $PWD ./github.com/fabiocicerchia/go-proxy-cache

Hope it helps you people! 🤞

fabiocicerchia avatar Aug 27 '21 19:08 fabiocicerchia