rspec_chunked 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 269d7677063d252032ed8e26c4d0b469417ba5e2bab2cc868edc79176f8201f9
4
- data.tar.gz: 2ee7a9c1e3b51809ac8f7e3312bf806acbebc049be0d21f80686636aa99a8c6b
3
+ metadata.gz: 88f625eba156da0e0603f45ad62a72aba2a1bb9c42c390cc25f0e2873e8491e9
4
+ data.tar.gz: 437165f8a02ebc862ea7553f0b9345f3a325ac9c93134a15c52ddde227a2662b
5
5
  SHA512:
6
- metadata.gz: 6a7d86038a73855d043f69a134aa11e7a5aebcff4ad88d4dd5cc39d8d269bef8dd64a9c1a85bccd7e765ed522aa10056400c0d5e0f362d6631093c302517ae6d
7
- data.tar.gz: 8103b9cc56f2fb35674789dfae0d44c41553c22f511a44cbdd9ae325ab099143be811edcc99534ad9b674ffca179882c64bbe8bcf8893b2cd1cb232ca5b2fa57
6
+ metadata.gz: ed38c5c6cdd3cad36f5d29123626303e62557acc7ae60761f5a484d481230cd54e1500dd01dcb47dbda41581216deb66fb9f5b3809926d50a13c74aa1ea6e496
7
+ data.tar.gz: 3885e21242709317eaa7df72aad821330ee1025a6c9768a98e1b524a824358d2c8f8ba67285b0411266d8ae7aecd5c1628ac154acb0ff3a81304f1e17cc88c4b
data/README.md CHANGED
@@ -25,9 +25,18 @@ If ordering is not enough, permits to balance manually by moving x percentage of
25
25
  Balance tests by moving 15% tests files from group 1 into group 2 and moving 10% tests files from group 4 into group 3
26
26
 
27
27
  ## Usage
28
- ` CI_JOBS=3 CI_JOB=1 rake rspec_chunked `
28
+ - Basic initialization
29
+ ` CI_JOBS=3 CI_JOB=1 rake rspec_chunked`
30
+ - Custom initialization
31
+ ` CI_JOBS=3 CI_JOB=1 CI_CMD="bundle exec rspec ..." rake rspec_chunked`
29
32
  - `CI_JOBS`: quantity of groups/workers to be split
30
33
  - `CI_JOB`: current group/worker to be executed, limit: 1 until CI_JOBS
34
+ - `CI_CMD`: Custom rspec command
35
+
36
+ ### Coverage merge reports (when using [simplecov](https://github.com/simplecov-ruby/simplecov#merging-test-runs-under-different-execution-environments))
37
+ This task will merge all coverage reports
38
+ `rake rspec_chunked:merge_reports`
39
+
31
40
 
32
41
  ### Github workflow result
33
42
  - Before:
@@ -5,12 +5,13 @@ module RspecChunked
5
5
  class << self
6
6
  attr_accessor :balance_settings
7
7
  end
8
- attr_accessor :qty_groups, :job_number, :balance_settings
8
+ attr_accessor :qty_groups, :job_number, :balance_settings, :cmd
9
9
 
10
- def initialize(qty_groups, job_number)
10
+ def initialize(qty_groups, job_number, cmd: '')
11
11
  @qty_groups = qty_groups
12
12
  @job_number = job_number - 1
13
13
  @balance_settings = self.class.balance_settings || {}
14
+ @cmd = cmd.empty? ? 'bundle exec rspec' : cmd
14
15
  end
15
16
 
16
17
  def run
@@ -18,7 +19,7 @@ module RspecChunked
18
19
  tests = balanced_tests[job_number]
19
20
  qty = balanced_tests.flatten.count
20
21
  Kernel.puts "**** running #{tests.count}/#{qty} tests (group number: #{job_number + 1})"
21
- Kernel.exec "bundle exec rspec #{tests.join(' ')}"
22
+ Kernel.exec "#{cmd} #{tests.join(' ')}"
22
23
  end
23
24
 
24
25
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RspecChunked
4
- VERSION = '0.3'
4
+ VERSION = '0.4'
5
5
  end
@@ -4,7 +4,20 @@ desc 'Run chunked rspec tests on specific qty, sample: CI_JOBS=3 CI_JOB=1 rake r
4
4
  task rspec_chunked: :environment do
5
5
  qty_jobs = (ENV['CI_JOBS'] || 3).to_i
6
6
  job_number = (ENV['CI_JOB'] || 1).to_i
7
-
8
- service = RspecChunked::ChunkedTests.new(qty_jobs, job_number)
7
+ service = RspecChunked::ChunkedTests.new(qty_jobs, job_number, cmd: ENV['CI_CMD'])
9
8
  service.run
9
+ copy_coverage
10
+ end
11
+
12
+ def copy_coverage
13
+ path = 'coverage/.resultset.json'
14
+ FileUtils.cp path, "coverage/.resultset-#{job_number}.json" if File.exist?(path)
15
+ end
16
+
17
+ namespace :rspec_chunked do
18
+ desc 'Collates all result sets generated by the different test runners'
19
+ task :merge_reports do
20
+ require 'simplecov'
21
+ SimpleCov.collate Dir['coverage/.resultset-*']
22
+ end
10
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_chunked
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - owen2345
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler