codeclimate / test-reporter

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

Setup code coverage on travis with a mono-repo architecture #280

Closed flegall closed 6 years ago

flegall commented 6 years ago

Hi,

I'm trying to set up code coverage on my travis build of js-given (https://github.com/jsGiven/jsGiven).

In my build the coverage file is located in ./js-given/coverage/lcov.info

The coverage is there, because coveralls already use it

I've setup the after_script part to :

after_script:
  - ./cc-test-reporter -p js-given after-build --exit-code $TRAVIS_TEST_RESULT

I'm having this error :

$ ./cc-test-reporter -p js-given after-build --exit-code $TRAVIS_TEST_RESULT

Error: could not find any viable formatter. available formatters: clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov

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, simplecov]

      --exit-code int                exit code of the test run

  -r, --id string                    reporter identifier (default "7372bdd9c70ad42f845941f1c5fba601dc0af2bb4ec221d55f6b04d228261b2c")

  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/travis/build/jsGiven/jsGiven")

Global Flags:

  -d, --debug   run in debug mode

Regards,

Florent

wfleming commented 6 years ago

Hi @flegall,

Apologies for the delayed reply, I was away for the holidays & am still catching up on some things.

Each formatter looks in a hard-coded path for the coverage information, and the lcov formatter expects to find the coverage at coverage/lcov.info. In your case it seems like the simplest thing to do might be to just cd js-given before running cc-test-reporter after-build. If you do that you'll probably also need to drop the -p js-given flag: I suspect the actual file paths listed in your lcov.info are already relative to js-given, e.g. that file would have an entry for src/Stage.js, not js-given/src/Stage.js.

Let me know if that helps.

karuhanga commented 6 years ago

In case this helps someone in the future. I'd simply forgotten to generate my report file. Be sure to check that this file is actually generated.