How to combine multiple simplecov directories inside CircleCI when running parallel_test?

I have a rails application that runs parallel_test using rspec inside circleci

Looking around the Internet, I added this to my most beginner spec_helper.rb file:

 if ENV['COVERAGE'] require 'simplecov' # on circleci change the output dir to the artifacts if ENV['CIRCLE_ARTIFACTS'] dir = File.join("..", "..", "..", ENV['CIRCLE_ARTIFACTS'], "coverage") SimpleCov.coverage_dir(dir) SimpleCov.merge_timeout 3600 SimpleCov.command_name "rspec_#{Process.pid.to_s}#{ENV['TEST_ENV_NUMBER']}" end SimpleCov.start 'rails' end 

The problem is that as a result, I get different folders, one for each instance of circleci:

enter image description here

What am I doing wrong?

+6
source share
3 answers

I work at CircleCI. Unfortunately, this will not work - we do not collect catalogs of artifacts from different collections until all the assemblies are over, so the tools that try to combine them together during the assembly will not work. We talked about adding features to this, but it is not currently on our roadmap, sorry!

+6
source

For those who are still looking for a solution to this problem, there is a new possibility: using ssh between containers for manual synchronization and consolidation of reports, see docs . However, this is not a turnkey solution; you will have to write the necessary scripts yourself.

Otherwise, you can also use the external coverage service (we use coveralls codecov ) together with the CircleCI webhook notification .

Edit

You can add such a website to your .yml circle (thanks Ian): notify: webhooks: - url: https://coveralls.io/webhook?repo_token=(your repo token)

+3
source

To spell out what Frank Eckert said, Coveralls can do this . However, this documentation is slightly disabled.

Add Gemfile to You:

 gem 'coveralls', require: false 

Add to your spec/spec_helper.rb :

 if ENV['CIRCLECI'] # If running in CircleCI, run with Coveralls too require 'coveralls' Coveralls.wear!('rails') end 

Add to circle.yml (not coveralls.yml , as stated in the article):

 notify: webhooks: - url: https://coveralls.io/webhook?repo_token=your-repo-token 

Add to (or create) .coveralls.yml in the root folder and add:

 repo_token: your-repo-token 

Finally, go into the CircleCI project configuration and add the environment variable: COVERALLS_PARALLEL=true

This worked for us, however we find errors in the correct line count ( reported by Coveralls ), but it works and gives us a good idea of ​​our scope changes over time.

+1
source

Source: https://habr.com/ru/post/977724/


All Articles