knapsack_pro 8.3.3 → 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: 7a43269c3d826dc9e9faed08299cffbc2d12afc454de28b58435e2bc05861e55
4
- data.tar.gz: 41c2129c7f580d3637a2cf7a189d4b4cf4e0ce10fa677162fd82640c2bf1b582
3
+ metadata.gz: 17dceae7090394f68959e5b8bdef4c0640ce4027b28efe41fb8f3d612b5f0348
4
+ data.tar.gz: 5828288a2160348d9acce467e17d16da00e8f794aa39e70d0d0b5fecc0b9188c
5
5
  SHA512:
6
- metadata.gz: e3a172a78479d59fd9a5becff1606df2555e5db961573ab42786ee37942f8a3c56305c996c3c774a5890189ad1ad75be1057066b0043f3260d4ce97668154a84
7
- data.tar.gz: a8176152345555ddcac3024a903cc6749b7d32ea0f432f5b01b8e10813202288f511b5ba06f5a1dd6b20738d4f4a25d9af7f6604d70544c771c2b30f186cc4e0
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
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,9 +2,17 @@
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
+
5
13
  ### 8.3.3
6
14
 
7
- * Fix a `Hash#sum` bug in the time tracker for RSpec
15
+ * Replace `Hash#sum` with `Hash#reduce` to fix a rare bug in the RSpec time tracker for a specific project
8
16
 
9
17
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/305
10
18
 
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]
@@ -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.3'
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