knapsack_pro 3.8.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +377 -23
- data/.github/dependabot.yml +11 -0
- data/.github/pull_request_template.md +22 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +325 -1
- data/Gemfile +9 -0
- data/README.md +3 -10
- data/bin/test +15 -0
- data/knapsack_pro.gemspec +7 -6
- data/lib/knapsack_pro/adapters/base_adapter.rb +17 -2
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +3 -3
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +88 -49
- data/lib/knapsack_pro/adapters/spinach_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/test_unit_adapter.rb +2 -0
- data/lib/knapsack_pro/allocator.rb +2 -0
- data/lib/knapsack_pro/allocator_builder.rb +2 -0
- data/lib/knapsack_pro/base_allocator_builder.rb +8 -25
- data/lib/knapsack_pro/build_distribution_fetcher.rb +2 -0
- data/lib/knapsack_pro/client/api/action.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/base.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +5 -0
- data/lib/knapsack_pro/client/api/v1/build_subsets.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/queues.rb +6 -1
- data/lib/knapsack_pro/client/connection.rb +5 -6
- data/lib/knapsack_pro/config/ci/app_veyor.rb +18 -0
- data/lib/knapsack_pro/config/ci/base.rb +27 -0
- data/lib/knapsack_pro/config/ci/buildkite.rb +18 -0
- data/lib/knapsack_pro/config/ci/circle.rb +18 -0
- data/lib/knapsack_pro/config/ci/cirrus_ci.rb +18 -0
- data/lib/knapsack_pro/config/ci/codefresh.rb +18 -0
- data/lib/knapsack_pro/config/ci/codeship.rb +18 -0
- data/lib/knapsack_pro/config/ci/github_actions.rb +26 -0
- data/lib/knapsack_pro/config/ci/gitlab_ci.rb +20 -1
- data/lib/knapsack_pro/config/ci/heroku.rb +18 -0
- data/lib/knapsack_pro/config/ci/semaphore.rb +16 -0
- data/lib/knapsack_pro/config/ci/semaphore2.rb +19 -0
- data/lib/knapsack_pro/config/ci/travis.rb +18 -0
- data/lib/knapsack_pro/config/env.rb +46 -22
- data/lib/knapsack_pro/config/env_generator.rb +2 -0
- data/lib/knapsack_pro/config/temp_files.rb +8 -4
- data/lib/knapsack_pro/crypto/branch_encryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/decryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/digestor.rb +2 -0
- data/lib/knapsack_pro/crypto/encryptor.rb +2 -0
- data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
- data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +2 -0
- data/lib/knapsack_pro/formatters/time_tracker.rb +152 -0
- data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +20 -0
- data/lib/knapsack_pro/hooks/queue.rb +2 -0
- data/lib/knapsack_pro/logger_wrapper.rb +2 -0
- data/lib/knapsack_pro/mask_string.rb +9 -0
- data/lib/knapsack_pro/presenter.rb +6 -3
- data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
- data/lib/knapsack_pro/queue_allocator.rb +2 -0
- data/lib/knapsack_pro/queue_allocator_builder.rb +2 -0
- data/lib/knapsack_pro/railtie.rb +2 -0
- data/lib/knapsack_pro/report.rb +15 -9
- data/lib/knapsack_pro/repository_adapter_initiator.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/base_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/env_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +50 -0
- data/lib/knapsack_pro/runners/base_runner.rb +2 -0
- data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -0
- data/lib/knapsack_pro/runners/minitest_runner.rb +2 -0
- data/lib/knapsack_pro/runners/queue/base_runner.rb +29 -0
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +9 -6
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +13 -6
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +128 -135
- data/lib/knapsack_pro/runners/rspec_runner.rb +22 -3
- data/lib/knapsack_pro/runners/spinach_runner.rb +2 -0
- data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_finder.rb +2 -0
- data/lib/knapsack_pro/task_loader.rb +2 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/base_merger.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +2 -0
- data/lib/knapsack_pro/test_file_cleaner.rb +2 -0
- data/lib/knapsack_pro/test_file_finder.rb +2 -0
- data/lib/knapsack_pro/test_file_pattern.rb +2 -0
- data/lib/knapsack_pro/test_file_presenter.rb +2 -0
- data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +2 -0
- data/lib/knapsack_pro/test_flat_distributor.rb +2 -0
- data/lib/knapsack_pro/tracker.rb +3 -3
- data/lib/knapsack_pro/urls.rb +4 -0
- data/lib/knapsack_pro/utils.rb +2 -0
- data/lib/knapsack_pro/version.rb +3 -1
- data/lib/knapsack_pro.rb +5 -3
- data/lib/tasks/cucumber.rake +2 -0
- data/lib/tasks/encrypted_branch_names.rake +2 -0
- data/lib/tasks/encrypted_test_file_names.rake +2 -0
- data/lib/tasks/minitest.rake +2 -0
- data/lib/tasks/queue/cucumber.rake +13 -0
- data/lib/tasks/queue/minitest.rake +13 -0
- data/lib/tasks/queue/rspec.rake +13 -0
- data/lib/tasks/rspec.rake +5 -0
- data/lib/tasks/salt.rake +2 -0
- data/lib/tasks/spinach.rake +2 -0
- data/lib/tasks/test_unit.rake +2 -0
- data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
- data/spec/integration/runners/queue/rspec_runner.rb +80 -0
- data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +30 -11
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +146 -174
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +22 -48
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +19 -27
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +23 -43
- data/spec/knapsack_pro/client/connection_spec.rb +59 -7
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +22 -8
- data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +51 -16
- data/spec/knapsack_pro/config/ci/circle_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +21 -6
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +20 -6
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +37 -10
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +11 -11
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/travis_spec.rb +8 -8
- data/spec/knapsack_pro/config/env_spec.rb +204 -124
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +424 -0
- data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
- data/spec/knapsack_pro/presenter_spec.rb +1 -1
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +72 -0
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +18 -16
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +17 -14
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +40 -23
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
- data/spec/knapsack_pro/tracker_spec.rb +0 -4
- data/spec/knapsack_pro_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +26 -23
- data/lib/knapsack_pro/config/ci/snap_ci.rb +0 -35
- data/lib/knapsack_pro/config/ci/solano_ci.rb +0 -32
- data/lib/knapsack_pro/extensions/time.rb +0 -7
- data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -56
- data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -112
- data/spec/knapsack_pro/config/ci/snap_ci_spec.rb +0 -104
- data/spec/knapsack_pro/config/ci/solano_ci_spec.rb +0 -73
- data/spec/knapsack_pro/extensions/time_spec.rb +0 -5
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -342
@@ -7,6 +7,9 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
7
7
|
let(:node_index) { double }
|
8
8
|
let(:test_files) { double }
|
9
9
|
let(:node_build_id) { double }
|
10
|
+
let(:masked_user_seat) { double }
|
11
|
+
let(:can_initialize_queue) { [false, true].sample }
|
12
|
+
let(:attempt_connect_to_queue) { [false, true].sample }
|
10
13
|
|
11
14
|
subject do
|
12
15
|
described_class.queue(
|
@@ -23,6 +26,7 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
23
26
|
before do
|
24
27
|
expect(KnapsackPro::Config::Env).to receive(:fixed_queue_split).and_return(fixed_queue_split)
|
25
28
|
expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(node_build_id)
|
29
|
+
expect(KnapsackPro::Config::Env).to receive(:masked_user_seat).and_return(masked_user_seat)
|
26
30
|
end
|
27
31
|
|
28
32
|
context 'when can_initialize_queue=true and attempt_connect_to_queue=true' do
|
@@ -31,20 +35,9 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
31
35
|
|
32
36
|
it 'does not send test_files among other params' do
|
33
37
|
action = double
|
34
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
35
|
-
|
36
|
-
|
37
|
-
request_hash: {
|
38
|
-
fixed_queue_split: fixed_queue_split,
|
39
|
-
can_initialize_queue: can_initialize_queue,
|
40
|
-
attempt_connect_to_queue: attempt_connect_to_queue,
|
41
|
-
commit_hash: commit_hash,
|
42
|
-
branch: branch,
|
43
|
-
node_total: node_total,
|
44
|
-
node_index: node_index,
|
45
|
-
node_build_id: node_build_id,
|
46
|
-
}
|
47
|
-
}).and_return(action)
|
38
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
39
|
+
hash_including(request_hash: hash_excluding(:test_files))
|
40
|
+
).and_return(action)
|
48
41
|
expect(subject).to eq action
|
49
42
|
end
|
50
43
|
end
|
@@ -55,21 +48,19 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
55
48
|
|
56
49
|
it 'sends test_files among other params' do
|
57
50
|
action = double
|
58
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
-
}).and_return(action)
|
51
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
52
|
+
hash_including(request_hash: hash_including(test_files: test_files))
|
53
|
+
).and_return(action)
|
54
|
+
expect(subject).to eq action
|
55
|
+
end
|
56
|
+
|
57
|
+
it "sends authors" do
|
58
|
+
action = double
|
59
|
+
|
60
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
61
|
+
hash_including(request_hash: hash_including(:build_author, :commit_authors))
|
62
|
+
).and_return(action)
|
63
|
+
|
73
64
|
expect(subject).to eq action
|
74
65
|
end
|
75
66
|
end
|
@@ -80,20 +71,9 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
80
71
|
|
81
72
|
it 'does not send test_files among other params' do
|
82
73
|
action = double
|
83
|
-
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
84
|
-
|
85
|
-
|
86
|
-
request_hash: {
|
87
|
-
fixed_queue_split: fixed_queue_split,
|
88
|
-
can_initialize_queue: can_initialize_queue,
|
89
|
-
attempt_connect_to_queue: attempt_connect_to_queue,
|
90
|
-
commit_hash: commit_hash,
|
91
|
-
branch: branch,
|
92
|
-
node_total: node_total,
|
93
|
-
node_index: node_index,
|
94
|
-
node_build_id: node_build_id,
|
95
|
-
}
|
96
|
-
}).and_return(action)
|
74
|
+
expect(KnapsackPro::Client::API::Action).to receive(:new).with(
|
75
|
+
hash_including(request_hash: hash_excluding(:test_files))
|
76
|
+
).and_return(action)
|
97
77
|
expect(subject).to eq action
|
98
78
|
end
|
99
79
|
end
|
@@ -282,14 +282,17 @@ describe KnapsackPro::Client::Connection do
|
|
282
282
|
request_hash: request_hash)
|
283
283
|
end
|
284
284
|
let(:test_suite_token) { '3fa64859337f6e56409d49f865d13fd7' }
|
285
|
-
|
286
285
|
let(:connection) { described_class.new(action) }
|
287
|
-
|
288
|
-
|
289
|
-
stub_const('ENV', {
|
286
|
+
let(:headers) do
|
287
|
+
{
|
290
288
|
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
291
289
|
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
292
|
-
|
290
|
+
'GITHUB_ACTIONS' => 'true',
|
291
|
+
}
|
292
|
+
end
|
293
|
+
|
294
|
+
before do
|
295
|
+
stub_const('ENV', headers)
|
293
296
|
end
|
294
297
|
|
295
298
|
describe '#call' do
|
@@ -310,7 +313,7 @@ describe KnapsackPro::Client::Connection do
|
|
310
313
|
expect(http).to receive(:read_timeout=).with(15)
|
311
314
|
end
|
312
315
|
|
313
|
-
context 'when http method is POST' do
|
316
|
+
context 'when http method is POST on GitHub Actions' do
|
314
317
|
let(:http_method) { :post }
|
315
318
|
|
316
319
|
before do
|
@@ -323,6 +326,7 @@ describe KnapsackPro::Client::Connection do
|
|
323
326
|
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
324
327
|
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
325
328
|
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
329
|
+
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
326
330
|
}
|
327
331
|
).and_return(http_response)
|
328
332
|
end
|
@@ -332,7 +336,30 @@ describe KnapsackPro::Client::Connection do
|
|
332
336
|
end
|
333
337
|
end
|
334
338
|
|
335
|
-
context 'when http method is
|
339
|
+
context 'when http method is POST and CI is undetected' do
|
340
|
+
let(:http_method) { :post }
|
341
|
+
|
342
|
+
let(:headers) do
|
343
|
+
{
|
344
|
+
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
345
|
+
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
346
|
+
}
|
347
|
+
end
|
348
|
+
|
349
|
+
before do
|
350
|
+
expect(http).to receive(:post).with(
|
351
|
+
anything,
|
352
|
+
anything,
|
353
|
+
hash_not_including('KNAPSACK-PRO-CI-PROVIDER')
|
354
|
+
).and_return(http_response)
|
355
|
+
end
|
356
|
+
|
357
|
+
it_behaves_like 'when request got response from API' do
|
358
|
+
let(:expected_http_method) { 'POST' }
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
context 'when http method is GET on GitHub Actions' do
|
336
363
|
let(:http_method) { :get }
|
337
364
|
|
338
365
|
before do
|
@@ -346,6 +373,7 @@ describe KnapsackPro::Client::Connection do
|
|
346
373
|
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
347
374
|
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
348
375
|
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
376
|
+
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
349
377
|
}
|
350
378
|
).and_return(http_response)
|
351
379
|
end
|
@@ -355,6 +383,28 @@ describe KnapsackPro::Client::Connection do
|
|
355
383
|
end
|
356
384
|
end
|
357
385
|
|
386
|
+
context 'when http method is GET and CI is undetected' do
|
387
|
+
let(:http_method) { :get }
|
388
|
+
|
389
|
+
let(:headers) do
|
390
|
+
{
|
391
|
+
'KNAPSACK_PRO_ENDPOINT' => 'http://api.knapsackpro.test:3000',
|
392
|
+
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => test_suite_token,
|
393
|
+
}
|
394
|
+
end
|
395
|
+
|
396
|
+
before do
|
397
|
+
expect(http).to receive(:get).with(
|
398
|
+
anything,
|
399
|
+
hash_not_including('KNAPSACK-PRO-CI-PROVIDER')
|
400
|
+
).and_return(http_response)
|
401
|
+
end
|
402
|
+
|
403
|
+
it_behaves_like 'when request got response from API' do
|
404
|
+
let(:expected_http_method) { 'GET' }
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
358
408
|
context 'when retry request for http method POST' do
|
359
409
|
let(:http_method) { :post }
|
360
410
|
|
@@ -368,6 +418,7 @@ describe KnapsackPro::Client::Connection do
|
|
368
418
|
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
369
419
|
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
370
420
|
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
421
|
+
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
371
422
|
}
|
372
423
|
).and_return(http_response)
|
373
424
|
end
|
@@ -391,6 +442,7 @@ describe KnapsackPro::Client::Connection do
|
|
391
442
|
'KNAPSACK-PRO-CLIENT-NAME' => 'knapsack_pro-ruby',
|
392
443
|
'KNAPSACK-PRO-CLIENT-VERSION' => KnapsackPro::VERSION,
|
393
444
|
'KNAPSACK-PRO-TEST-SUITE-TOKEN' => test_suite_token,
|
445
|
+
'KNAPSACK-PRO-CI-PROVIDER' => 'GitHub Actions',
|
394
446
|
}
|
395
447
|
).and_return(http_response)
|
396
448
|
end
|
@@ -22,12 +22,12 @@ describe KnapsackPro::Config::CI::AppVeyor do
|
|
22
22
|
describe '#node_build_id' do
|
23
23
|
subject { described_class.new.node_build_id }
|
24
24
|
|
25
|
-
context 'when environment exists' do
|
25
|
+
context 'when the environment exists' do
|
26
26
|
let(:env) { { 'APPVEYOR_BUILD_ID' => 123 } }
|
27
27
|
it { should eql 123 }
|
28
28
|
end
|
29
29
|
|
30
|
-
context "when environment doesn't exist" do
|
30
|
+
context "when the environment doesn't exist" do
|
31
31
|
it { should be nil }
|
32
32
|
end
|
33
33
|
end
|
@@ -35,12 +35,12 @@ describe KnapsackPro::Config::CI::AppVeyor do
|
|
35
35
|
describe '#commit_hash' do
|
36
36
|
subject { described_class.new.commit_hash }
|
37
37
|
|
38
|
-
context 'when environment exists' do
|
38
|
+
context 'when the environment exists' do
|
39
39
|
let(:env) { { 'APPVEYOR_REPO_COMMIT' => '2e13512fc230d6f9ebf4923352718e4d' } }
|
40
40
|
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
|
41
41
|
end
|
42
42
|
|
43
|
-
context "when environment doesn't exist" do
|
43
|
+
context "when the environment doesn't exist" do
|
44
44
|
it { should be nil }
|
45
45
|
end
|
46
46
|
end
|
@@ -48,12 +48,12 @@ describe KnapsackPro::Config::CI::AppVeyor do
|
|
48
48
|
describe '#branch' do
|
49
49
|
subject { described_class.new.branch }
|
50
50
|
|
51
|
-
context 'when environment exists' do
|
51
|
+
context 'when the environment exists' do
|
52
52
|
let(:env) { { 'APPVEYOR_REPO_BRANCH' => 'master' } }
|
53
53
|
it { should eql 'master' }
|
54
54
|
end
|
55
55
|
|
56
|
-
context "when environment doesn't exist" do
|
56
|
+
context "when the environment doesn't exist" do
|
57
57
|
it { should be nil }
|
58
58
|
end
|
59
59
|
end
|
@@ -61,12 +61,26 @@ describe KnapsackPro::Config::CI::AppVeyor do
|
|
61
61
|
describe '#project_dir' do
|
62
62
|
subject { described_class.new.project_dir }
|
63
63
|
|
64
|
-
context 'when environment exists' do
|
64
|
+
context 'when the environment exists' do
|
65
65
|
let(:env) { { 'APPVEYOR_BUILD_FOLDER' => '/path/to/clone/repo' } }
|
66
66
|
it { should eql '/path/to/clone/repo' }
|
67
67
|
end
|
68
68
|
|
69
|
-
context "when environment doesn't exist" do
|
69
|
+
context "when the environment doesn't exist" do
|
70
|
+
it { should be nil }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#user_seat' do
|
75
|
+
subject { described_class.new.user_seat }
|
76
|
+
|
77
|
+
context 'when the APPVEYOR_REPO_COMMIT_AUTHOR environment variable exists' do
|
78
|
+
let(:env) { { 'APPVEYOR_REPO_COMMIT_AUTHOR' => 'jane_doe' } }
|
79
|
+
|
80
|
+
it { should eql 'jane_doe' }
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when the APPVEYOR_REPO_COMMIT_AUTHOR environment variable doesn't exist" do
|
70
84
|
it { should be nil }
|
71
85
|
end
|
72
86
|
end
|
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
10
10
|
describe '#node_total' do
|
11
11
|
subject { described_class.new.node_total }
|
12
12
|
|
13
|
-
context 'when environment exists' do
|
13
|
+
context 'when the environment exists' do
|
14
14
|
let(:env) { { 'BUILDKITE_PARALLEL_JOB_COUNT' => 4 } }
|
15
15
|
it { should eql 4 }
|
16
16
|
end
|
17
17
|
|
18
|
-
context "when environment doesn't exist" do
|
18
|
+
context "when the environment doesn't exist" do
|
19
19
|
it { should be nil }
|
20
20
|
end
|
21
21
|
end
|
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
23
23
|
describe '#node_index' do
|
24
24
|
subject { described_class.new.node_index }
|
25
25
|
|
26
|
-
context 'when environment exists' do
|
26
|
+
context 'when the environment exists' do
|
27
27
|
let(:env) { { 'BUILDKITE_PARALLEL_JOB' => 3 } }
|
28
28
|
it { should eql 3 }
|
29
29
|
end
|
30
30
|
|
31
|
-
context "when environment doesn't exist" do
|
31
|
+
context "when the environment doesn't exist" do
|
32
32
|
it { should be nil }
|
33
33
|
end
|
34
34
|
end
|
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
36
36
|
describe '#node_build_id' do
|
37
37
|
subject { described_class.new.node_build_id }
|
38
38
|
|
39
|
-
context 'when environment exists' do
|
39
|
+
context 'when the environment exists' do
|
40
40
|
let(:env) { { 'BUILDKITE_BUILD_NUMBER' => 1514 } }
|
41
41
|
it { should eql 1514 }
|
42
42
|
end
|
43
43
|
|
44
|
-
context "when environment doesn't exist" do
|
44
|
+
context "when the environment doesn't exist" do
|
45
45
|
it { should be nil }
|
46
46
|
end
|
47
47
|
end
|
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
49
49
|
describe '#node_retry_count' do
|
50
50
|
subject { described_class.new.node_retry_count }
|
51
51
|
|
52
|
-
context 'when environment exists' do
|
52
|
+
context 'when the environment exists' do
|
53
53
|
let(:env) { { 'BUILDKITE_RETRY_COUNT' => '1' } }
|
54
54
|
it { should eql '1' }
|
55
55
|
end
|
56
56
|
|
57
|
-
context "when environment doesn't exist" do
|
57
|
+
context "when the environment doesn't exist" do
|
58
58
|
it { should be nil }
|
59
59
|
end
|
60
60
|
end
|
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
62
62
|
describe '#commit_hash' do
|
63
63
|
subject { described_class.new.commit_hash }
|
64
64
|
|
65
|
-
context 'when environment exists' do
|
65
|
+
context 'when the environment exists' do
|
66
66
|
let(:env) { { 'BUILDKITE_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
|
67
67
|
it { should eql '3fa64859337f6e56409d49f865d13fd7' }
|
68
68
|
end
|
69
69
|
|
70
|
-
context "when environment doesn't exist" do
|
70
|
+
context "when the environment doesn't exist" do
|
71
71
|
it { should be nil }
|
72
72
|
end
|
73
73
|
end
|
@@ -75,12 +75,12 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
75
75
|
describe '#branch' do
|
76
76
|
subject { described_class.new.branch }
|
77
77
|
|
78
|
-
context 'when environment exists' do
|
79
|
-
let(:env) { { 'BUILDKITE_BRANCH' => '
|
80
|
-
it { should eql '
|
78
|
+
context 'when the environment exists' do
|
79
|
+
let(:env) { { 'BUILDKITE_BRANCH' => 'main' } }
|
80
|
+
it { should eql 'main' }
|
81
81
|
end
|
82
82
|
|
83
|
-
context "when environment doesn't exist" do
|
83
|
+
context "when the environment doesn't exist" do
|
84
84
|
it { should be nil }
|
85
85
|
end
|
86
86
|
end
|
@@ -88,12 +88,47 @@ describe KnapsackPro::Config::CI::Buildkite do
|
|
88
88
|
describe '#project_dir' do
|
89
89
|
subject { described_class.new.project_dir }
|
90
90
|
|
91
|
-
context 'when environment exists' do
|
91
|
+
context 'when the environment exists' do
|
92
92
|
let(:env) { { 'BUILDKITE_BUILD_CHECKOUT_PATH' => '/home/user/knapsack_pro-ruby' } }
|
93
93
|
it { should eql '/home/user/knapsack_pro-ruby' }
|
94
94
|
end
|
95
95
|
|
96
|
-
context "when environment doesn't exist" do
|
96
|
+
context "when the environment doesn't exist" do
|
97
|
+
it { should be nil }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#user_seat' do
|
102
|
+
subject { described_class.new.user_seat }
|
103
|
+
|
104
|
+
context 'when the BUILDKITE_BUILD_AUTHOR env var exists' do
|
105
|
+
let(:env) do
|
106
|
+
{ 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
|
107
|
+
'BUILDKITE_BUILD_CREATOR' => nil }
|
108
|
+
end
|
109
|
+
|
110
|
+
it { should eql 'Jane Doe' }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when the BUILDKITE_BUILD_CREATOR env var exists' do
|
114
|
+
let(:env) do
|
115
|
+
{ 'BUILDKITE_BUILD_AUTHOR' => nil,
|
116
|
+
'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
|
117
|
+
end
|
118
|
+
|
119
|
+
it { should eql 'John Doe' }
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when both BUILDKITE_BUILD_AUTHOR and BUILDKITE_BUILD_CREATOR env vars exist' do
|
123
|
+
let(:env) do
|
124
|
+
{ 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
|
125
|
+
'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
|
126
|
+
end
|
127
|
+
|
128
|
+
it { should eql 'Jane Doe' }
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when neither env var exists" do
|
97
132
|
it { should be nil }
|
98
133
|
end
|
99
134
|
end
|
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::Circle do
|
|
10
10
|
describe '#node_total' do
|
11
11
|
subject { described_class.new.node_total }
|
12
12
|
|
13
|
-
context 'when environment exists' do
|
13
|
+
context 'when the environment exists' do
|
14
14
|
let(:env) { { 'CIRCLE_NODE_TOTAL' => 4 } }
|
15
15
|
it { should eql 4 }
|
16
16
|
end
|
17
17
|
|
18
|
-
context "when environment doesn't exist" do
|
18
|
+
context "when the environment doesn't exist" do
|
19
19
|
it { should be nil }
|
20
20
|
end
|
21
21
|
end
|
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::Circle do
|
|
23
23
|
describe '#node_index' do
|
24
24
|
subject { described_class.new.node_index }
|
25
25
|
|
26
|
-
context 'when environment exists' do
|
26
|
+
context 'when the environment exists' do
|
27
27
|
let(:env) { { 'CIRCLE_NODE_INDEX' => 3 } }
|
28
28
|
it { should eql 3 }
|
29
29
|
end
|
30
30
|
|
31
|
-
context "when environment doesn't exist" do
|
31
|
+
context "when the environment doesn't exist" do
|
32
32
|
it { should be nil }
|
33
33
|
end
|
34
34
|
end
|
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::Circle do
|
|
36
36
|
describe '#node_build_id' do
|
37
37
|
subject { described_class.new.node_build_id }
|
38
38
|
|
39
|
-
context 'when environment exists' do
|
39
|
+
context 'when the environment exists' do
|
40
40
|
let(:env) { { 'CIRCLE_BUILD_NUM' => 123 } }
|
41
41
|
it { should eql 123 }
|
42
42
|
end
|
43
43
|
|
44
|
-
context "when environment doesn't exist" do
|
44
|
+
context "when the environment doesn't exist" do
|
45
45
|
it { should be nil }
|
46
46
|
end
|
47
47
|
end
|
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::Circle do
|
|
49
49
|
describe '#commit_hash' do
|
50
50
|
subject { described_class.new.commit_hash }
|
51
51
|
|
52
|
-
context 'when environment exists' do
|
52
|
+
context 'when the environment exists' do
|
53
53
|
let(:env) { { 'CIRCLE_SHA1' => '3fa64859337f6e56409d49f865d13fd7' } }
|
54
54
|
it { should eql '3fa64859337f6e56409d49f865d13fd7' }
|
55
55
|
end
|
56
56
|
|
57
|
-
context "when environment doesn't exist" do
|
57
|
+
context "when the environment doesn't exist" do
|
58
58
|
it { should be nil }
|
59
59
|
end
|
60
60
|
end
|
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::Circle do
|
|
62
62
|
describe '#branch' do
|
63
63
|
subject { described_class.new.branch }
|
64
64
|
|
65
|
-
context 'when environment exists' do
|
66
|
-
let(:env) { { 'CIRCLE_BRANCH' => '
|
67
|
-
it { should eql '
|
65
|
+
context 'when the environment exists' do
|
66
|
+
let(:env) { { 'CIRCLE_BRANCH' => 'main' } }
|
67
|
+
it { should eql 'main' }
|
68
68
|
end
|
69
69
|
|
70
|
-
context "when environment doesn't exist" do
|
70
|
+
context "when the environment doesn't exist" do
|
71
71
|
it { should be nil }
|
72
72
|
end
|
73
73
|
end
|
@@ -80,7 +80,42 @@ describe KnapsackPro::Config::CI::Circle do
|
|
80
80
|
it { should eql '~/knapsack_pro-ruby' }
|
81
81
|
end
|
82
82
|
|
83
|
-
context "when environment doesn't exist" do
|
83
|
+
context "when the environment doesn't exist" do
|
84
|
+
it { should be nil }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#user_seat' do
|
89
|
+
subject { described_class.new.user_seat }
|
90
|
+
|
91
|
+
context 'when the CIRCLE_USERNAME env var exists' do
|
92
|
+
let(:env) do
|
93
|
+
{ 'CIRCLE_USERNAME' => 'Jane Doe',
|
94
|
+
'CIRCLE_PR_USERNAME' => nil }
|
95
|
+
end
|
96
|
+
|
97
|
+
it { should eql 'Jane Doe' }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when the CIRCLE_PR_USERNAME env var exists' do
|
101
|
+
let(:env) do
|
102
|
+
{ 'CIRCLE_USERNAME' => nil,
|
103
|
+
'CIRCLE_PR_USERNAME' => 'John Doe' }
|
104
|
+
end
|
105
|
+
|
106
|
+
it { should eql 'John Doe' }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when both CIRCLE_USERNAME and CIRCLE_PR_USERNAME env vars exist' do
|
110
|
+
let(:env) do
|
111
|
+
{ 'CIRCLE_USERNAME' => 'Jane Doe',
|
112
|
+
'CIRCLE_PR_USERNAME' => 'John Doe' }
|
113
|
+
end
|
114
|
+
|
115
|
+
it { should eql 'Jane Doe' }
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when neither env var exists" do
|
84
119
|
it { should be nil }
|
85
120
|
end
|
86
121
|
end
|
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
10
10
|
describe '#node_total' do
|
11
11
|
subject { described_class.new.node_total }
|
12
12
|
|
13
|
-
context 'when environment exists' do
|
13
|
+
context 'when the environment exists' do
|
14
14
|
let(:env) { { 'CI_NODE_TOTAL' => 4 } }
|
15
15
|
it { should eql 4 }
|
16
16
|
end
|
17
17
|
|
18
|
-
context "when environment doesn't exist" do
|
18
|
+
context "when the environment doesn't exist" do
|
19
19
|
it { should be nil }
|
20
20
|
end
|
21
21
|
end
|
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
23
23
|
describe '#node_index' do
|
24
24
|
subject { described_class.new.node_index }
|
25
25
|
|
26
|
-
context 'when environment exists' do
|
26
|
+
context 'when the environment exists' do
|
27
27
|
let(:env) { { 'CI_NODE_INDEX' => 3 } }
|
28
28
|
it { should eql 3 }
|
29
29
|
end
|
30
30
|
|
31
|
-
context "when environment doesn't exist" do
|
31
|
+
context "when the environment doesn't exist" do
|
32
32
|
it { should be nil }
|
33
33
|
end
|
34
34
|
end
|
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
36
36
|
describe '#node_build_id' do
|
37
37
|
subject { described_class.new.node_build_id }
|
38
38
|
|
39
|
-
context 'when environment exists' do
|
39
|
+
context 'when the environment exists' do
|
40
40
|
let(:env) { { 'CIRRUS_BUILD_ID' => 123 } }
|
41
41
|
it { should eql 123 }
|
42
42
|
end
|
43
43
|
|
44
|
-
context "when environment doesn't exist" do
|
44
|
+
context "when the environment doesn't exist" do
|
45
45
|
it { should be nil }
|
46
46
|
end
|
47
47
|
end
|
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
49
49
|
describe '#commit_hash' do
|
50
50
|
subject { described_class.new.commit_hash }
|
51
51
|
|
52
|
-
context 'when environment exists' do
|
52
|
+
context 'when the environment exists' do
|
53
53
|
let(:env) { { 'CIRRUS_CHANGE_IN_REPO' => '2e13512fc230d6f9ebf4923352718e4d' } }
|
54
54
|
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
|
55
55
|
end
|
56
56
|
|
57
|
-
context "when environment doesn't exist" do
|
57
|
+
context "when the environment doesn't exist" do
|
58
58
|
it { should be nil }
|
59
59
|
end
|
60
60
|
end
|
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
62
62
|
describe '#branch' do
|
63
63
|
subject { described_class.new.branch }
|
64
64
|
|
65
|
-
context 'when environment exists' do
|
65
|
+
context 'when the environment exists' do
|
66
66
|
let(:env) { { 'CIRRUS_BRANCH' => 'master' } }
|
67
67
|
it { should eql 'master' }
|
68
68
|
end
|
69
69
|
|
70
|
-
context "when environment doesn't exist" do
|
70
|
+
context "when the environment doesn't exist" do
|
71
71
|
it { should be nil }
|
72
72
|
end
|
73
73
|
end
|
@@ -75,12 +75,12 @@ describe KnapsackPro::Config::CI::CirrusCI do
|
|
75
75
|
describe '#project_dir' do
|
76
76
|
subject { described_class.new.project_dir }
|
77
77
|
|
78
|
-
context 'when environment exists' do
|
78
|
+
context 'when the environment exists' do
|
79
79
|
let(:env) { { 'CIRRUS_WORKING_DIR' => '/tmp/cirrus-ci-build' } }
|
80
80
|
it { should eql '/tmp/cirrus-ci-build' }
|
81
81
|
end
|
82
82
|
|
83
|
-
context "when environment doesn't exist" do
|
83
|
+
context "when the environment doesn't exist" do
|
84
84
|
it { should be nil }
|
85
85
|
end
|
86
86
|
end
|