bilal
bilal

Reputation: 219

CircleCI 2.0: could not find coverage file

i am migrating from circleci version 1 to 2 and facing a problem. when i try to do Code Climate coverage, split for parallel nodes it gives me error saying:

#!/bin/bash -eo pipefail
./cc-test-reporter format-coverage -t simplecov --output "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"

ERRO[0000] could not find coverage file 
could not find any files in search paths for simplecov. search paths 
were: , coverage/.resultset.json 
Error: could not find any files in search paths for simplecov. search 
paths were: , coverage/.resultset.json
Usage:
  cc-test-reporter format-coverage [coverage file] [flags]

i dont understand path thing: where the /coverage path coming from. do i have to create a directory inside my working_directory ? i tried to run - run: ./cc-test-reporter before-build also but things seems to not be working: my code is :

- run: ./cc-test-reporter format-coverage -t simplecov --output "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"

- run: aws s3 sync coverage/ "s3://myapp/coverage/$CIRCLE_BUILD_NUM"

how to i correctly format it according to needs?

my parallelism is 2

version: 2
jobs:
  build:
   environment:
   working_directory: ~/circleci-goget
   docker:


  - image: circleci/ruby:2.1.10-node-browsers
    environment:
      CC_TEST_REPORTER_ID: XXXX
      PGHOST: 127.0.0.1
      RAILS_ENV: test
      TEST_REPORT_PATH: "test/reports"


  - image: circleci/postgres:9.6.2-alpine
    environment:
      POSTGRES_USER: circleci
      POSTGRES_DB: circleci-goget-test
      POSTGRES_PASSWORD: ""

  - image: circleci/redis:3.2
  - image: circleci/rabbitmq:3.6.6

parallelism: 1
steps:
  - checkout

  - run: echo "started running"

  # Restore bundle cache
  - type: cache-restore
    key: goget-bundle-{{ checksum "Gemfile.lock" }}


  - run: echo "going to bundle"

  - run: sudo gem install bundler

  # Install gem dependencies
  - run: bundle install --path vendor/bundle

  # Install Javascript dependencies
  # - run: bin/yarn install

  # Store bundle cache
  - type: cache-save
    key: goget-bundle-{{ checksum "Gemfile.lock" }}
    paths:
      - vendor/bundle

  - run: echo "creating db"

  # Database setup
  - run:
      name: Database Setup
      command: |
        bundle exec rake db:create
        bundle exec rake db:migrate
        bundle exec rake db:schema:load

  - run: echo "test till schema load"

  # Code Climate setup
  - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
  - run: chmod +x ./cc-test-reporter
  # - run: sudo apt-get -y -qq install awscli

  - run:
      name: Install AWS CLI
      command: |
        sudo apt-get update
        sudo apt-get install python-pip python-dev jq


        sudo pip install awscli


  - run: aws s3 rm s3://goget/coverage/$CIRCLE_PREVIOUS_BUILD_NUM --recursive

  # Run Ruby unit tests and app integration tests in parallel
  - type: shell
    command: |
      bundle exec rake test $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings --timings-type=classname)


  - run: ./cc-test-reporter before-build

  Code Climate coverage, split for parallel nodes
  - run: ./cc-test-reporter format-coverage -t simplecov --output "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
  - run: aws s3 sync coverage/ "s3://myapp/coverage/$CIRCLE_BUILD_NUM"

  - run: echo "code climate"

  # Run security scan
  # - run: bundle exec brakeman

  # Save artifacts
  - type: store_test_results
    path: test

  # `deploy` runs only on node 0 after parallel steps have finished
  # Upload results from all parallel nodes to Code Climate
  - deploy: 
      command: |
        aws s3 sync "s3://goget/coverage/$CIRCLE_BUILD_NUM" coverage/ 
        ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --input -

Upvotes: 1

Views: 1866

Answers (1)

Pablo Carbajal
Pablo Carbajal

Reputation: 103

I had the same error until I added the gem simplecov to my project.

Here is the repo with installation instructions: https://github.com/colszowka/simplecov

Upvotes: 0

Related Questions