Code Coverage for Code Climate with Node/Javascript on Lerna monorepository

code-climate
javascript
nodejs
code-coverage

#1

I’m having an issue getting code coverage to work on my configuration. Here is the code that executes and while bash should continue when there is an error it’s not. Since I have a Lerna monorepository I eseentially iterate all packages/* and look for /coverage folder. If it’s not there it should skip it and gracefully continue rather than fail like it happening now.

Any assistance would be greatly appreciated.

Configuration part

 - run:
          name: Setup Code Climate test-reporter
          command: |
            mkdir -p tmp/
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
            chmod +x ./tmp/cc-test-reporter
      - run:
          name: Code Coverage
          command: |
            ./tmp/cc-test-reporter before-build
            for f in packages/*; do
              if [ -d "$f" ]; then
                 echo $f
                ./tmp/cc-test-reporter format-coverage -t lcov -o tmp/coverage.${f//\//-}.json $f/coverage/lcov.info
              fi
            done;
            ./tmp/cc-test-reporter sum-coverage -o tmp/coverage.total.json tmp/coverage.*.json
            ./tmp/cc-test-reporter upload-coverage -i tmp/coverage.total.json
            #./tmp/cc-test-reporter after-build --coverage-input-type lcov --exit-code $?

Error

packages/fast-animation
packages/fast-browser-extensions
ERRO[0000] could not find coverage file packages/fast-browser-extensions/coverage/lcov.info
could not find any files in search paths for lcov. search paths were: packages/fast-browser-extensions/coverage/lcov.info, coverage/lcov.info 
Error: could not find any files in search paths for lcov. search paths were: packages/fast-browser-extensions/coverage/lcov.info, coverage/lcov.info
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]
  -o, --output string       output path (default "coverage/codeclimate.json")
  -p, --prefix string       the root directory where the coverage analysis was performed (default "/home/circleci/fast-dna")

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

Exited with code 255

#2

Issue has been resolved using new bash statement

for f in packages/*; do
  if [ -d "$f" ]; then
    echo $f
    if [ -d "$f/coverage" ]; then
      ./coverage/cc-test-reporter format-coverage -t lcov -o coverage/coverage.${f//\//-}.json $f/coverage/lcov.info
    fi
  fi
done;

#3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.