CircleCI 2.0:找不到覆盖率文件

时间:2018-08-29 03:32:01

标签: ruby-on-rails circleci circleci-2.0

我正在从Circleci版本1迁移到2,并遇到问题。当我尝试进行代码气候覆盖时,为并行节点拆分会给我错误提示:

#!/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]

我不了解路径问题:/coverage路径来自何处。 我必须在我的working_directory中创建一个目录吗? 我也尝试运行- run: ./cc-test-reporter before-build,但似乎无法正常工作: 我的代码是:

- 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"

如何根据需要正确格式化?

我的parallelism2

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 -

1 个答案:

答案 0 :(得分:0)

在将宝石simplecov添加到项目中之前,我遇到了同样的错误。

以下是带有安装说明的仓库:https://github.com/colszowka/simplecov