rspec_chunked 0.3 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/lib/rspec_chunked/chunked_tests.rb +4 -3
- data/lib/rspec_chunked/railtie.rb +5 -1
- data/lib/rspec_chunked/version.rb +1 -1
- data/lib/tasks/rspec_chunked_tasks.rake +23 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc398c99a740b44f4503b351d0161a93db59a2ee50a87ce992d7863faf00278c
|
4
|
+
data.tar.gz: ac9a9e3cd8bd6dd05d4d20c191e8d59efba116a37be3f0fe8948e4267e11542d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533b28d0ddf8b52d6502527889364fa80537fcfb1e0d5aec1406030b408cff5f98cdf3517b8795f410969cef87c1e509137a6f33a28869bbded20341f4a660e8
|
7
|
+
data.tar.gz: 5f40aa1988ce2b4350ffcc7e9e065617df4533bf37ad101ff8efab95944a53a6796d807463459ef2ac132dcf0069eb6f63bb99e3e91bdc906bda4162a3ea3f7d
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ If ordering is not enough, permits to balance manually by moving x percentage of
|
|
15
15
|
|
16
16
|
- Add manual balance
|
17
17
|
```ruby
|
18
|
-
# config/
|
18
|
+
# config/rspec_chunked.rb
|
19
19
|
if defined?(RspecChunked::ChunkedTests)
|
20
20
|
data = { 1 => { to: 2, percentage: 15 },
|
21
21
|
4 => { to: 3, percentage: 10 } }
|
@@ -25,9 +25,17 @@ 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
|
-
|
29
|
-
|
30
|
-
-
|
28
|
+
- Basic initialization
|
29
|
+
` CI_JOBS=1/3 rake rspec_chunked`
|
30
|
+
- Custom initialization
|
31
|
+
` CI_JOBS=1/3 CI_CMD="bundle exec rspec ..." rake rspec_chunked`
|
32
|
+
- `CI_JOBS`: Current job number / quantity of groups/jobs to be split
|
33
|
+
- `CI_CMD`: Custom rspec command
|
34
|
+
|
35
|
+
### Coverage merge reports (when using [simplecov](https://github.com/simplecov-ruby/simplecov#merging-test-runs-under-different-execution-environments))
|
36
|
+
This task will merge all coverage reports
|
37
|
+
`rake rspec_chunked:merge_reports`
|
38
|
+
|
31
39
|
|
32
40
|
### Github workflow result
|
33
41
|
- 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: nil)
|
11
11
|
@qty_groups = qty_groups
|
12
12
|
@job_number = job_number - 1
|
13
13
|
@balance_settings = self.class.balance_settings || {}
|
14
|
+
@cmd = cmd || 'bundle exec rspec'
|
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.
|
22
|
+
Kernel.abort('failed running command') unless Kernel.system "#{cmd} #{tests.join(' ')}"
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rspec_chunked'
|
3
4
|
require 'rails'
|
5
|
+
|
4
6
|
module RspecChunked
|
5
|
-
class Railtie <
|
7
|
+
class Railtie < Rails::Railtie
|
8
|
+
railtie_name :my_gem
|
9
|
+
|
6
10
|
rake_tasks do
|
7
11
|
load 'tasks/rspec_chunked_tasks.rake'
|
8
12
|
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
desc 'Run chunked rspec tests on specific qty, sample: CI_JOBS=3 CI_JOB=1 rake rspec_chunked'
|
4
|
-
task rspec_chunked
|
5
|
-
qty_jobs = (ENV['CI_JOBS'] || 3).
|
6
|
-
|
7
|
-
|
8
|
-
service = RspecChunked::ChunkedTests.new(qty_jobs, job_number)
|
4
|
+
task :rspec_chunked do
|
5
|
+
job_number, qty_jobs = (ENV['CI_JOBS'] || '1/3').split('/')
|
6
|
+
load_config
|
7
|
+
service = RspecChunked::ChunkedTests.new(qty_jobs.to_i, job_number.to_i, cmd: ENV['CI_CMD'])
|
9
8
|
service.run
|
9
|
+
copy_coverage(job_number)
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_config
|
13
|
+
config_file = File.join(Dir.pwd, 'config', 'rspec_chunked.rb')
|
14
|
+
load config_file if File.exist?(config_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def copy_coverage(job_number)
|
18
|
+
path = 'coverage/.resultset.json'
|
19
|
+
FileUtils.cp path, "coverage/.resultset-#{job_number}.json" if File.exist?(path)
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :rspec_chunked do
|
23
|
+
desc 'Collates all result sets generated by the different test runners'
|
24
|
+
task :merge_reports do
|
25
|
+
require 'simplecov'
|
26
|
+
SimpleCov.collate Dir['coverage/.resultset-*']
|
27
|
+
end
|
10
28
|
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.
|
4
|
+
version: '0.5'
|
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-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|