Skip to content

Configuring coveralls with CircleCI and parallelism

Ryan Romanchuk edited this page Mar 19, 2019 · 5 revisions

Using Coveralls with CircleCI 2.0

Warning: This will require the proposed changes https://github.com/Coveralls-Community/coveralls-ruby/pull/24/files

Setup your required environment variables

COVERALLS_PARALLEL=true
COVERALLS_REPO_TOKEN=
COVERALLS_SERVICE_NAME=CIRCLECI

Getting coveralls to work with workflows and parallel builds.

version: 2.1

# This is entirely unique to your app, but leaving an example for completeness
executors:
  my-simple-executor:
    docker:
      - image: circleci/ruby:2.6.1-node
  my-executor:
    environment:
      FOO: bar
      RAILS_ENV: test
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.6.1-node
      - image: circleci/postgres:10.6-alpine
      - image: redis:5.0.0
    working_directory: ~/my-app

jobs:
  test:
    parallelism: 2
    executor: my-executor
    steps:
      # [... truncated]
      - run:
          name: Run tests
          command: |
            TEST_FILES="$(circleci tests glob 'spec/**/*_spec.rb' | circleci tests split --split-by=timings --total=2)"
            echo $TEST_FILES
            mkdir /tmp/test-results
            bundle exec rspec --format progress \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            -- ${TEST_FILES}

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results
      - store_artifacts:
          path: /coverage
          destination: coverage
  notify_coveralls:
    executor: my-simple-executor
    steps:
      - run:
          name: Notify coveralls
          command: |
            curl -k https://coveralls.io/webhook?repo_token=${COVERALLS_REPO_TOKEN} -d "payload[build_num]=${CIRCLE_WORKFLOW_ID}&payload[status]=done"

workflows:
  version: 2
  test:
    jobs:
      - test
      - notify_coveralls

References:

Clone this wiki locally