knapsack_pro 3.8.0 → 7.0.0

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.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +377 -23
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/pull_request_template.md +22 -0
  5. data/.gitignore +4 -0
  6. data/CHANGELOG.md +325 -1
  7. data/Gemfile +9 -0
  8. data/README.md +3 -10
  9. data/bin/test +15 -0
  10. data/knapsack_pro.gemspec +7 -6
  11. data/lib/knapsack_pro/adapters/base_adapter.rb +17 -2
  12. data/lib/knapsack_pro/adapters/cucumber_adapter.rb +3 -3
  13. data/lib/knapsack_pro/adapters/minitest_adapter.rb +2 -0
  14. data/lib/knapsack_pro/adapters/rspec_adapter.rb +88 -49
  15. data/lib/knapsack_pro/adapters/spinach_adapter.rb +2 -0
  16. data/lib/knapsack_pro/adapters/test_unit_adapter.rb +2 -0
  17. data/lib/knapsack_pro/allocator.rb +2 -0
  18. data/lib/knapsack_pro/allocator_builder.rb +2 -0
  19. data/lib/knapsack_pro/base_allocator_builder.rb +8 -25
  20. data/lib/knapsack_pro/build_distribution_fetcher.rb +2 -0
  21. data/lib/knapsack_pro/client/api/action.rb +2 -0
  22. data/lib/knapsack_pro/client/api/v1/base.rb +2 -0
  23. data/lib/knapsack_pro/client/api/v1/build_distributions.rb +5 -0
  24. data/lib/knapsack_pro/client/api/v1/build_subsets.rb +2 -0
  25. data/lib/knapsack_pro/client/api/v1/queues.rb +6 -1
  26. data/lib/knapsack_pro/client/connection.rb +5 -6
  27. data/lib/knapsack_pro/config/ci/app_veyor.rb +18 -0
  28. data/lib/knapsack_pro/config/ci/base.rb +27 -0
  29. data/lib/knapsack_pro/config/ci/buildkite.rb +18 -0
  30. data/lib/knapsack_pro/config/ci/circle.rb +18 -0
  31. data/lib/knapsack_pro/config/ci/cirrus_ci.rb +18 -0
  32. data/lib/knapsack_pro/config/ci/codefresh.rb +18 -0
  33. data/lib/knapsack_pro/config/ci/codeship.rb +18 -0
  34. data/lib/knapsack_pro/config/ci/github_actions.rb +26 -0
  35. data/lib/knapsack_pro/config/ci/gitlab_ci.rb +20 -1
  36. data/lib/knapsack_pro/config/ci/heroku.rb +18 -0
  37. data/lib/knapsack_pro/config/ci/semaphore.rb +16 -0
  38. data/lib/knapsack_pro/config/ci/semaphore2.rb +19 -0
  39. data/lib/knapsack_pro/config/ci/travis.rb +18 -0
  40. data/lib/knapsack_pro/config/env.rb +46 -22
  41. data/lib/knapsack_pro/config/env_generator.rb +2 -0
  42. data/lib/knapsack_pro/config/temp_files.rb +8 -4
  43. data/lib/knapsack_pro/crypto/branch_encryptor.rb +2 -0
  44. data/lib/knapsack_pro/crypto/decryptor.rb +2 -0
  45. data/lib/knapsack_pro/crypto/digestor.rb +2 -0
  46. data/lib/knapsack_pro/crypto/encryptor.rb +2 -0
  47. data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
  48. data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +2 -0
  49. data/lib/knapsack_pro/formatters/time_tracker.rb +152 -0
  50. data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +20 -0
  51. data/lib/knapsack_pro/hooks/queue.rb +2 -0
  52. data/lib/knapsack_pro/logger_wrapper.rb +2 -0
  53. data/lib/knapsack_pro/mask_string.rb +9 -0
  54. data/lib/knapsack_pro/presenter.rb +6 -3
  55. data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
  56. data/lib/knapsack_pro/queue_allocator.rb +2 -0
  57. data/lib/knapsack_pro/queue_allocator_builder.rb +2 -0
  58. data/lib/knapsack_pro/railtie.rb +2 -0
  59. data/lib/knapsack_pro/report.rb +15 -9
  60. data/lib/knapsack_pro/repository_adapter_initiator.rb +2 -0
  61. data/lib/knapsack_pro/repository_adapters/base_adapter.rb +2 -0
  62. data/lib/knapsack_pro/repository_adapters/env_adapter.rb +2 -0
  63. data/lib/knapsack_pro/repository_adapters/git_adapter.rb +50 -0
  64. data/lib/knapsack_pro/runners/base_runner.rb +2 -0
  65. data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -0
  66. data/lib/knapsack_pro/runners/minitest_runner.rb +2 -0
  67. data/lib/knapsack_pro/runners/queue/base_runner.rb +29 -0
  68. data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +9 -6
  69. data/lib/knapsack_pro/runners/queue/minitest_runner.rb +13 -6
  70. data/lib/knapsack_pro/runners/queue/rspec_runner.rb +128 -135
  71. data/lib/knapsack_pro/runners/rspec_runner.rb +22 -3
  72. data/lib/knapsack_pro/runners/spinach_runner.rb +2 -0
  73. data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -0
  74. data/lib/knapsack_pro/slow_test_file_determiner.rb +2 -0
  75. data/lib/knapsack_pro/slow_test_file_finder.rb +2 -0
  76. data/lib/knapsack_pro/task_loader.rb +2 -0
  77. data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +2 -0
  78. data/lib/knapsack_pro/test_case_mergers/base_merger.rb +2 -0
  79. data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +2 -0
  80. data/lib/knapsack_pro/test_file_cleaner.rb +2 -0
  81. data/lib/knapsack_pro/test_file_finder.rb +2 -0
  82. data/lib/knapsack_pro/test_file_pattern.rb +2 -0
  83. data/lib/knapsack_pro/test_file_presenter.rb +2 -0
  84. data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +2 -0
  85. data/lib/knapsack_pro/test_flat_distributor.rb +2 -0
  86. data/lib/knapsack_pro/tracker.rb +3 -3
  87. data/lib/knapsack_pro/urls.rb +4 -0
  88. data/lib/knapsack_pro/utils.rb +2 -0
  89. data/lib/knapsack_pro/version.rb +3 -1
  90. data/lib/knapsack_pro.rb +5 -3
  91. data/lib/tasks/cucumber.rake +2 -0
  92. data/lib/tasks/encrypted_branch_names.rake +2 -0
  93. data/lib/tasks/encrypted_test_file_names.rake +2 -0
  94. data/lib/tasks/minitest.rake +2 -0
  95. data/lib/tasks/queue/cucumber.rake +13 -0
  96. data/lib/tasks/queue/minitest.rake +13 -0
  97. data/lib/tasks/queue/rspec.rake +13 -0
  98. data/lib/tasks/rspec.rake +5 -0
  99. data/lib/tasks/salt.rake +2 -0
  100. data/lib/tasks/spinach.rake +2 -0
  101. data/lib/tasks/test_unit.rake +2 -0
  102. data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
  103. data/spec/integration/runners/queue/rspec_runner.rb +80 -0
  104. data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
  105. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +30 -11
  106. data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
  107. data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +146 -174
  108. data/spec/knapsack_pro/base_allocator_builder_spec.rb +22 -48
  109. data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +19 -27
  110. data/spec/knapsack_pro/client/api/v1/queues_spec.rb +23 -43
  111. data/spec/knapsack_pro/client/connection_spec.rb +59 -7
  112. data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +22 -8
  113. data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
  114. data/spec/knapsack_pro/config/ci/buildkite_spec.rb +51 -16
  115. data/spec/knapsack_pro/config/ci/circle_spec.rb +48 -13
  116. data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +12 -12
  117. data/spec/knapsack_pro/config/ci/codefresh_spec.rb +21 -6
  118. data/spec/knapsack_pro/config/ci/codeship_spec.rb +20 -6
  119. data/spec/knapsack_pro/config/ci/github_actions_spec.rb +37 -10
  120. data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +48 -13
  121. data/spec/knapsack_pro/config/ci/heroku_spec.rb +12 -12
  122. data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +11 -11
  123. data/spec/knapsack_pro/config/ci/semaphore_spec.rb +12 -12
  124. data/spec/knapsack_pro/config/ci/travis_spec.rb +8 -8
  125. data/spec/knapsack_pro/config/env_spec.rb +204 -124
  126. data/spec/knapsack_pro/formatters/time_tracker_specs.rb +424 -0
  127. data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
  128. data/spec/knapsack_pro/presenter_spec.rb +1 -1
  129. data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
  130. data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +72 -0
  131. data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +18 -16
  132. data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +17 -14
  133. data/spec/knapsack_pro/runners/rspec_runner_spec.rb +40 -23
  134. data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
  135. data/spec/knapsack_pro/tracker_spec.rb +0 -4
  136. data/spec/knapsack_pro_spec.rb +3 -3
  137. data/spec/spec_helper.rb +0 -1
  138. metadata +26 -23
  139. data/lib/knapsack_pro/config/ci/snap_ci.rb +0 -35
  140. data/lib/knapsack_pro/config/ci/solano_ci.rb +0 -32
  141. data/lib/knapsack_pro/extensions/time.rb +0 -7
  142. data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -56
  143. data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -112
  144. data/spec/knapsack_pro/config/ci/snap_ci_spec.rb +0 -104
  145. data/spec/knapsack_pro/config/ci/solano_ci_spec.rb +0 -73
  146. data/spec/knapsack_pro/extensions/time_spec.rb +0 -5
  147. data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -342
@@ -31,4 +31,76 @@ describe KnapsackPro::RepositoryAdapters::GitAdapter do
31
31
  it { expect(subject.include?('master')).to be true }
32
32
  it { expect(subject.include?(circle_branch)).to be true } if ENV['CIRCLECI']
33
33
  end
34
+
35
+ describe '#build_author' do
36
+ it "returns the masked build author" do
37
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_return(
38
+ "John Doe <john.doe@example.com>" + "\n"
39
+ )
40
+
41
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
42
+
43
+ expect(subject.build_author).to eq 'Jo** Do* <jo**.do*@ex*****.co*>'
44
+ end
45
+
46
+ context "when the command raises an exception" do
47
+ it "returns the no-git author" do
48
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_raise(Exception)
49
+
50
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
51
+
52
+ expect(subject.build_author).to eq "no git <no.git@example.com>"
53
+ end
54
+ end
55
+
56
+ context "when the command returns an empty string" do
57
+ it "returns the no-git author" do
58
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_build_author).and_return("")
59
+
60
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
61
+
62
+ expect(subject.build_author).to eq "no git <no.git@example.com>"
63
+ end
64
+ end
65
+ end
66
+
67
+ describe '#commit_authors' do
68
+ it "returns the masked commit authors" do
69
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_return([
70
+ " 5\t3v0k4 <riccardo@example.com>\n",
71
+ " 10\tArtur Nowak <artur@example.com>\n",
72
+ " 2\tRiccardo <riccardo@example.com>\n",
73
+ " 3 \tshadre <shadi@example.com>\n",
74
+ ].join(""))
75
+
76
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
77
+
78
+ expect(subject.commit_authors).to eq([
79
+ { commits: 5, author: "3v0*4 <ri******@ex*****.co*>" },
80
+ { commits: 10, author: "Ar*** No*** <ar***@ex*****.co*>" },
81
+ { commits: 2, author: "Ri****** <ri******@ex*****.co*>" },
82
+ { commits: 3, author: "sh**** <sh***@ex*****.co*>" },
83
+ ])
84
+ end
85
+
86
+ context "when the authors command raises an exception" do
87
+ it "returns []" do
88
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_raise(Exception)
89
+
90
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
91
+
92
+ expect(subject.commit_authors).to eq []
93
+ end
94
+ end
95
+
96
+ context "when the authors command returns an empty string" do
97
+ it "returns []" do
98
+ allow_any_instance_of(KnapsackPro::RepositoryAdapters::GitAdapter).to receive(:git_commit_authors).and_return("")
99
+
100
+ subject = KnapsackPro::RepositoryAdapters::GitAdapter.new
101
+
102
+ expect(subject.commit_authors).to eq []
103
+ end
104
+ end
105
+ end
34
106
  end
@@ -24,7 +24,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
24
24
  expect(described_class).to receive(:new).with(KnapsackPro::Adapters::CucumberAdapter).and_return(runner)
25
25
  end
26
26
 
27
- context 'when args provided' do
27
+ context 'when args are provided' do
28
28
  let(:args) { '--retry 5 --no-strict-flaky' }
29
29
 
30
30
  it do
@@ -39,8 +39,9 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
39
39
  can_initialize_queue: true,
40
40
  args: args,
41
41
  exitstatus: 0,
42
- all_test_file_paths: [],
42
+ node_test_file_paths: [],
43
43
  }
44
+ expect(described_class).to receive(:handle_signal!)
44
45
  expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
45
46
 
46
47
  expect(Kernel).to receive(:exit).with(expected_exitstatus)
@@ -49,7 +50,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
49
50
  end
50
51
  end
51
52
 
52
- context 'when args not provided' do
53
+ context 'when args are not provided' do
53
54
  let(:args) { nil }
54
55
 
55
56
  it do
@@ -64,8 +65,9 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
64
65
  can_initialize_queue: true,
65
66
  args: nil,
66
67
  exitstatus: 0,
67
- all_test_file_paths: [],
68
+ node_test_file_paths: [],
68
69
  }
70
+ expect(described_class).to receive(:handle_signal!)
69
71
  expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
70
72
 
71
73
  expect(Kernel).to receive(:exit).with(expected_exitstatus)
@@ -83,21 +85,21 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
83
85
  let(:can_initialize_queue) { double(:can_initialize_queue) }
84
86
  let(:args) { '--retry 5 --no-strict-flaky' }
85
87
  let(:exitstatus) { 0 }
86
- let(:all_test_file_paths) { [] }
88
+ let(:node_test_file_paths) { [] }
87
89
  let(:accumulator) do
88
90
  {
89
91
  runner: runner,
90
92
  can_initialize_queue: can_initialize_queue,
91
93
  args: args,
92
94
  exitstatus: exitstatus,
93
- all_test_file_paths: all_test_file_paths,
95
+ node_test_file_paths: node_test_file_paths,
94
96
  }
95
97
  end
96
98
 
97
99
  subject { described_class.run_tests(accumulator) }
98
100
 
99
101
  before do
100
- expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: all_test_file_paths).and_return(test_file_paths)
102
+ expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: node_test_file_paths).and_return(test_file_paths)
101
103
  end
102
104
 
103
105
  context 'when test files exist' do
@@ -127,7 +129,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
127
129
  allow(child_status).to receive(:exitstatus).and_return(exitstatus)
128
130
  end
129
131
 
130
- context 'when system process finished its work (exited)' do
132
+ context 'when system process finished (exited)' do
131
133
  let(:process_exited) { true }
132
134
 
133
135
  context 'when tests are passing' do
@@ -140,7 +142,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
140
142
  can_initialize_queue: false,
141
143
  args: args,
142
144
  exitstatus: exitstatus,
143
- all_test_file_paths: test_file_paths,
145
+ node_test_file_paths: test_file_paths,
144
146
  })
145
147
  end
146
148
  end
@@ -155,13 +157,13 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
155
157
  can_initialize_queue: false,
156
158
  args: args,
157
159
  exitstatus: 1, # tests failed
158
- all_test_file_paths: test_file_paths,
160
+ node_test_file_paths: test_file_paths,
159
161
  })
160
162
  end
161
163
  end
162
164
  end
163
165
 
164
- context "when system process didn't finish its work (hasn't exited)" do
166
+ context 'when system process did not finish (it has not exited)' do
165
167
  let(:process_exited) { false }
166
168
 
167
169
  it 'raises an error' do
@@ -170,11 +172,11 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
170
172
  end
171
173
  end
172
174
 
173
- context "when test files don't exist" do
175
+ context 'when test files do not exist' do
174
176
  let(:test_file_paths) { [] }
175
177
 
176
- context 'when all_test_file_paths exist' do
177
- let(:all_test_file_paths) { ['features/a.feature'] }
178
+ context 'when node_test_file_paths exists' do
179
+ let(:node_test_file_paths) { ['features/a.feature'] }
178
180
 
179
181
  it 'returns exit code 0' do
180
182
  expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called)
@@ -189,8 +191,8 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
189
191
  end
190
192
  end
191
193
 
192
- context "when all_test_file_paths don't exist" do
193
- let(:all_test_file_paths) { [] }
194
+ context 'when node_test_file_paths do not exist' do
195
+ let(:node_test_file_paths) { [] }
194
196
 
195
197
  it 'returns exit code 0' do
196
198
  expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
@@ -26,7 +26,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
26
26
  expect($LOAD_PATH).to receive(:unshift).with(test_dir)
27
27
  end
28
28
 
29
- context 'when args provided' do
29
+ context 'when args are provided' do
30
30
  let(:args) { '--verbose --pride' }
31
31
 
32
32
  it do
@@ -41,8 +41,9 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
41
41
  can_initialize_queue: true,
42
42
  args: ['--verbose', '--pride'],
43
43
  exitstatus: 0,
44
- all_test_file_paths: [],
44
+ node_test_file_paths: [],
45
45
  }
46
+ expect(described_class).to receive(:handle_signal!)
46
47
  expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
47
48
 
48
49
  expect(Kernel).to receive(:exit).with(expected_exitstatus)
@@ -51,7 +52,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
51
52
  end
52
53
  end
53
54
 
54
- context 'when args not provided' do
55
+ context 'when args are not provided' do
55
56
  let(:args) { nil }
56
57
 
57
58
  it do
@@ -66,8 +67,9 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
66
67
  can_initialize_queue: true,
67
68
  args: [],
68
69
  exitstatus: 0,
69
- all_test_file_paths: [],
70
+ node_test_file_paths: [],
70
71
  }
72
+ expect(described_class).to receive(:handle_signal!)
71
73
  expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
72
74
 
73
75
  expect(Kernel).to receive(:exit).with(expected_exitstatus)
@@ -82,21 +84,21 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
82
84
  let(:can_initialize_queue) { double(:can_initialize_queue) }
83
85
  let(:args) { ['--verbose', '--pride'] }
84
86
  let(:exitstatus) { 0 }
85
- let(:all_test_file_paths) { [] }
87
+ let(:node_test_file_paths) { [] }
86
88
  let(:accumulator) do
87
89
  {
88
90
  runner: runner,
89
91
  can_initialize_queue: can_initialize_queue,
90
92
  args: args,
91
93
  exitstatus: exitstatus,
92
- all_test_file_paths: all_test_file_paths,
94
+ node_test_file_paths: node_test_file_paths,
93
95
  }
94
96
  end
95
97
 
96
98
  subject { described_class.run_tests(accumulator) }
97
99
 
98
100
  before do
99
- expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: all_test_file_paths).and_return(test_file_paths)
101
+ expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: node_test_file_paths).and_return(test_file_paths)
100
102
  end
101
103
 
102
104
  context 'when test files exist' do
@@ -114,6 +116,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
114
116
  expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
115
117
 
116
118
  # .minitest_run
119
+ allow(File).to receive(:exist?)
117
120
  expect(File).to receive(:exist?).with('./a_test.rb').and_return(true)
118
121
  expect(File).to receive(:exist?).with('./b_test.rb').and_return(true)
119
122
  expect(File).to receive(:exist?).with('./fake_path_test.rb').and_return(false)
@@ -142,7 +145,7 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
142
145
  can_initialize_queue: false,
143
146
  args: args,
144
147
  exitstatus: exitstatus,
145
- all_test_file_paths: test_file_paths,
148
+ node_test_file_paths: test_file_paths,
146
149
  })
147
150
  end
148
151
  end
@@ -157,17 +160,17 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
157
160
  can_initialize_queue: false,
158
161
  args: args,
159
162
  exitstatus: 1, # tests failed
160
- all_test_file_paths: test_file_paths,
163
+ node_test_file_paths: test_file_paths,
161
164
  })
162
165
  end
163
166
  end
164
167
  end
165
168
 
166
- context "when test files don't exist" do
169
+ context 'when test files do not exist' do
167
170
  let(:test_file_paths) { [] }
168
171
 
169
- context 'when all_test_file_paths exist' do
170
- let(:all_test_file_paths) { ['a_test.rb'] }
172
+ context 'when node_test_file_paths exists' do
173
+ let(:node_test_file_paths) { ['a_test.rb'] }
171
174
 
172
175
  it 'returns exit code 0' do
173
176
  expect(KnapsackPro::Adapters::MinitestAdapter).to receive(:verify_bind_method_called)
@@ -182,8 +185,8 @@ describe KnapsackPro::Runners::Queue::MinitestRunner do
182
185
  end
183
186
  end
184
187
 
185
- context "when all_test_file_paths don't exist" do
186
- let(:all_test_file_paths) { [] }
188
+ context 'when node_test_file_paths do not exist' do
189
+ let(:node_test_file_paths) { [] }
187
190
 
188
191
  it 'returns exit code 0' do
189
192
  expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
@@ -36,47 +36,64 @@ describe KnapsackPro::Runners::RSpecRunner do
36
36
  test_files_to_execute_exist?: true)
37
37
  end
38
38
  let(:task) { double }
39
+ let(:task_config) { double }
39
40
 
40
41
  before do
41
42
  expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called).ordered
42
43
  expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).with(['--profile', '--color']).ordered
43
44
 
44
- tracker = instance_double(KnapsackPro::Tracker)
45
- expect(KnapsackPro).to receive(:tracker).and_return(tracker)
46
- expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
47
-
48
45
  expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task)
49
46
 
50
- t = double
51
- expect(RSpec::Core::RakeTask).to receive(:new).with('knapsack_pro:rspec_run').and_yield(t)
52
- expect(t).to receive(:rspec_opts=).with('--profile --color --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
53
- expect(t).to receive(:pattern=).with([])
47
+ expect(RSpec::Core::RakeTask).to receive(:new).with('knapsack_pro:rspec_run').and_yield(task_config)
48
+ expect(RSpec::Core::ConfigurationOptions).to receive_message_chain(:new, :options).and_return({})
49
+ expect(task_config).to receive(:rspec_opts=).with('--profile --color --format progress --format KnapsackPro::Formatters::TimeTracker --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
50
+ expect(task_config).to receive(:pattern=).with([])
54
51
  end
55
52
 
56
- context 'when rake task already exists' do
57
- before do
58
- expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(true)
59
- expect(task).to receive(:clear)
53
+ shared_examples 'invokes RSpec rake task' do
54
+ context 'when rake task already exists' do
55
+ before do
56
+ expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(true)
57
+ expect(task).to receive(:clear)
58
+ end
59
+
60
+ it do
61
+ result = double(:result)
62
+ expect(task).to receive(:invoke).and_return(result)
63
+ expect(subject).to eq result
64
+ end
60
65
  end
61
66
 
62
- it do
63
- result = double(:result)
64
- expect(task).to receive(:invoke).and_return(result)
65
- expect(subject).to eq result
67
+ context "when rake task doesn't exist" do
68
+ before do
69
+ expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(false)
70
+ expect(task).not_to receive(:clear)
71
+ end
72
+
73
+ it do
74
+ result = double(:result)
75
+ expect(task).to receive(:invoke).and_return(result)
76
+ expect(subject).to eq result
77
+ end
66
78
  end
67
79
  end
68
80
 
69
- context "when rake task doesn't exist" do
81
+ context 'when the default log level' do
70
82
  before do
71
- expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(false)
72
- expect(task).not_to receive(:clear)
83
+ expect(task_config).to receive(:verbose=).with(true)
73
84
  end
74
85
 
75
- it do
76
- result = double(:result)
77
- expect(task).to receive(:invoke).and_return(result)
78
- expect(subject).to eq result
86
+ it_behaves_like 'invokes RSpec rake task'
87
+ end
88
+
89
+ context 'when the warning log level' do
90
+ before do
91
+ expect(KnapsackPro::Config::Env).to receive(:log_level).and_return(::Logger::WARN)
92
+
93
+ expect(task_config).to receive(:verbose=).with(false)
79
94
  end
95
+
96
+ it_behaves_like 'invokes RSpec rake task'
80
97
  end
81
98
  end
82
99
 
@@ -11,6 +11,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
11
11
 
12
12
  expect(FileUtils).to receive(:mkdir_p).with(report_dir)
13
13
 
14
+ allow(File).to receive(:exist?)
14
15
  expect(File).to receive(:exist?).at_least(:once).with(report_path).and_return(true)
15
16
  expect(File).to receive(:delete).with(report_path)
16
17
 
@@ -177,10 +177,6 @@ describe KnapsackPro::Tracker do
177
177
 
178
178
  it_behaves_like 'default trakcer attributes'
179
179
 
180
- it "global time since beginning won't be reset" do
181
- expect(tracker.global_time_since_beginning).to be >= 0.1
182
- end
183
-
184
180
  it 'resets prerun_tests_loaded to false' do
185
181
  expect(tracker.prerun_tests_loaded).to be false
186
182
  end
@@ -24,7 +24,7 @@ describe KnapsackPro do
24
24
  })
25
25
 
26
26
  expect(Logger).to receive(:new).with('log/knapsack_pro_node_1.log').and_return(logger)
27
- expect(logger).to receive(:level=).with(Logger::DEBUG)
27
+ expect(logger).to receive(:level=).with(Logger::INFO)
28
28
  expect(KnapsackPro::LoggerWrapper).to receive(:new).with(logger).and_return(logger_wrapper)
29
29
  end
30
30
 
@@ -38,7 +38,7 @@ describe KnapsackPro do
38
38
  })
39
39
 
40
40
  expect(Logger).to receive(:new).with('log/knapsack_pro_node_0.log').and_return(logger)
41
- expect(logger).to receive(:level=).with(Logger::DEBUG)
41
+ expect(logger).to receive(:level=).with(Logger::INFO)
42
42
  expect(KnapsackPro::LoggerWrapper).to receive(:new).with(logger).and_return(logger_wrapper)
43
43
  end
44
44
 
@@ -51,7 +51,7 @@ describe KnapsackPro do
51
51
 
52
52
  before do
53
53
  expect(Logger).to receive(:new).with(STDOUT).and_return(logger)
54
- expect(logger).to receive(:level=).with(Logger::DEBUG)
54
+ expect(logger).to receive(:level=).with(Logger::INFO)
55
55
  expect(KnapsackPro::LoggerWrapper).to receive(:new).with(logger).and_return(logger_wrapper)
56
56
  end
57
57
 
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,6 @@ require 'webmock/rspec'
9
9
  VCR.configure do |config|
10
10
  config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
11
11
  config.hook_into :webmock # or :fakeweb
12
- config.ignore_hosts('codeclimate.com')
13
12
  end
14
13
 
15
14
  require 'knapsack_pro'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2024-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -178,12 +178,12 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.9.4
181
- description: Run tests in parallel across CI server nodes based on tests execution
182
- time. Split tests in a dynamic way to ensure parallel jobs are done at a similar
183
- time. Thanks to that your CI build time is as fast as possible. It works with many
184
- CI providers.
181
+ description: Knapsack Pro wraps your current test runner(s) and works with your existing
182
+ CI infrastructure to parallelize tests optimally. It dynamically splits your tests
183
+ based on up-to-date test execution data. It's designed from the ground up for CI
184
+ and supports all of them.
185
185
  email:
186
- - arturtrzop@gmail.com
186
+ - support@knapsackpro.com
187
187
  executables:
188
188
  - knapsack_pro
189
189
  extensions: []
@@ -192,6 +192,8 @@ files:
192
192
  - ".circleci/config.yml"
193
193
  - ".github/assets/install-button.png"
194
194
  - ".github/assets/knapsack-diamonds.png"
195
+ - ".github/dependabot.yml"
196
+ - ".github/pull_request_template.md"
195
197
  - ".gitignore"
196
198
  - ".rspec"
197
199
  - CHANGELOG.md
@@ -200,6 +202,7 @@ files:
200
202
  - README.md
201
203
  - Rakefile
202
204
  - bin/knapsack_pro
205
+ - bin/test
203
206
  - knapsack_pro.gemspec
204
207
  - lib/knapsack_pro.rb
205
208
  - lib/knapsack_pro/adapters/base_adapter.rb
@@ -230,8 +233,6 @@ files:
230
233
  - lib/knapsack_pro/config/ci/heroku.rb
231
234
  - lib/knapsack_pro/config/ci/semaphore.rb
232
235
  - lib/knapsack_pro/config/ci/semaphore2.rb
233
- - lib/knapsack_pro/config/ci/snap_ci.rb
234
- - lib/knapsack_pro/config/ci/solano_ci.rb
235
236
  - lib/knapsack_pro/config/ci/travis.rb
236
237
  - lib/knapsack_pro/config/env.rb
237
238
  - lib/knapsack_pro/config/env_generator.rb
@@ -240,13 +241,15 @@ files:
240
241
  - lib/knapsack_pro/crypto/decryptor.rb
241
242
  - lib/knapsack_pro/crypto/digestor.rb
242
243
  - lib/knapsack_pro/crypto/encryptor.rb
243
- - lib/knapsack_pro/extensions/time.rb
244
+ - lib/knapsack_pro/extensions/rspec_extension.rb
244
245
  - lib/knapsack_pro/formatters/rspec_json_formatter.rb
245
- - lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
246
- - lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb
246
+ - lib/knapsack_pro/formatters/time_tracker.rb
247
+ - lib/knapsack_pro/formatters/time_tracker_fetcher.rb
247
248
  - lib/knapsack_pro/hooks/queue.rb
248
249
  - lib/knapsack_pro/logger_wrapper.rb
250
+ - lib/knapsack_pro/mask_string.rb
249
251
  - lib/knapsack_pro/presenter.rb
252
+ - lib/knapsack_pro/pure/queue/rspec_pure.rb
250
253
  - lib/knapsack_pro/queue_allocator.rb
251
254
  - lib/knapsack_pro/queue_allocator_builder.rb
252
255
  - lib/knapsack_pro/railtie.rb
@@ -299,6 +302,8 @@ files:
299
302
  - spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml
300
303
  - spec/integration/api/build_distributions_subset_spec.rb
301
304
  - spec/integration/api/build_subsets_create_spec.rb
305
+ - spec/integration/runners/queue/rspec_runner.rb
306
+ - spec/integration/runners/queue/rspec_runner_spec.rb
302
307
  - spec/knapsack_pro/adapters/base_adapter_spec.rb
303
308
  - spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
304
309
  - spec/knapsack_pro/adapters/minitest_adapter_spec.rb
@@ -327,8 +332,6 @@ files:
327
332
  - spec/knapsack_pro/config/ci/heroku_spec.rb
328
333
  - spec/knapsack_pro/config/ci/semaphore2_spec.rb
329
334
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
330
- - spec/knapsack_pro/config/ci/snap_ci_spec.rb
331
- - spec/knapsack_pro/config/ci/solano_ci_spec.rb
332
335
  - spec/knapsack_pro/config/ci/travis_spec.rb
333
336
  - spec/knapsack_pro/config/env_generator_spec.rb
334
337
  - spec/knapsack_pro/config/env_spec.rb
@@ -337,10 +340,11 @@ files:
337
340
  - spec/knapsack_pro/crypto/decryptor_spec.rb
338
341
  - spec/knapsack_pro/crypto/digestor_spec.rb
339
342
  - spec/knapsack_pro/crypto/encryptor_spec.rb
340
- - spec/knapsack_pro/extensions/time_spec.rb
343
+ - spec/knapsack_pro/formatters/time_tracker_specs.rb
341
344
  - spec/knapsack_pro/hooks/queue_spec.rb
342
345
  - spec/knapsack_pro/logger_wrapper_spec.rb
343
346
  - spec/knapsack_pro/presenter_spec.rb
347
+ - spec/knapsack_pro/pure/queue/rspec_pure_spec.rb
344
348
  - spec/knapsack_pro/queue_allocator_builder_spec.rb
345
349
  - spec/knapsack_pro/queue_allocator_spec.rb
346
350
  - spec/knapsack_pro/report_spec.rb
@@ -354,7 +358,6 @@ files:
354
358
  - spec/knapsack_pro/runners/queue/base_runner_spec.rb
355
359
  - spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb
356
360
  - spec/knapsack_pro/runners/queue/minitest_runner_spec.rb
357
- - spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
358
361
  - spec/knapsack_pro/runners/rspec_runner_spec.rb
359
362
  - spec/knapsack_pro/runners/spinach_runner_spec.rb
360
363
  - spec/knapsack_pro/runners/test_unit_runner_spec.rb
@@ -390,7 +393,7 @@ licenses:
390
393
  metadata:
391
394
  bug_tracker_uri: https://github.com/KnapsackPro/knapsack_pro-ruby/issues
392
395
  changelog_uri: https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md
393
- documentation_uri: https://docs.knapsackpro.com/integration/
396
+ documentation_uri: https://docs.knapsackpro.com/knapsack_pro-ruby/guide/
394
397
  homepage_uri: https://knapsackpro.com
395
398
  source_code_uri: https://github.com/KnapsackPro/knapsack_pro-ruby
396
399
  post_install_message:
@@ -401,14 +404,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
401
404
  requirements:
402
405
  - - ">="
403
406
  - !ruby/object:Gem::Version
404
- version: '0'
407
+ version: 2.7.0
405
408
  required_rubygems_version: !ruby/object:Gem::Requirement
406
409
  requirements:
407
410
  - - ">="
408
411
  - !ruby/object:Gem::Version
409
412
  version: '0'
410
413
  requirements: []
411
- rubygems_version: 3.2.3
414
+ rubygems_version: 3.4.19
412
415
  signing_key:
413
416
  specification_version: 4
414
417
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
@@ -421,6 +424,8 @@ test_files:
421
424
  - spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml
422
425
  - spec/integration/api/build_distributions_subset_spec.rb
423
426
  - spec/integration/api/build_subsets_create_spec.rb
427
+ - spec/integration/runners/queue/rspec_runner.rb
428
+ - spec/integration/runners/queue/rspec_runner_spec.rb
424
429
  - spec/knapsack_pro/adapters/base_adapter_spec.rb
425
430
  - spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
426
431
  - spec/knapsack_pro/adapters/minitest_adapter_spec.rb
@@ -449,8 +454,6 @@ test_files:
449
454
  - spec/knapsack_pro/config/ci/heroku_spec.rb
450
455
  - spec/knapsack_pro/config/ci/semaphore2_spec.rb
451
456
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
452
- - spec/knapsack_pro/config/ci/snap_ci_spec.rb
453
- - spec/knapsack_pro/config/ci/solano_ci_spec.rb
454
457
  - spec/knapsack_pro/config/ci/travis_spec.rb
455
458
  - spec/knapsack_pro/config/env_generator_spec.rb
456
459
  - spec/knapsack_pro/config/env_spec.rb
@@ -459,10 +462,11 @@ test_files:
459
462
  - spec/knapsack_pro/crypto/decryptor_spec.rb
460
463
  - spec/knapsack_pro/crypto/digestor_spec.rb
461
464
  - spec/knapsack_pro/crypto/encryptor_spec.rb
462
- - spec/knapsack_pro/extensions/time_spec.rb
465
+ - spec/knapsack_pro/formatters/time_tracker_specs.rb
463
466
  - spec/knapsack_pro/hooks/queue_spec.rb
464
467
  - spec/knapsack_pro/logger_wrapper_spec.rb
465
468
  - spec/knapsack_pro/presenter_spec.rb
469
+ - spec/knapsack_pro/pure/queue/rspec_pure_spec.rb
466
470
  - spec/knapsack_pro/queue_allocator_builder_spec.rb
467
471
  - spec/knapsack_pro/queue_allocator_spec.rb
468
472
  - spec/knapsack_pro/report_spec.rb
@@ -476,7 +480,6 @@ test_files:
476
480
  - spec/knapsack_pro/runners/queue/base_runner_spec.rb
477
481
  - spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb
478
482
  - spec/knapsack_pro/runners/queue/minitest_runner_spec.rb
479
- - spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
480
483
  - spec/knapsack_pro/runners/rspec_runner_spec.rb
481
484
  - spec/knapsack_pro/runners/spinach_runner_spec.rb
482
485
  - spec/knapsack_pro/runners/test_unit_runner_spec.rb