knapsack_pro 7.9.0 → 7.10.0

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: 3d625a03b86be895a8b0250cc4bc19e9a3a53065f99d05266e1a2a3a09c8e115
4
- data.tar.gz: b89c5d69fd4330ff4bec30c5a44a37d4bc6a6622743e75044aafcfaae13b5a4f
3
+ metadata.gz: 173300dc2ec82a1b5a15005c91ac3ceb942c40acbb14fd2ba57e64d2a32b67d8
4
+ data.tar.gz: c0c856044ce6773dce0968ebd620f4c49e1fea170c30d880af90ace2e1fb66c1
5
5
  SHA512:
6
- metadata.gz: f30db8ff8c5f391814991fc565036b35c416f2c2015d48e9385ad2bd8b2dbd242867817df03fcd053b152c31b2e142da07f50069251b0a586dc6ef572833b05a
7
- data.tar.gz: 285de6eab1d7fb36c457ca3361748208064bcbfe6cf937a37cc6997b2c1334e121545072ffab7cfc2096ef877837faa0f5c70930d35dca29c80a880add04c5d7
6
+ metadata.gz: e078dce53b72374ef499087c9675eea34272769a46154997e55dc06ab23e4da7fa016206297eed8b3cc660c5238a99b16177abb6f45c191e3bd38dc60c9cee6f
7
+ data.tar.gz: 5a80b8cbc3dc3273e297693263a9223fab250d1ee6adbd2c6c909f904d35430f3403a1f9da92dc2709adc3f30f8311b8d05d34b6292e8952e1aae42c88f8f977
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ### 7.9.0
4
12
 
5
13
  * A more readable error message for the RSpec split by examples JSON report (remove ANSI codes that are not human-readable)
@@ -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
- # time_execution: of build distribution (total time of CI build run)
9
- def self.call(test_files, time_execution)
10
- time_threshold = (time_execution / KnapsackPro::Config::Env.ci_node_total) * TIME_THRESHOLD_PER_CI_NODE
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, build_distribution_entity.time_execution)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '7.9.0'
4
+ VERSION = '7.10.0'
5
5
  end
@@ -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, time_execution) }
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' => 5.9 },
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' => 5.9 },
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
- time_execution = double
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, time_execution).and_return(slow_test_files)
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
 
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.9.0
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-22 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake