knapsack_pro 8.3.1 → 8.3.2
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 +8 -0
- data/lib/knapsack_pro/config/env.rb +3 -3
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/config/env_spec.rb +25 -48
- data/spec/knapsack_pro_spec.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 479679af72441adcef212263c4a92e92760fc3bb82779616c47504d0a137a69c
|
4
|
+
data.tar.gz: 6376bcc3c00f50efa3633a1d015b23bb7a6fd3d8a3188d6912327e5f79c1ae27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dc0407f4c64d578cac17f64f71d93ac123e8ee7a96eeca2637e7e131449c35318bed7b6636d9e722528f36059a4cb5a8748b18e7737aaa8e92ba8212c82f83e
|
7
|
+
data.tar.gz: b3c505870912614006845bbf65b488ca1fe201f0a22e0dc449d5b2f7651603eceea5693fa7db5eff68bc7cd5bc89dde673eb21097a4cb341473b5b06bbcacaf5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
### UNRELEASED (patch)
|
4
4
|
|
5
|
+
### 8.3.2
|
6
|
+
|
7
|
+
* 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`).
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/304
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.1...v8.3.2
|
12
|
+
|
5
13
|
### 8.3.1
|
6
14
|
|
7
15
|
* Fix RSpec TimeTracker to properly track `before(:all)/after(:all)`.
|
@@ -13,11 +13,11 @@ module KnapsackPro
|
|
13
13
|
|
14
14
|
class << self
|
15
15
|
def ci_node_total
|
16
|
-
(env_for('KNAPSACK_PRO_CI_NODE_TOTAL', :node_total) || 1).to_i
|
16
|
+
@ci_node_total ||= (env_for('KNAPSACK_PRO_CI_NODE_TOTAL', :node_total) || 1).to_i
|
17
17
|
end
|
18
18
|
|
19
19
|
def ci_node_index
|
20
|
-
(env_for('KNAPSACK_PRO_CI_NODE_INDEX', :node_index) || 0).to_i
|
20
|
+
@ci_node_index ||= (env_for('KNAPSACK_PRO_CI_NODE_INDEX', :node_index) || 0).to_i
|
21
21
|
end
|
22
22
|
|
23
23
|
def ci_node_build_id
|
@@ -294,7 +294,7 @@ module KnapsackPro
|
|
294
294
|
ci_env_value = ci_env_for(ci_env_method)
|
295
295
|
|
296
296
|
if !knapsack_env_value.nil? && !ci_env_value.nil? && knapsack_env_value != ci_env_value.to_s
|
297
|
-
|
297
|
+
warn("You have set the environment variable #{knapsack_env_name} to #{knapsack_env_value} which could be automatically determined from the CI environment as #{ci_env_value}.")
|
298
298
|
end
|
299
299
|
|
300
300
|
knapsack_env_value != nil ? knapsack_env_value : ci_env_value
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
describe KnapsackPro::Config::Env do
|
2
2
|
before { stub_const("ENV", {}) }
|
3
3
|
|
4
|
+
before(:each) do
|
5
|
+
described_class.remove_instance_variable(:@ci_node_index) if described_class.instance_variable_defined?(:@ci_node_index)
|
6
|
+
described_class.remove_instance_variable(:@ci_node_total) if described_class.instance_variable_defined?(:@ci_node_total)
|
7
|
+
end
|
8
|
+
|
4
9
|
describe '.ci_node_total' do
|
5
10
|
subject { described_class.ci_node_total }
|
6
11
|
|
@@ -19,12 +24,9 @@ describe KnapsackPro::Config::Env do
|
|
19
24
|
end
|
20
25
|
|
21
26
|
context 'when both KNAPSACK_PRO_CI_NODE_TOTAL and CI environment have value' do
|
22
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
23
|
-
|
24
27
|
before do
|
25
28
|
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => env_value })
|
26
29
|
expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(ci_value)
|
27
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
28
30
|
end
|
29
31
|
|
30
32
|
context 'when values are different' do
|
@@ -34,7 +36,7 @@ describe KnapsackPro::Config::Env do
|
|
34
36
|
it { should eq 5 }
|
35
37
|
|
36
38
|
it 'logs a warning' do
|
37
|
-
expect(
|
39
|
+
expect(described_class).to receive(:warn).with(
|
38
40
|
'You have set the environment variable KNAPSACK_PRO_CI_NODE_TOTAL to 5 which could be automatically determined from the CI environment as 4.'
|
39
41
|
)
|
40
42
|
subject
|
@@ -46,7 +48,7 @@ describe KnapsackPro::Config::Env do
|
|
46
48
|
let(:ci_value) { 5 }
|
47
49
|
|
48
50
|
it 'does not log a warning' do
|
49
|
-
expect(
|
51
|
+
expect(described_class).not_to receive(:warn)
|
50
52
|
subject
|
51
53
|
end
|
52
54
|
end
|
@@ -76,12 +78,9 @@ describe KnapsackPro::Config::Env do
|
|
76
78
|
end
|
77
79
|
|
78
80
|
context 'when both KNAPSACK_PRO_CI_NODE_INDEX and CI environment have value' do
|
79
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
80
|
-
|
81
81
|
before do
|
82
82
|
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => env_value })
|
83
83
|
expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(ci_value)
|
84
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
85
84
|
end
|
86
85
|
|
87
86
|
context 'when values are different' do
|
@@ -91,7 +90,7 @@ describe KnapsackPro::Config::Env do
|
|
91
90
|
it { should eq 3 }
|
92
91
|
|
93
92
|
it 'logs a warning' do
|
94
|
-
expect(
|
93
|
+
expect(described_class).to receive(:warn).with(
|
95
94
|
'You have set the environment variable KNAPSACK_PRO_CI_NODE_INDEX to 3 which could be automatically determined from the CI environment as 2.'
|
96
95
|
)
|
97
96
|
subject
|
@@ -103,7 +102,7 @@ describe KnapsackPro::Config::Env do
|
|
103
102
|
let(:ci_value) { 3 }
|
104
103
|
|
105
104
|
it 'does not log a warning' do
|
106
|
-
expect(
|
105
|
+
expect(described_class).not_to receive(:warn)
|
107
106
|
subject
|
108
107
|
end
|
109
108
|
end
|
@@ -140,12 +139,9 @@ describe KnapsackPro::Config::Env do
|
|
140
139
|
end
|
141
140
|
|
142
141
|
context 'when both KNAPSACK_PRO_CI_NODE_BUILD_ID and CI environment have value' do
|
143
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
144
|
-
|
145
142
|
before do
|
146
143
|
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => env_value })
|
147
144
|
expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return(ci_value)
|
148
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
149
145
|
end
|
150
146
|
|
151
147
|
context 'when values are different' do
|
@@ -155,7 +151,7 @@ describe KnapsackPro::Config::Env do
|
|
155
151
|
it { should eq '7' }
|
156
152
|
|
157
153
|
it 'logs a warning' do
|
158
|
-
expect(
|
154
|
+
expect(described_class).to receive(:warn).with(
|
159
155
|
'You have set the environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID to 7 which could be automatically determined from the CI environment as 8.'
|
160
156
|
)
|
161
157
|
subject
|
@@ -167,7 +163,7 @@ describe KnapsackPro::Config::Env do
|
|
167
163
|
let(:ci_value) { '7' }
|
168
164
|
|
169
165
|
it 'does not log a warning' do
|
170
|
-
expect(
|
166
|
+
expect(described_class).not_to receive(:warn)
|
171
167
|
subject
|
172
168
|
end
|
173
169
|
end
|
@@ -199,12 +195,9 @@ describe KnapsackPro::Config::Env do
|
|
199
195
|
end
|
200
196
|
|
201
197
|
context 'when both KNAPSACK_PRO_CI_NODE_RETRY_COUNT and CI environment have value' do
|
202
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
203
|
-
|
204
198
|
before do
|
205
199
|
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => env_value })
|
206
200
|
expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return(ci_value)
|
207
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
208
201
|
end
|
209
202
|
|
210
203
|
context 'when values are different' do
|
@@ -214,7 +207,7 @@ describe KnapsackPro::Config::Env do
|
|
214
207
|
it { should eq 1 }
|
215
208
|
|
216
209
|
it 'logs a warning' do
|
217
|
-
expect(
|
210
|
+
expect(described_class).to receive(:warn).with(
|
218
211
|
'You have set the environment variable KNAPSACK_PRO_CI_NODE_RETRY_COUNT to 1 which could be automatically determined from the CI environment as 2.'
|
219
212
|
)
|
220
213
|
subject
|
@@ -226,7 +219,7 @@ describe KnapsackPro::Config::Env do
|
|
226
219
|
let(:ci_value) { '7' }
|
227
220
|
|
228
221
|
it 'does not log a warning' do
|
229
|
-
expect(
|
222
|
+
expect(described_class).not_to receive(:warn)
|
230
223
|
subject
|
231
224
|
end
|
232
225
|
end
|
@@ -269,12 +262,9 @@ describe KnapsackPro::Config::Env do
|
|
269
262
|
end
|
270
263
|
|
271
264
|
context 'when both KNAPSACK_PRO_COMMIT_HASH and CI environment have value' do
|
272
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
273
|
-
|
274
265
|
before do
|
275
266
|
stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => env_value })
|
276
267
|
expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return(ci_value)
|
277
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
278
268
|
end
|
279
269
|
|
280
270
|
context 'when values are different' do
|
@@ -284,7 +274,7 @@ describe KnapsackPro::Config::Env do
|
|
284
274
|
it { should eq '3fa64859337f6e56409d49f865d13fd7' }
|
285
275
|
|
286
276
|
it 'logs a warning' do
|
287
|
-
expect(
|
277
|
+
expect(described_class).to receive(:warn).with(
|
288
278
|
'You have set the environment variable KNAPSACK_PRO_COMMIT_HASH to 3fa64859337f6e56409d49f865d13fd7 which could be automatically determined from the CI environment as fe61a08118d0d52e97c38666eba1eaf3.'
|
289
279
|
)
|
290
280
|
subject
|
@@ -296,7 +286,7 @@ describe KnapsackPro::Config::Env do
|
|
296
286
|
let(:ci_value) { '3fa64859337f6e56409d49f865d13fd7' }
|
297
287
|
|
298
288
|
it 'does not log a warning' do
|
299
|
-
expect(
|
289
|
+
expect(described_class).not_to receive(:warn)
|
300
290
|
subject
|
301
291
|
end
|
302
292
|
end
|
@@ -326,12 +316,9 @@ describe KnapsackPro::Config::Env do
|
|
326
316
|
end
|
327
317
|
|
328
318
|
context 'when both KNAPSACK_PRO_BRANCH and CI environment have value' do
|
329
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
330
|
-
|
331
319
|
before do
|
332
320
|
stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => env_value })
|
333
321
|
expect(described_class).to receive(:ci_env_for).with(:branch).and_return(ci_value)
|
334
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
335
322
|
end
|
336
323
|
|
337
324
|
context 'when values are different' do
|
@@ -341,7 +328,7 @@ describe KnapsackPro::Config::Env do
|
|
341
328
|
it { should eq 'main' }
|
342
329
|
|
343
330
|
it 'logs a warning' do
|
344
|
-
expect(
|
331
|
+
expect(described_class).to receive(:warn).with(
|
345
332
|
'You have set the environment variable KNAPSACK_PRO_BRANCH to main which could be automatically determined from the CI environment as feature-branch.'
|
346
333
|
)
|
347
334
|
subject
|
@@ -353,7 +340,7 @@ describe KnapsackPro::Config::Env do
|
|
353
340
|
let(:ci_value) { 'main' }
|
354
341
|
|
355
342
|
it 'does not log a warning' do
|
356
|
-
expect(
|
343
|
+
expect(described_class).not_to receive(:warn)
|
357
344
|
subject
|
358
345
|
end
|
359
346
|
end
|
@@ -383,12 +370,9 @@ describe KnapsackPro::Config::Env do
|
|
383
370
|
end
|
384
371
|
|
385
372
|
context 'when both KNAPSACK_PRO_PROJECT_DIR and CI environment have value' do
|
386
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
387
|
-
|
388
373
|
before do
|
389
374
|
stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => env_value })
|
390
375
|
expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return(ci_value)
|
391
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
392
376
|
end
|
393
377
|
|
394
378
|
context 'when values are different' do
|
@@ -398,7 +382,7 @@ describe KnapsackPro::Config::Env do
|
|
398
382
|
it { should eq '/home/user/myapp' }
|
399
383
|
|
400
384
|
it 'logs a warning' do
|
401
|
-
expect(
|
385
|
+
expect(described_class).to receive(:warn).with(
|
402
386
|
'You have set the environment variable KNAPSACK_PRO_PROJECT_DIR to /home/user/myapp which could be automatically determined from the CI environment as /home/runner/myapp.'
|
403
387
|
)
|
404
388
|
subject
|
@@ -410,7 +394,7 @@ describe KnapsackPro::Config::Env do
|
|
410
394
|
let(:ci_value) { '/home/user/myapp' }
|
411
395
|
|
412
396
|
it 'does not log a warning' do
|
413
|
-
expect(
|
397
|
+
expect(described_class).not_to receive(:warn)
|
414
398
|
subject
|
415
399
|
end
|
416
400
|
end
|
@@ -440,12 +424,9 @@ describe KnapsackPro::Config::Env do
|
|
440
424
|
end
|
441
425
|
|
442
426
|
context 'when both KNAPSACK_PRO_USER_SEAT and CI environment have value' do
|
443
|
-
let(:logger) { instance_double(Logger, info: nil) }
|
444
|
-
|
445
427
|
before do
|
446
428
|
stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => env_value })
|
447
429
|
expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return(ci_value)
|
448
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
449
430
|
end
|
450
431
|
|
451
432
|
context 'when values are different' do
|
@@ -455,7 +436,7 @@ describe KnapsackPro::Config::Env do
|
|
455
436
|
it { should eq 'John Doe' }
|
456
437
|
|
457
438
|
it 'logs a warning' do
|
458
|
-
expect(
|
439
|
+
expect(described_class).to receive(:warn).with(
|
459
440
|
'You have set the environment variable KNAPSACK_PRO_USER_SEAT to John Doe which could be automatically determined from the CI environment as Jane Doe.'
|
460
441
|
)
|
461
442
|
subject
|
@@ -467,7 +448,7 @@ describe KnapsackPro::Config::Env do
|
|
467
448
|
let(:ci_value) { 'John Doe' }
|
468
449
|
|
469
450
|
it 'does not log a warning' do
|
470
|
-
expect(
|
451
|
+
expect(described_class).not_to receive(:warn)
|
471
452
|
subject
|
472
453
|
end
|
473
454
|
end
|
@@ -872,13 +853,11 @@ describe KnapsackPro::Config::Env do
|
|
872
853
|
it "on #{ci} it is false" do
|
873
854
|
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'false' }))
|
874
855
|
|
875
|
-
logger = instance_double(Logger)
|
876
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
877
856
|
ci_env = described_class.detected_ci.new.fixed_queue_split
|
878
857
|
if ci_env == false
|
879
|
-
expect(
|
858
|
+
expect(described_class).not_to receive(:warn)
|
880
859
|
else
|
881
|
-
expect(
|
860
|
+
expect(described_class).to receive(:warn).with(
|
882
861
|
'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to false which could be automatically determined from the CI environment as true.'
|
883
862
|
)
|
884
863
|
end
|
@@ -907,13 +886,11 @@ describe KnapsackPro::Config::Env do
|
|
907
886
|
it "on #{ci} it is true" do
|
908
887
|
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'true' }))
|
909
888
|
|
910
|
-
logger = instance_double(Logger)
|
911
|
-
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
912
889
|
ci_env = described_class.detected_ci.new.fixed_queue_split
|
913
890
|
if ci_env == true
|
914
|
-
expect(
|
891
|
+
expect(described_class).not_to receive(:warn)
|
915
892
|
else
|
916
|
-
expect(
|
893
|
+
expect(described_class).to receive(:warn).with(
|
917
894
|
'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to true which could be automatically determined from the CI environment as false.'
|
918
895
|
)
|
919
896
|
end
|
data/spec/knapsack_pro_spec.rb
CHANGED
@@ -10,7 +10,10 @@ describe KnapsackPro do
|
|
10
10
|
|
11
11
|
subject { described_class.logger }
|
12
12
|
|
13
|
-
before
|
13
|
+
before(:each) do
|
14
|
+
described_class.reset_logger!
|
15
|
+
KnapsackPro::Config::Env.remove_instance_variable(:@ci_node_index) if KnapsackPro::Config::Env.instance_variable_defined?(:@ci_node_index)
|
16
|
+
end
|
14
17
|
after { described_class.reset_logger! }
|
15
18
|
|
16
19
|
context 'when KNAPSACK_PRO_LOG_DIR is set' do
|