knapsack_pro 3.8.0 → 7.0.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 +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
|
@@ -72,8 +72,10 @@ describe KnapsackPro::Config::Env do
|
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
context "when ENV
|
|
76
|
-
it
|
|
75
|
+
context "when ENV does not exist" do
|
|
76
|
+
it 'raises' do
|
|
77
|
+
expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID/)
|
|
78
|
+
end
|
|
77
79
|
end
|
|
78
80
|
end
|
|
79
81
|
|
|
@@ -182,6 +184,55 @@ describe KnapsackPro::Config::Env do
|
|
|
182
184
|
end
|
|
183
185
|
end
|
|
184
186
|
|
|
187
|
+
describe '.user_seat' do
|
|
188
|
+
subject { described_class.user_seat }
|
|
189
|
+
|
|
190
|
+
context 'when ENV exists' do
|
|
191
|
+
context 'when KNAPSACK_PRO_USER_SEAT has value' do
|
|
192
|
+
before { stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => 'John Doe' }) }
|
|
193
|
+
it { should eq 'John Doe' }
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
context 'when CI environment has value' do
|
|
197
|
+
before do
|
|
198
|
+
expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return('Jane Doe')
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it { should eq 'Jane Doe' }
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context "when ENV doesn't exist" do
|
|
206
|
+
it { should be nil }
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
describe '.masked_seat_hash' do
|
|
211
|
+
subject { described_class.masked_user_seat }
|
|
212
|
+
|
|
213
|
+
before do
|
|
214
|
+
expect(described_class).to receive(:user_seat).at_least(1).and_return(user_seat)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
context 'when the user seat is a name' do
|
|
218
|
+
let(:user_seat) { 'John Doe' }
|
|
219
|
+
|
|
220
|
+
it { expect(subject).to eq 'Jo** Do*' }
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
context 'when the user seat is an e-mail' do
|
|
224
|
+
let(:user_seat) { 'john.doe@example.com' }
|
|
225
|
+
|
|
226
|
+
it { expect(subject).to eq 'jo**.do*@ex*****.co*' }
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
context 'when the user seat is nil' do
|
|
230
|
+
let(:user_seat) { nil }
|
|
231
|
+
|
|
232
|
+
it { expect(subject).to be_nil }
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
185
236
|
describe '.test_file_pattern' do
|
|
186
237
|
subject { described_class.test_file_pattern }
|
|
187
238
|
|
|
@@ -460,40 +511,6 @@ describe KnapsackPro::Config::Env do
|
|
|
460
511
|
end
|
|
461
512
|
end
|
|
462
513
|
|
|
463
|
-
describe '.modify_default_rspec_formatters' do
|
|
464
|
-
subject { described_class.modify_default_rspec_formatters }
|
|
465
|
-
|
|
466
|
-
context 'when ENV exists' do
|
|
467
|
-
let(:modify_default_rspec_formatters) { 'false' }
|
|
468
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORMATTERS' => modify_default_rspec_formatters }) }
|
|
469
|
-
it { should eq modify_default_rspec_formatters }
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
context "when ENV doesn't exist" do
|
|
473
|
-
it { should be true }
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
describe '.modify_default_rspec_formatters?' do
|
|
478
|
-
subject { described_class.modify_default_rspec_formatters? }
|
|
479
|
-
|
|
480
|
-
before do
|
|
481
|
-
expect(described_class).to receive(:modify_default_rspec_formatters).and_return(modify_default_rspec_formatters)
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
context 'when enabled' do
|
|
485
|
-
let(:modify_default_rspec_formatters) { true }
|
|
486
|
-
|
|
487
|
-
it { should be true }
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
context 'when disabled' do
|
|
491
|
-
let(:modify_default_rspec_formatters) { false }
|
|
492
|
-
|
|
493
|
-
it { should be false }
|
|
494
|
-
end
|
|
495
|
-
end
|
|
496
|
-
|
|
497
514
|
describe '.branch_encrypted' do
|
|
498
515
|
subject { described_class.branch_encrypted }
|
|
499
516
|
|
|
@@ -585,20 +602,6 @@ describe KnapsackPro::Config::Env do
|
|
|
585
602
|
end
|
|
586
603
|
end
|
|
587
604
|
|
|
588
|
-
describe '.fixed_test_suite_split' do
|
|
589
|
-
subject { described_class.fixed_test_suite_split }
|
|
590
|
-
|
|
591
|
-
context 'when ENV exists' do
|
|
592
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT' => false }) }
|
|
593
|
-
it { should eq false }
|
|
594
|
-
end
|
|
595
|
-
|
|
596
|
-
context "when ENV doesn't exist" do
|
|
597
|
-
before { stub_const("ENV", {}) }
|
|
598
|
-
it { should be true }
|
|
599
|
-
end
|
|
600
|
-
end
|
|
601
|
-
|
|
602
605
|
describe '.fixed_test_suite_split?' do
|
|
603
606
|
subject { described_class.fixed_test_suite_split? }
|
|
604
607
|
|
|
@@ -620,38 +623,94 @@ describe KnapsackPro::Config::Env do
|
|
|
620
623
|
end
|
|
621
624
|
end
|
|
622
625
|
|
|
623
|
-
describe '.fixed_queue_split' do
|
|
624
|
-
subject { described_class.fixed_queue_split }
|
|
625
|
-
|
|
626
|
-
context 'when ENV exists' do
|
|
627
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => true }) }
|
|
628
|
-
it { should eq true }
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
context "when ENV doesn't exist" do
|
|
632
|
-
before { stub_const("ENV", {}) }
|
|
633
|
-
it { should be false }
|
|
634
|
-
end
|
|
635
|
-
end
|
|
636
|
-
|
|
637
626
|
describe '.fixed_queue_split?' do
|
|
638
627
|
subject { described_class.fixed_queue_split? }
|
|
628
|
+
after(:each) { described_class.remove_instance_variable(:@fixed_queue_split) }
|
|
639
629
|
|
|
640
630
|
context 'when ENV exists' do
|
|
641
|
-
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=
|
|
642
|
-
|
|
643
|
-
|
|
631
|
+
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=false' do
|
|
632
|
+
[
|
|
633
|
+
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
634
|
+
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
635
|
+
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
636
|
+
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
637
|
+
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
638
|
+
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
639
|
+
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
640
|
+
['GitLab CI', { 'GITLAB_CI' => 'true' }],
|
|
641
|
+
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
642
|
+
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
643
|
+
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
644
|
+
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
645
|
+
['Unsupported CI', {}],
|
|
646
|
+
].each do |ci, env|
|
|
647
|
+
it "on #{ci} it is false" do
|
|
648
|
+
logger = instance_double(Logger)
|
|
649
|
+
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
|
650
|
+
expect(logger).not_to receive(:info)
|
|
651
|
+
|
|
652
|
+
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'false' }))
|
|
653
|
+
|
|
654
|
+
expect(subject).to eq(false)
|
|
655
|
+
end
|
|
656
|
+
end
|
|
644
657
|
end
|
|
645
658
|
|
|
646
|
-
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=
|
|
647
|
-
|
|
648
|
-
|
|
659
|
+
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true' do
|
|
660
|
+
[
|
|
661
|
+
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
662
|
+
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
663
|
+
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
664
|
+
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
665
|
+
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
666
|
+
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
667
|
+
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
668
|
+
['GitLab CI', { 'GITLAB_CI' => 'true' }],
|
|
669
|
+
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
670
|
+
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
671
|
+
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
672
|
+
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
673
|
+
['Unsupported CI', {}],
|
|
674
|
+
].each do |ci, env|
|
|
675
|
+
it "on #{ci} it is true" do
|
|
676
|
+
logger = instance_double(Logger)
|
|
677
|
+
allow(KnapsackPro).to receive(:logger).and_return(logger)
|
|
678
|
+
expect(logger).not_to receive(:info)
|
|
679
|
+
|
|
680
|
+
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'true' }))
|
|
681
|
+
|
|
682
|
+
expect(subject).to eq(true)
|
|
683
|
+
end
|
|
684
|
+
end
|
|
649
685
|
end
|
|
650
686
|
end
|
|
651
687
|
|
|
652
688
|
context "when ENV doesn't exist" do
|
|
653
|
-
|
|
654
|
-
|
|
689
|
+
[
|
|
690
|
+
['AppVeyor', { 'APPVEYOR' => '123' }, false],
|
|
691
|
+
['Buildkite', { 'BUILDKITE' => 'true' }, true],
|
|
692
|
+
['CircleCI', { 'CIRCLECI' => 'true' }, false],
|
|
693
|
+
['Cirrus CI', { 'CIRRUS_CI' => 'true' }, false],
|
|
694
|
+
['Codefresh', { 'CF_BUILD_ID' => '123' }, false],
|
|
695
|
+
['Codeship', { 'CI_NAME' => 'codeship' }, true],
|
|
696
|
+
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }, true],
|
|
697
|
+
['GitLab CI', { 'GITLAB_CI' => 'true' }, true],
|
|
698
|
+
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }, false],
|
|
699
|
+
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }, false],
|
|
700
|
+
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }, false],
|
|
701
|
+
['Travis CI', { 'TRAVIS' => 'true' }, true],
|
|
702
|
+
['Unsupported CI', {}, true],
|
|
703
|
+
].each do |ci, env, expected|
|
|
704
|
+
it "on #{ci} it is #{expected}" do
|
|
705
|
+
logger = instance_double(Logger)
|
|
706
|
+
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
707
|
+
expect(logger).to receive(:info).with("KNAPSACK_PRO_FIXED_QUEUE_SPLIT is not set. Using default value: #{expected}. Learn more at #{KnapsackPro::Urls::FIXED_QUEUE_SPLIT}")
|
|
708
|
+
|
|
709
|
+
stub_const("ENV", env)
|
|
710
|
+
|
|
711
|
+
expect(subject).to eq(expected)
|
|
712
|
+
end
|
|
713
|
+
end
|
|
655
714
|
end
|
|
656
715
|
end
|
|
657
716
|
|
|
@@ -848,57 +907,6 @@ describe KnapsackPro::Config::Env do
|
|
|
848
907
|
end
|
|
849
908
|
end
|
|
850
909
|
|
|
851
|
-
describe '.ci_env_for' do
|
|
852
|
-
let(:env_name) { :node_total }
|
|
853
|
-
|
|
854
|
-
subject { described_class.ci_env_for(env_name) }
|
|
855
|
-
|
|
856
|
-
context 'when CI has no value for env_name method' do
|
|
857
|
-
before do
|
|
858
|
-
expect(KnapsackPro::Config::CI::Circle).to receive_message_chain(:new, env_name).and_return(nil)
|
|
859
|
-
expect(KnapsackPro::Config::CI::Semaphore).to receive_message_chain(:new, env_name).and_return(nil)
|
|
860
|
-
expect(KnapsackPro::Config::CI::Buildkite).to receive_message_chain(:new, env_name).and_return(nil)
|
|
861
|
-
end
|
|
862
|
-
|
|
863
|
-
it do
|
|
864
|
-
expect(subject).to be_nil
|
|
865
|
-
end
|
|
866
|
-
end
|
|
867
|
-
|
|
868
|
-
context 'when CI has value for env_name method' do
|
|
869
|
-
let(:circle_env) { double(:circle) }
|
|
870
|
-
let(:semaphore_env) { double(:semaphore) }
|
|
871
|
-
let(:buildkite_env) { double(:buildkite) }
|
|
872
|
-
|
|
873
|
-
before do
|
|
874
|
-
allow(KnapsackPro::Config::CI::Circle).to receive_message_chain(:new, env_name).and_return(circle_env)
|
|
875
|
-
allow(KnapsackPro::Config::CI::Semaphore).to receive_message_chain(:new, env_name).and_return(semaphore_env)
|
|
876
|
-
allow(KnapsackPro::Config::CI::Buildkite).to receive_message_chain(:new, env_name).and_return(buildkite_env)
|
|
877
|
-
end
|
|
878
|
-
|
|
879
|
-
context do
|
|
880
|
-
let(:buildkite_env) { nil }
|
|
881
|
-
let(:semaphore_env) { nil }
|
|
882
|
-
|
|
883
|
-
it { should eq circle_env }
|
|
884
|
-
end
|
|
885
|
-
|
|
886
|
-
context do
|
|
887
|
-
let(:circle_env) { nil }
|
|
888
|
-
let(:buildkite_env) { nil }
|
|
889
|
-
|
|
890
|
-
it { should eq semaphore_env }
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
context do
|
|
894
|
-
let(:circle_env) { nil }
|
|
895
|
-
let(:semaphore_env) { nil }
|
|
896
|
-
|
|
897
|
-
it { should eq buildkite_env }
|
|
898
|
-
end
|
|
899
|
-
end
|
|
900
|
-
end
|
|
901
|
-
|
|
902
910
|
describe '.log_level' do
|
|
903
911
|
subject { described_class.log_level }
|
|
904
912
|
|
|
@@ -933,7 +941,7 @@ describe KnapsackPro::Config::Env do
|
|
|
933
941
|
end
|
|
934
942
|
|
|
935
943
|
context "when ENV doesn't exist" do
|
|
936
|
-
it { should eql ::Logger::
|
|
944
|
+
it { should eql ::Logger::INFO }
|
|
937
945
|
end
|
|
938
946
|
end
|
|
939
947
|
|
|
@@ -975,4 +983,76 @@ describe KnapsackPro::Config::Env do
|
|
|
975
983
|
expect(described_class.test_runner_adapter).to eql 'RSpecAdapter'
|
|
976
984
|
end
|
|
977
985
|
end
|
|
986
|
+
|
|
987
|
+
describe '.detected_ci' do
|
|
988
|
+
[
|
|
989
|
+
['AppVeyor', { 'APPVEYOR' => '123' }, KnapsackPro::Config::CI::AppVeyor],
|
|
990
|
+
['Buildkite', { 'BUILDKITE' => 'true' }, KnapsackPro::Config::CI::Buildkite],
|
|
991
|
+
['CircleCI', { 'CIRCLECI' => 'true' }, KnapsackPro::Config::CI::Circle],
|
|
992
|
+
['Cirrus CI', { 'CIRRUS_CI' => 'true' }, KnapsackPro::Config::CI::CirrusCI],
|
|
993
|
+
['Codefresh', { 'CF_BUILD_ID' => '123' }, KnapsackPro::Config::CI::Codefresh],
|
|
994
|
+
['Codeship', { 'CI_NAME' => 'codeship' }, KnapsackPro::Config::CI::Codeship],
|
|
995
|
+
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }, KnapsackPro::Config::CI::GithubActions],
|
|
996
|
+
['GitLab CI', { 'GITLAB_CI' => 'true' }, KnapsackPro::Config::CI::GitlabCI],
|
|
997
|
+
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }, KnapsackPro::Config::CI::Heroku],
|
|
998
|
+
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }, KnapsackPro::Config::CI::Semaphore],
|
|
999
|
+
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }, KnapsackPro::Config::CI::Semaphore2],
|
|
1000
|
+
['Travis CI', { 'TRAVIS' => 'true' }, KnapsackPro::Config::CI::Travis],
|
|
1001
|
+
['Unsupported CI', {}, KnapsackPro::Config::CI::Base],
|
|
1002
|
+
].each do |ci, env, expected|
|
|
1003
|
+
it "detects #{ci}" do
|
|
1004
|
+
stub_const("ENV", env)
|
|
1005
|
+
|
|
1006
|
+
expect(described_class.detected_ci).to eq(expected)
|
|
1007
|
+
end
|
|
1008
|
+
end
|
|
1009
|
+
end
|
|
1010
|
+
|
|
1011
|
+
describe '.ci?' do
|
|
1012
|
+
[
|
|
1013
|
+
['CI from env', { 'CI' => 'True' }, true],
|
|
1014
|
+
['Travis CI', { 'TRAVIS' => 'true' }, true],
|
|
1015
|
+
['missing CI from ENV or development', {}, false],
|
|
1016
|
+
].each do |ci, env, expected|
|
|
1017
|
+
it "detects #{ci}" do
|
|
1018
|
+
stub_const("ENV", env)
|
|
1019
|
+
|
|
1020
|
+
expect(described_class.ci?).to eq(expected)
|
|
1021
|
+
end
|
|
1022
|
+
end
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
describe '.ci_provider' do
|
|
1026
|
+
[
|
|
1027
|
+
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
1028
|
+
['Azure Pipelines', { 'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI' => '123' }],
|
|
1029
|
+
['AWS CodeBuild', { 'CODEBUILD_BUILD_ARN' => '123' }],
|
|
1030
|
+
['Bamboo', { 'bamboo_planKey' => '123' }],
|
|
1031
|
+
['Bitbucket Pipelines', { 'BITBUCKET_COMMIT' => '123' }],
|
|
1032
|
+
['Buddy.works', { 'BUDDY' => 'true' }],
|
|
1033
|
+
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
1034
|
+
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
1035
|
+
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
1036
|
+
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
1037
|
+
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
1038
|
+
['Drone.io', { 'DRONE' => 'true' }],
|
|
1039
|
+
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
1040
|
+
['Gitlab CI', { 'GITLAB_CI' => 'true' }],
|
|
1041
|
+
['Google Cloud Build', { 'BUILDER_OUTPUT' => '123' }],
|
|
1042
|
+
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
1043
|
+
['Jenkins', { 'JENKINS_URL' => '123' }],
|
|
1044
|
+
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
1045
|
+
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
1046
|
+
['TeamCity', { 'TEAMCITY_VERSION' => '123' }],
|
|
1047
|
+
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
1048
|
+
['Other', { 'CI' => 'true'}],
|
|
1049
|
+
[nil, {}],
|
|
1050
|
+
].each do |ci, env|
|
|
1051
|
+
it "detects #{ci || 'missing CI from env or development'}" do
|
|
1052
|
+
stub_const("ENV", env)
|
|
1053
|
+
|
|
1054
|
+
expect(described_class.ci_provider).to eq(ci)
|
|
1055
|
+
end
|
|
1056
|
+
end
|
|
1057
|
+
end
|
|
978
1058
|
end
|