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 +4 -4
- data/.circleci/config.yml +10 -0
- data/CHANGELOG.md +8 -0
- data/lib/knapsack_pro/base_allocator_builder.rb +0 -5
- data/lib/knapsack_pro/config/env.rb +10 -5
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +18 -36
- data/spec/knapsack_pro/config/env_spec.rb +36 -19
- 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: 204e1595877682d96997ee193c8b0aa0230d6f5e1c22d37ca515e1e94a40d404
|
4
|
+
data.tar.gz: 4a373acd12bdd3451bda93d7186a69a217aeeea593c3ad1d8cb425d1f215d0cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -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
|
-
|
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
|
157
|
-
let(:
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
164
|
-
|
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
|
-
|
176
|
-
|
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
|
-
|
179
|
-
end
|
161
|
+
expect(subject).to eq test_files_with_test_cases
|
180
162
|
end
|
163
|
+
end
|
181
164
|
|
182
|
-
|
183
|
-
|
165
|
+
context 'when slow test files are not detected' do
|
166
|
+
let(:slow_test_files) { [] }
|
184
167
|
|
185
|
-
|
186
|
-
|
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
|
-
|
1020
|
-
|
1021
|
-
|
1019
|
+
before do
|
1020
|
+
described_class.remove_instance_variable(:@rspec_split_by_test_examples)
|
1021
|
+
rescue NameError
|
1022
1022
|
end
|
1023
1023
|
|
1024
|
-
context
|
1025
|
-
before
|
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
|
-
|
1031
|
-
|
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
|
-
|
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
|
1040
|
-
|
1041
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|