knapsack_pro 8.3.2 → 8.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 479679af72441adcef212263c4a92e92760fc3bb82779616c47504d0a137a69c
4
- data.tar.gz: 6376bcc3c00f50efa3633a1d015b23bb7a6fd3d8a3188d6912327e5f79c1ae27
3
+ metadata.gz: 17dceae7090394f68959e5b8bdef4c0640ce4027b28efe41fb8f3d612b5f0348
4
+ data.tar.gz: 5828288a2160348d9acce467e17d16da00e8f794aa39e70d0d0b5fecc0b9188c
5
5
  SHA512:
6
- metadata.gz: 7dc0407f4c64d578cac17f64f71d93ac123e8ee7a96eeca2637e7e131449c35318bed7b6636d9e722528f36059a4cb5a8748b18e7737aaa8e92ba8212c82f83e
7
- data.tar.gz: b3c505870912614006845bbf65b488ca1fe201f0a22e0dc449d5b2f7651603eceea5693fa7db5eff68bc7cd5bc89dde673eb21097a4cb341473b5b06bbcacaf5
6
+ metadata.gz: abf9abe76b5e0841d95c09230cd88289e6c197a26dad27cd2a9c7f2fe97310c9d1fbe1ddb77134676c604daa7a28bd8d6c405598262f9623a9110c5b7ce15751
7
+ data.tar.gz: 7c9a0f978b8f01b2e5ad888535ddfbaf006b20da5a5853edc454dd82044f1608b2ce9d21acd25a00c77146bbad7e0954d76f5fc2ae541970cdfd9feaee0bc45e
data/.circleci/config.yml CHANGED
@@ -65,7 +65,6 @@ jobs:
65
65
  - run: bundle update rspec
66
66
  - run: bundle exec rspec --version
67
67
  - run: bundle exec rspec spec
68
- - run: bundle exec ruby spec/knapsack_pro/formatters/time_tracker_specs.rb
69
68
 
70
69
  integration-rspec:
71
70
  parallelism: 1
@@ -1,23 +1,11 @@
1
- # Story
2
-
3
- TODO: link to the internal story
4
-
5
- ## Related
6
-
7
- TODO: links to related PRs or issues
8
-
9
1
  # Description
10
2
 
11
3
  TODO
12
4
 
13
- # Changes
14
-
15
- TODO: changes introduced by this PR
16
-
17
- # Checklist reminder
5
+ # Checks
18
6
 
19
- - [ ] You added the changes to the `UNRELEASED` section of the `CHANGELOG.md`, including the needed bump (ie, patch, minor, major)
20
- - [ ] You follow the architecture outlined below for RSpec in Queue Mode, which is a work in progress (feel free to propose changes):
7
+ - [ ] I added the changes to the `UNRELEASED` section of the `CHANGELOG.md`, including the needed bump (i.e., patch, minor, major)
8
+ - [ ] I followed the architecture outlined below for RSpec in Queue Mode:
21
9
  - Pure: `lib/knapsack_pro/pure/queue/rspec_pure.rb` contains pure functions that are unit tested.
22
- - Extension: `lib/knapsack_pro/extensions/rspec_extension.rb` encapsulates calls to RSpec internals and is integration and e2e tested.
23
- - Runner: `lib/knapsack_pro/runners/queue/rspec_runner.rb` invokes the pure code and the extension to produce side effects, which are integration and e2e tested.
10
+ - Extension: `lib/knapsack_pro/extensions/rspec_extension.rb` encapsulates calls to RSpec internals and is integration and E2E tested.
11
+ - Runner: `lib/knapsack_pro/runners/queue/rspec_runner.rb` invokes the pure code and the extension to produce side effects, which are integration and E2E tested.
data/.gitignore CHANGED
@@ -36,5 +36,4 @@ Gemfile.lock
36
36
  .rvmrc
37
37
 
38
38
  # dynamically generated specs
39
- spec/knapsack_pro/formatters/tmp_time_tracker*_spec.rb
40
39
  spec_integration/
data/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ### UNRELEASED (patch)
4
4
 
5
+ ### 8.4.0
6
+
7
+ * Add a batch UUID to the V1 Queue API request payload to improve handling of retried requests
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/307
10
+
11
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.3...v8.4.0
12
+
13
+ ### 8.3.3
14
+
15
+ * Replace `Hash#sum` with `Hash#reduce` to fix a rare bug in the RSpec time tracker for a specific project
16
+
17
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/305
18
+
19
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.2...v8.3.3
20
+
5
21
  ### 8.3.2
6
22
 
7
23
  * Fix infinite recursion when the logger enters a loop. [The issue](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/269) occurs when `KNAPSACK_PRO_LOG_DIR=log` is set and a conflict arises between the values of environment variables from the CI provider and those configured by the user (e.g., `KNAPSACK_PRO_CI_NODE_INDEX`, `KNAPSACK_PRO_CI_NODE_TOTAL`).
data/README.md CHANGED
@@ -67,7 +67,7 @@ bundle update knapsack_pro
67
67
  RSpec:
68
68
 
69
69
  ```bash
70
- bin/test
70
+ bundle exec rspec
71
71
  ```
72
72
 
73
73
  Scripted tests can be found in the [Rails App With Knapsack Pro repository](https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/master/bin/knapsack_pro_all.rb).
@@ -19,6 +19,7 @@ module KnapsackPro
19
19
  :node_index => args.fetch(:node_index),
20
20
  :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
21
21
  :user_seat => KnapsackPro::Config::Env.masked_user_seat,
22
+ batch_uuid: args.fetch(:batch_uuid)
22
23
  }
23
24
 
24
25
  if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
@@ -109,12 +109,12 @@ module KnapsackPro
109
109
  group.each do |_, example|
110
110
  next if example[:time_execution] == 0.0
111
111
 
112
- example[:time_execution] += time_all_by_group_id_path.sum do |group_id_path, time|
112
+ example[:time_execution] += time_all_by_group_id_path.reduce(0.0) do |sum, (group_id_path, time)|
113
113
  # :path is a file path (a_spec.rb), sum any before/after(:all) in the file
114
- next time if group_id_path.start_with?(example[:path])
114
+ next sum + time if group_id_path.start_with?(example[:path])
115
115
  # :path is an id path (a_spec.rb[1:1]), sum any before/after(:all) above it
116
- next time if example[:path].start_with?(group_id_path[0..-2])
117
- 0
116
+ next sum + time if example[:path].start_with?(group_id_path[0..-2])
117
+ sum
118
118
  end
119
119
  end
120
120
  end
@@ -41,26 +41,26 @@ module KnapsackPro
41
41
  @fallback_mode = false
42
42
  end
43
43
 
44
- def test_file_paths(can_initialize_queue, executed_test_files)
44
+ def test_file_paths(can_initialize_queue, executed_test_files, batch_uuid: SecureRandom.uuid)
45
45
  return [] if @fallback_mode
46
46
 
47
- batch = pull_tests_from_queue(can_initialize_queue)
47
+ batch = pull_tests_from_queue(can_initialize_queue, batch_uuid)
48
48
 
49
49
  return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed?
50
50
  return normalize_test_files(batch.test_files) if batch.queue_exists?
51
51
 
52
52
  test_files_result = test_suite.calculate_test_files
53
53
 
54
- return try_initializing_queue(test_files_result.test_files) if test_files_result.quick?
54
+ return try_initializing_queue(test_files_result.test_files, batch_uuid) if test_files_result.quick?
55
55
 
56
56
  # The tests to run were found slowly. By that time, the queue could have already been initialized by another CI node.
57
57
  # Attempt to pull tests from the queue to avoid the attempt to initialize the queue unnecessarily (queue initialization is an expensive request with a big test files payload).
58
- batch = pull_tests_from_queue(can_initialize_queue)
58
+ batch = pull_tests_from_queue(can_initialize_queue, batch_uuid)
59
59
 
60
60
  return switch_to_fallback_mode(executed_test_files: executed_test_files) if batch.connection_failed?
61
61
  return normalize_test_files(batch.test_files) if batch.queue_exists?
62
62
 
63
- try_initializing_queue(test_files_result.test_files)
63
+ try_initializing_queue(test_files_result.test_files, batch_uuid)
64
64
  end
65
65
 
66
66
  private
@@ -80,7 +80,7 @@ module KnapsackPro
80
80
  KnapsackPro::TestFilePresenter.paths(decrypted_test_files)
81
81
  end
82
82
 
83
- def build_action(can_initialize_queue:, attempt_connect_to_queue:, test_files: nil)
83
+ def build_action(can_initialize_queue:, attempt_connect_to_queue:, batch_uuid:, test_files: nil)
84
84
  if can_initialize_queue && !attempt_connect_to_queue
85
85
  raise 'Test files are required when initializing a new queue.' if test_files.nil?
86
86
  test_files = KnapsackPro::Crypto::Encryptor.call(test_files)
@@ -95,25 +95,26 @@ module KnapsackPro
95
95
  node_index: ci_node_index,
96
96
  node_build_id: ci_node_build_id,
97
97
  test_files: test_files,
98
+ batch_uuid: batch_uuid
98
99
  )
99
100
  end
100
101
 
101
- def pull_tests_from_queue(can_initialize_queue)
102
- action = build_action(can_initialize_queue: can_initialize_queue, attempt_connect_to_queue: can_initialize_queue)
102
+ def pull_tests_from_queue(can_initialize_queue, batch_uuid)
103
+ action = build_action(can_initialize_queue: can_initialize_queue, attempt_connect_to_queue: can_initialize_queue, batch_uuid: batch_uuid)
103
104
  connection = KnapsackPro::Client::Connection.new(action)
104
105
  response = connection.call
105
106
  Batch.new(connection, response)
106
107
  end
107
108
 
108
- def initialize_queue(tests_to_run)
109
- action = build_action(can_initialize_queue: true, attempt_connect_to_queue: false, test_files: tests_to_run)
109
+ def initialize_queue(tests_to_run, batch_uuid)
110
+ action = build_action(can_initialize_queue: true, attempt_connect_to_queue: false, batch_uuid: batch_uuid, test_files: tests_to_run)
110
111
  connection = KnapsackPro::Client::Connection.new(action)
111
112
  response = connection.call
112
113
  Batch.new(connection, response)
113
114
  end
114
115
 
115
- def try_initializing_queue(tests)
116
- result = initialize_queue(tests)
116
+ def try_initializing_queue(tests, batch_uuid)
117
+ result = initialize_queue(tests, batch_uuid)
117
118
 
118
119
  return switch_to_fallback_mode(executed_test_files: []) if result.connection_failed?
119
120
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '8.3.2'
4
+ VERSION = '8.4.0'
5
5
  end
@@ -10,6 +10,7 @@ describe KnapsackPro::Client::API::V1::Queues do
10
10
  let(:masked_user_seat) { double }
11
11
  let(:can_initialize_queue) { [false, true].sample }
12
12
  let(:attempt_connect_to_queue) { [false, true].sample }
13
+ let(:batch_uuid) { SecureRandom.uuid }
13
14
 
14
15
  subject do
15
16
  described_class.queue(
@@ -19,7 +20,8 @@ describe KnapsackPro::Client::API::V1::Queues do
19
20
  branch: branch,
20
21
  node_total: node_total,
21
22
  node_index: node_index,
22
- test_files: test_files
23
+ test_files: test_files,
24
+ batch_uuid: batch_uuid
23
25
  )
24
26
  end
25
27