Skip to content

Commit

Permalink
update(docs simplecov): add an example of using simplecov with Minite…
Browse files Browse the repository at this point in the history
…st in Queue Mode after the knapsack_pro gem 6.0.4 release

Related: KnapsackPro/knapsack_pro-ruby#257
  • Loading branch information
ArturT committed Jun 5, 2024
1 parent c44c186 commit 50f6c19
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docusaurus/docs/ruby/simplecov.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This is needed only if you are using Knapsack Pro in [Queue Mode](../overview/in

:::

## RSpec

Apply the following patch:

```ruby
Expand All @@ -28,3 +30,41 @@ end
This is needed to avoid conflicts between code coverage reports generated by parallel CI nodes.

If the local drive is common between parallel nodes on your CI, `simplecov` will generate a single report at `coverage/index.html` with merged data. Otherwise, you can refer to [How to merge CodeClimate reports for parallel jobs (CI nodes)](https://docs.knapsackpro.com/2019/how-to-merge-codeclimate-reports-for-parallel-jobs-ci-nodes) or [How to merge SimpleCov results with parallel Rails specs on Semaphore CI](https://docs.knapsackpro.com/2020/how-to-merge-simplecov-results-with-parallel-rails-specs).

## Minitest

Apply the following patch:

```ruby
# test_helper.rb
require 'simplecov'

SimpleCov.start

KnapsackPro::Hooks::Queue.before_queue do |queue_id|
SimpleCov.command_name("minitest_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
end

KnapsackPro::Hooks::Queue.after_queue do
SimpleCov.result.format!
end
```

This is needed to avoid conflicts between code coverage reports generated by parallel CI nodes.

<details>
<summary>For legacy versions of `knapsack_pro` older than 6.0.4, please click here.</summary>

```ruby
# test_helper.rb
require 'simplecov'

SimpleCov.start

KnapsackPro::Hooks::Queue.before_queue do |queue_id|
SimpleCov.command_name("minitest_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
end
```

</details>

0 comments on commit 50f6c19

Please sign in to comment.