codeclimate / test-reporter

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

Error: could not find coverage info for source files (using nyc, clover, circleci) #295

Closed aneilbaboo closed 6 years ago

aneilbaboo commented 6 years ago

On CircleCI, after producing clover.xml using nyc, I get "Error: could not find coverage info for source files". This is similar to https://github.com/codeclimate/test-reporter/issues/259, but none of the fixes mentioned there work for me.

I ssh'ed into CircleCI and verified that my test script (using nyc) is producing coverage/clover.xml, which seems to have valid contents (I can post, if that's helpful).

I tried invoking cc-test-reporter many different ways from the ssh shell in CircleCI, to no effect. Inspecting the response from cc-test-reporter, I can see that it has identified the correct directory where my clover.xml is stored, but it is still giving me this error:

$~/repo/coverage ../cc-test-reporter format-coverage -t clover
Error: could not find coverage info for source files
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
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/circleci/repo/coverage")

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

Here are the relevant parts of my package.json and .circleci/config.yml. I tried many configurations. In this one, I'm cd'ing into the coverage folder because cc-test-reporter seems to be ignoring the --prefix argument.

.circleci/config.yml

 - run:
          name: Run Tests and Code Coverage
          command: |
            ./cc-test-reporter before-build
            yarn lint && yarn test
            cd coverage
            ../cc-test-reporter after-build -t clover --exit-code $?

package.json

{
  "test": "cross-env NODE_ENV=test nyc mocha",
  "nyc": {
    "require": [
      "babel-register"
    ],
    "reporter": [
      "clover", "html", "text"
    ],
    "sourceMap": false,
    "instrument": false
  }
}
wbhob commented 6 years ago

I, too, need help setting up CC test coverage with Travis and NodeJS.

davehenton commented 6 years ago

Hey @aneilbaboo and @wbhob. To help troubleshoot, could you each open up a support ticket here. In the ticket, can you please include:

If you're running your tests in single builds, use after-build --debug.

For tests run in parallel, please use both format-coverage --debug and upload-coverage --debug.

Sorry about the extra work here, but this will help expedite the troubleshooting process. I'll be standing by to help further. Thanks!

wbhob commented 6 years ago

I just saw this but sent a support request. Can you just shoot me an empty response so I can offer the information I missed? Thanks!

aneilbaboo commented 6 years ago

Thanks, @davehenton - I just created a ticket.

efueger commented 6 years ago

Hi @aneilbaboo - just opened a PR with a solution that should work.

aneilbaboo commented 6 years ago

@efueger - Moving the cc_test_reporter_id to the docker step was the key. I had tried the other changes before that, but that was the missing piece. Thanks so much.