knapsack_pro 7.8.2 → 7.10.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +3 -3
- data/lib/knapsack_pro/slow_test_file_finder.rb +1 -1
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +1 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +12 -6
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +2 -3
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
- 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: 173300dc2ec82a1b5a15005c91ac3ceb942c40acbb14fd2ba57e64d2a32b67d8
|
4
|
+
data.tar.gz: c0c856044ce6773dce0968ebd620f4c49e1fea170c30d880af90ace2e1fb66c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e078dce53b72374ef499087c9675eea34272769a46154997e55dc06ab23e4da7fa016206297eed8b3cc660c5238a99b16177abb6f45c191e3bd38dc60c9cee6f
|
7
|
+
data.tar.gz: 5a80b8cbc3dc3273e297693263a9223fab250d1ee6adbd2c6c909f904d35430f3403a1f9da92dc2709adc3f30f8311b8d05d34b6292e8952e1aae42c88f8f977
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 7.10.0
|
4
|
+
|
5
|
+
* Improve the RSpec split by examples feature. Use test file execution times for existing test files on the disk to determine slow test files. This fixes issue with detecting slow test files when API token is shared between multiple test suites.
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/277
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.9.0...v7.10.0
|
10
|
+
|
11
|
+
### 7.9.0
|
12
|
+
|
13
|
+
* A more readable error message for the RSpec split by examples JSON report (remove ANSI codes that are not human-readable)
|
14
|
+
|
15
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/275
|
16
|
+
|
17
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.8.2...v7.9.0
|
18
|
+
|
3
19
|
### 7.8.2
|
4
20
|
|
5
21
|
* Set `RSpec.world.wants_to_quit` to true when any signal is received by the knapsack_pro gem to allow graceful exit.
|
@@ -5,9 +5,9 @@ module KnapsackPro
|
|
5
5
|
TIME_THRESHOLD_PER_CI_NODE = 0.7 # 70%
|
6
6
|
|
7
7
|
# test_files: { 'path' => 'a_spec.rb', 'time_execution' => 0.0 }
|
8
|
-
|
9
|
-
|
10
|
-
time_threshold = (
|
8
|
+
def self.call(test_files)
|
9
|
+
total_execution_time = test_files.sum { |test_file| test_file.fetch('time_execution') }
|
10
|
+
time_threshold = (total_execution_time / KnapsackPro::Config::Env.ci_node_total) * TIME_THRESHOLD_PER_CI_NODE
|
11
11
|
|
12
12
|
test_files.select do |test_file|
|
13
13
|
time_execution = test_file.fetch('time_execution')
|
@@ -19,7 +19,7 @@ module KnapsackPro
|
|
19
19
|
|
20
20
|
test_files_existing_on_disk = KnapsackPro::TestFileFinder.select_test_files_that_can_be_run(adapter_class, merged_test_files_from_api)
|
21
21
|
|
22
|
-
slow_test_files = KnapsackPro::SlowTestFileDeterminer.call(test_files_existing_on_disk
|
22
|
+
slow_test_files = KnapsackPro::SlowTestFileDeterminer.call(test_files_existing_on_disk)
|
23
23
|
|
24
24
|
KnapsackPro::SlowTestFileDeterminer.save_to_json_report(slow_test_files)
|
25
25
|
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -6,7 +6,7 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
6
6
|
expect(KnapsackPro::Config::Env).to receive(:ci_node_total).and_return(node_total)
|
7
7
|
end
|
8
8
|
|
9
|
-
subject { described_class.call(test_files
|
9
|
+
subject { described_class.call(test_files) }
|
10
10
|
|
11
11
|
context 'when test files have recorded time execution' do
|
12
12
|
let(:time_execution) { 20.0 }
|
@@ -14,22 +14,20 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
14
14
|
[
|
15
15
|
{ 'path' => 'a_spec.rb', 'time_execution' => 1.0 },
|
16
16
|
{ 'path' => 'b_spec.rb', 'time_execution' => 3.4 },
|
17
|
-
# slow tests are above 3.5s threshold (20.0 / 4 * 0.7 = 3.5)
|
18
17
|
{ 'path' => 'c_spec.rb', 'time_execution' => 3.5 },
|
19
|
-
{ 'path' => 'd_spec.rb', 'time_execution' =>
|
18
|
+
{ 'path' => 'd_spec.rb', 'time_execution' => 12.1 },
|
20
19
|
]
|
21
20
|
end
|
22
21
|
|
23
|
-
it do
|
22
|
+
it 'detects slow tests above 3.5s threshold (20.0 / 4 nodes * 70% threshold = 3.5)' do
|
24
23
|
expect(subject).to eq([
|
25
24
|
{ 'path' => 'c_spec.rb', 'time_execution' => 3.5 },
|
26
|
-
{ 'path' => 'd_spec.rb', 'time_execution' =>
|
25
|
+
{ 'path' => 'd_spec.rb', 'time_execution' => 12.1 },
|
27
26
|
])
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
context 'when test files have no recorded time execution' do
|
32
|
-
let(:time_execution) { 0.0 }
|
33
31
|
let(:test_files) do
|
34
32
|
[
|
35
33
|
{ 'path' => 'a_spec.rb', 'time_execution' => 0.0 },
|
@@ -41,6 +39,14 @@ describe KnapsackPro::SlowTestFileDeterminer do
|
|
41
39
|
expect(subject).to eq([])
|
42
40
|
end
|
43
41
|
end
|
42
|
+
|
43
|
+
context 'when there are no test files' do
|
44
|
+
let(:test_files) { [] }
|
45
|
+
|
46
|
+
it do
|
47
|
+
expect(subject).to eq([])
|
48
|
+
end
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
describe '.save_to_json_report', :clear_tmp do
|
@@ -13,8 +13,7 @@ describe KnapsackPro::SlowTestFileFinder do
|
|
13
13
|
|
14
14
|
it do
|
15
15
|
test_files_from_api = double
|
16
|
-
|
17
|
-
build_distribution_entity = instance_double(KnapsackPro::BuildDistributionFetcher::BuildDistributionEntity, test_files: test_files_from_api, time_execution: time_execution)
|
16
|
+
build_distribution_entity = instance_double(KnapsackPro::BuildDistributionFetcher::BuildDistributionEntity, test_files: test_files_from_api)
|
18
17
|
expect(KnapsackPro::BuildDistributionFetcher).to receive(:call).and_return(build_distribution_entity)
|
19
18
|
|
20
19
|
merged_test_files_from_api = double
|
@@ -24,7 +23,7 @@ describe KnapsackPro::SlowTestFileFinder do
|
|
24
23
|
expect(KnapsackPro::TestFileFinder).to receive(:select_test_files_that_can_be_run).with(adapter_class, merged_test_files_from_api).and_return(test_files_existing_on_disk)
|
25
24
|
|
26
25
|
slow_test_files = double
|
27
|
-
expect(KnapsackPro::SlowTestFileDeterminer).to receive(:call).with(test_files_existing_on_disk
|
26
|
+
expect(KnapsackPro::SlowTestFileDeterminer).to receive(:call).with(test_files_existing_on_disk).and_return(slow_test_files)
|
28
27
|
|
29
28
|
expect(KnapsackPro::SlowTestFileDeterminer).to receive(:save_to_json_report).with(slow_test_files)
|
30
29
|
|
@@ -48,6 +48,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
48
48
|
expect(RSpec::Core::ConfigurationOptions).to receive(:new).with([
|
49
49
|
'--format', expected_format,
|
50
50
|
'--dry-run',
|
51
|
+
'--no-color',
|
51
52
|
'--out', report_path,
|
52
53
|
'--default-path', test_dir,
|
53
54
|
'spec/a_spec.rb', 'spec/b_spec.rb',
|
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.
|
4
|
+
version: 7.10.0
|
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-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|