knapsack_pro 7.12.0 → 7.12.1

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: b6e9369d803759d8590a88b3e34bc3e195ca6520ee6f97e41c312735a768a8bb
4
- data.tar.gz: 45dd6b4b8871cd370ec44384b706a0445cce6276b0463bc307d36f79dea16deb
3
+ metadata.gz: 204e1595877682d96997ee193c8b0aa0230d6f5e1c22d37ca515e1e94a40d404
4
+ data.tar.gz: 4a373acd12bdd3451bda93d7186a69a217aeeea593c3ad1d8cb425d1f215d0cc
5
5
  SHA512:
6
- metadata.gz: 4a0a3f3301f24a840845b0a59d40f06aa94d1ce94d1156846f740f237606c54a05b32da7d44ee815a65674c35ca94ac63185b0d93262570c3379e60a3686872f
7
- data.tar.gz: 12f877a2c3e060580c3b2f20fc1de7fb934c47c82f1dfa95a1b240ab82838cf6580c9325fbba494849e14515634084cc12b294224412e2e63d5aa36810572d98
6
+ metadata.gz: 9f2310862a878b55c4001beaf3beda4c2249946a7fc04fe40f3b4e5911c17aff1ffc1df2437df392aa597681396cc1dc1e7a0deac67936d6e5cbf399bda830c5
7
+ data.tar.gz: a3d8b7bf464a71a5a0600333f017a981562ecab163c52f1b67747c5aaad444aab834ab7d0a93ef00cad012e2d4f66163ec1cfa9b9204e4bb13477b1fdce263de
data/.circleci/config.yml CHANGED
@@ -277,6 +277,16 @@ jobs:
277
277
  export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
278
278
  export KNAPSACK_PRO_SLOW_TEST_FILE_THRESHOLD=1
279
279
  bundle exec rake knapsack_pro:queue:rspec
280
+ - run:
281
+ working_directory: ~/rails-app-with-knapsack_pro
282
+ command: |
283
+ # split by test examples AND a single CI node ||
284
+ export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--queue--split--single-node"
285
+ export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true
286
+ export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
287
+ export KNAPSACK_PRO_CI_NODE_TOTAL=1
288
+ export KNAPSACK_PRO_CI_NODE_INDEX=0
289
+ bundle exec rake knapsack_pro:queue:rspec
280
290
  - run:
281
291
  working_directory: ~/rails-app-with-knapsack_pro
282
292
  command: |
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ### 7.12.1
4
+
5
+ * fix(RSpec split by examples): properly disable split by test examples on a single node to speed up tests
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/283
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.12.0...v7.12.1
10
+
3
11
  ### 7.12.0
4
12
 
5
13
  * Add `KNAPSACK_PRO_SLOW_TEST_FILE_THRESHOLD` to improve the RSpec split by examples feature with many skipped tests
@@ -36,11 +36,6 @@ module KnapsackPro
36
36
  test_files_to_run = all_test_files_to_run
37
37
 
38
38
  if adapter_class.split_by_test_cases_enabled?
39
- if KnapsackPro::Config::Env.ci_node_total < 2
40
- KnapsackPro.logger.warn('Skipping split of test files by test cases because you are running tests on a single CI node (no parallelism)')
41
- return test_files_to_run
42
- end
43
-
44
39
  slow_test_files = get_slow_test_files
45
40
  return test_files_to_run if slow_test_files.empty?
46
41
 
@@ -188,12 +188,17 @@ module KnapsackPro
188
188
  ENV.fetch('KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX', 'bundle exec')
189
189
  end
190
190
 
191
- def rspec_split_by_test_examples
192
- ENV.fetch('KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES', false)
193
- end
194
-
195
191
  def rspec_split_by_test_examples?
196
- rspec_split_by_test_examples.to_s == 'true'
192
+ return @rspec_split_by_test_examples if defined?(@rspec_split_by_test_examples)
193
+
194
+ split = ENV.fetch('KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES', false).to_s == 'true'
195
+
196
+ if split && ci_node_total < 2
197
+ KnapsackPro.logger.debug('Skipping split of test files by test examples because you are running tests on a single CI node (no parallelism)')
198
+ @rspec_split_by_test_examples = false
199
+ else
200
+ @rspec_split_by_test_examples = split
201
+ end
197
202
  end
198
203
 
199
204
  def rspec_test_example_detector_prefix
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '7.12.0'
4
+ VERSION = '7.12.1'
5
5
  end
@@ -134,57 +134,39 @@ describe KnapsackPro::BaseAllocatorBuilder do
134
134
 
135
135
  before do
136
136
  expect(adapter_class).to receive(:split_by_test_cases_enabled?).and_return(true)
137
- expect(KnapsackPro::Config::Env).to receive(:ci_node_total).and_return(node_total)
138
137
 
139
138
  test_file_pattern = double
140
139
  expect(KnapsackPro::TestFilePattern).to receive(:call).with(adapter_class).and_return(test_file_pattern)
141
140
 
142
141
  expect(KnapsackPro::TestFileFinder).to receive(:call).with(test_file_pattern).and_return(test_files_to_run)
143
- end
144
-
145
- context 'when less than 2 CI nodes' do
146
- let(:node_total) { 1 }
147
142
 
148
- it 'returns test files without test cases' do
149
- logger = instance_double(Logger)
150
- expect(KnapsackPro).to receive(:logger).and_return(logger)
151
- expect(logger).to receive(:warn).with('Skipping split of test files by test cases because you are running tests on a single CI node (no parallelism)')
152
- expect(subject).to eq test_files_to_run
153
- end
143
+ expect(allocator_builder).to receive(:get_slow_test_files).and_return(slow_test_files)
154
144
  end
155
145
 
156
- context 'when at least 2 CI nodes' do
157
- let(:node_total) { 2 }
158
-
159
- before do
160
- expect(allocator_builder).to receive(:get_slow_test_files).and_return(slow_test_files)
146
+ context 'when slow test files are detected' do
147
+ let(:slow_test_files) do
148
+ [
149
+ '1_spec.rb',
150
+ '2_spec.rb',
151
+ ]
161
152
  end
162
153
 
163
- context 'when slow test files are detected' do
164
- let(:slow_test_files) do
165
- [
166
- '1_spec.rb',
167
- '2_spec.rb',
168
- ]
169
- end
170
-
171
- it 'returns test files with test cases' do
172
- test_file_cases = double
173
- expect(adapter_class).to receive(:test_file_cases_for).with(slow_test_files).and_return(test_file_cases)
154
+ it 'returns test files with test cases' do
155
+ test_file_cases = double
156
+ expect(adapter_class).to receive(:test_file_cases_for).with(slow_test_files).and_return(test_file_cases)
174
157
 
175
- test_files_with_test_cases = double
176
- expect(KnapsackPro::TestFilesWithTestCasesComposer).to receive(:call).with(test_files_to_run, slow_test_files, test_file_cases).and_return(test_files_with_test_cases)
158
+ test_files_with_test_cases = double
159
+ expect(KnapsackPro::TestFilesWithTestCasesComposer).to receive(:call).with(test_files_to_run, slow_test_files, test_file_cases).and_return(test_files_with_test_cases)
177
160
 
178
- expect(subject).to eq test_files_with_test_cases
179
- end
161
+ expect(subject).to eq test_files_with_test_cases
180
162
  end
163
+ end
181
164
 
182
- context 'when slow test files are not detected' do
183
- let(:slow_test_files) { [] }
165
+ context 'when slow test files are not detected' do
166
+ let(:slow_test_files) { [] }
184
167
 
185
- it 'returns test files without test cases' do
186
- expect(subject).to eq test_files_to_run
187
- end
168
+ it 'returns test files without test cases' do
169
+ expect(subject).to eq test_files_to_run
188
170
  end
189
171
  end
190
172
  end
@@ -1013,37 +1013,54 @@ describe KnapsackPro::Config::Env do
1013
1013
  end
1014
1014
  end
1015
1015
 
1016
- describe '.rspec_split_by_test_examples' do
1017
- subject { described_class.rspec_split_by_test_examples }
1016
+ describe '.rspec_split_by_test_examples?' do
1017
+ subject { described_class.rspec_split_by_test_examples? }
1018
1018
 
1019
- context 'when ENV exists' do
1020
- before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => true }) }
1021
- it { should eq true }
1019
+ before do
1020
+ described_class.remove_instance_variable(:@rspec_split_by_test_examples)
1021
+ rescue NameError
1022
1022
  end
1023
1023
 
1024
- context "when ENV doesn't exist" do
1025
- before { stub_const("ENV", {}) }
1024
+ context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true AND KNAPSACK_PRO_CI_NODE_TOTAL >= 2' do
1025
+ before do
1026
+ stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => 'true', 'KNAPSACK_PRO_CI_NODE_TOTAL' => '2' })
1027
+ expect(KnapsackPro).not_to receive(:logger)
1028
+ end
1029
+
1030
+ it { should be true }
1031
+ end
1032
+
1033
+ context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=false AND KNAPSACK_PRO_CI_NODE_TOTAL >= 2' do
1034
+ before do
1035
+ stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => 'false', 'KNAPSACK_PRO_CI_NODE_TOTAL' => '2' })
1036
+ expect(KnapsackPro).not_to receive(:logger)
1037
+ end
1038
+
1026
1039
  it { should be false }
1027
1040
  end
1028
- end
1029
1041
 
1030
- describe '.rspec_split_by_test_examples?' do
1031
- subject { described_class.rspec_split_by_test_examples? }
1042
+ context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true AND KNAPSACK_PRO_CI_NODE_TOTAL < 2' do
1043
+ before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => 'true', 'KNAPSACK_PRO_CI_NODE_TOTAL' => '1' }) }
1032
1044
 
1033
- context 'when ENV exists' do
1034
- context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true' do
1035
- before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => 'true' }) }
1036
- it { should be true }
1037
- end
1045
+ it { should be false }
1038
1046
 
1039
- context 'when KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=false' do
1040
- before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => 'false' }) }
1041
- it { should be false }
1047
+ context 'when called twice' do
1048
+ it 'logs a debug message only once' do
1049
+ logger = instance_double(Logger)
1050
+ expect(KnapsackPro).to receive(:logger).and_return(logger)
1051
+ expect(logger).to receive(:debug).with('Skipping split of test files by test examples because you are running tests on a single CI node (no parallelism)')
1052
+
1053
+ 2.times { described_class.rspec_split_by_test_examples? }
1054
+ end
1042
1055
  end
1043
1056
  end
1044
1057
 
1045
1058
  context "when ENV doesn't exist" do
1046
- before { stub_const("ENV", {}) }
1059
+ before do
1060
+ stub_const("ENV", {})
1061
+ expect(KnapsackPro).not_to receive(:logger)
1062
+ end
1063
+
1047
1064
  it { should be false }
1048
1065
  end
1049
1066
  end
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: 7.12.0
4
+ version: 7.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake